i2c volt tolerance / 2nd bus mLink relayboard

Forum for posting topics and questions about anything.
Post Reply
lewsut
Posts: 8
Joined: Tue Jan 09, 2024 9:08 pm

i2c volt tolerance / 2nd bus mLink relayboard

Post by lewsut » Tue Jan 09, 2024 9:22 pm

Hello,

Just received my 4ch board, i'm fairly used to such boards having separate i2c voltage provision to the relay voltage however that's not the case here and was going to use a level shifter as is the norm. However the official instructions confused me a little, especially that of the Rpis whos GPIO is notoriously not 5v tolerant.

Am I missing something here? The voltage on the relayboards SCL/SDA lines with 5v input are 5v, this could very easily damage my micro controller certainly it's outside of Rpi , ESP32 et al's official recommendations.

I shall use a level shifter to be safe but it may be a useful future enhancement to separate out the voltages or have a solder join pad and I am still not convinced by the Rpi instructions.

My second stumbling block is that I use Wire1 (I have a few i2c busses) how do I change the bus in setup? I see the library is written around a single bus. I would usually expect something like i2cThing.begin_I2C(address,&Wire1) , this seems fairly common now.

Edit: I see that I can probably solve the second issue using things mentioned in viewtopic.php?f=131&t=3003 I'll give that a go this evening.

andrew
Site Admin
Posts: 1384
Joined: Sun Aug 05, 2012 4:15 pm

Re: i2c volt tolerance / 2nd bus mLink relayboard

Post by andrew » Wed Jan 10, 2024 11:25 am

Am I missing something here? The voltage on the relayboards SCL/SDA lines with 5v input are 5v, this could very easily damage my micro controller certainly it's outside of Rpi , ESP32 et al's official recommendations.

On your mLink relay module there are a set of 3 pads labelled ‘END DEV’. If you cut the tracks in between the 3 pads this will remove the 5V pullups from the SDA and SCL pins. You will then be able to use it with your Pi’s built in 3.3V pullups (but see note at bottom of this post).

You are correct though, I think this should be made clearer and I’ll get a note about non 5V tolerant microcontrollers added to the product threads shortly.


My second stumbling block is that I use Wire1 (I have a few i2c busses) how do I change the bus in setup? I see the library is written around a single bus. I would usually expect something like i2cThing.begin_I2C(address,&Wire1) , this seems fairly common now.

The mLink python library makes use of the smbus2 module for I2C communication:

https://pypi.org/project/smbus2/

The mLink library passes the I2C bus number to the smbus library when an instance of the mLink library is created via the ml = mLink.mLink(1) command (see the example python scripts). You can try changing this number but this is something the smbus2 documentation isn’t very clear about and the library hasn’t been tested with anything other than the standard I2C interface.

Also note that anything other than GPIOS 2 & 3 will not have pullups fitted.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

lewsut
Posts: 8
Joined: Tue Jan 09, 2024 9:08 pm

Re: i2c volt tolerance / 2nd bus mLink relayboard

Post by lewsut » Wed Jan 10, 2024 12:16 pm

Cheers Andrew,

Is there any documentation on the end dev pads? (I did wonder what their use was) I could do with a drawing schematic to see exactly what's happening. although this explains most of what I want to know viewtopic.php?f=131&t=3003&p=8605&hilit=end+dev#p8605

Also will I need to supply the relay module with 3.3v from my MCU or is the relay board taking care of this? I assume the STM8 is getting 3.3v from somewhere...

I'm mostly a C/C++ guy I'm unlikely to use this board with Rpi and thus Python so I'll whip something up to utilise wire1.

Thanks for the reply, appreciate it, I'll have a good poke at it tonight.

andrew
Site Admin
Posts: 1384
Joined: Sun Aug 05, 2012 4:15 pm

Re: i2c volt tolerance / 2nd bus mLink relayboard

Post by andrew » Wed Jan 10, 2024 3:05 pm

Is there any documentation on the end dev pads? (I did wonder what their use was) I could do with a drawing schematic to see exactly what's happening. although this explains most of what I want to know viewtopic.php?f=131&t=3003&p=8605&hilit=end+dev#p8605

Yes, the post you linked to shows exactly what you need to do. Just cut the tracks between the jumper pads as shown in the second image of that post.

To make it a little clearer, the centre pad is 5V, and the outer two pads are in turn connected to the +Ve end of the two 10K pullup resistors. So cutting those tracks is effectively the same as removing those resistors from the circuit.


Also will I need to supply the relay module with 3.3v from my MCU or is the relay board taking care of this? I assume the STM8 is getting 3.3v from somewhere…

I'm mostly a C/C++ guy..
Just supply the module with 5V via the mLink header as normal. The STM8 is powered directly from the 5V supply but with the pullups disconnected the I2C data/clk pins will then only be pulled up to 3.3V via the pullups on your Pi.

In case you're not aware, I2C pins works differently from standard GPIO pins in that they can only pull their clk/data lines low. It is the additional pullups that drive the pin high. So even though the STM8 is running at 5V it cannot put 5V onto these pins itself.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

lewsut
Posts: 8
Joined: Tue Jan 09, 2024 9:08 pm

Re: i2c volt tolerance / 2nd bus mLink relayboard

Post by lewsut » Wed Jan 10, 2024 6:19 pm

Perfect, thanks for the info!

Post Reply

Return to “General Discussion”