Connect a thermometer device to the I2C ports

3 posts
by mrumpf » Sun Jul 01, 2012 3:26 pm

I have a thermometer/hygrometer which directly connects a I2C EEPROM AT24C256 to a RS232 connector. The I2C protocol is spoken by bit-banging (see docs from here: the DSR (SCL) and CTS (SDA) lines. A request to takeover the I2C bus is sent via the TxD line (0x55).
That is the reason why a simple RS232 to USB adapter does not work as there is no serial protocol being spoken.

Because I'm not firm with electronics, the question is whether I can connect the 3 lines directly to the GPIO lines:
* DSR (SCL) -> GPIO 1 (SCL)
* CTS (SDA) -> GPIO 0 (SDA)
* TxD -> GPIO 14 (TxD)

My question is about the voltage levels. The thermometer is powered by 3 Micro Cells with 1.5 V each and I have measured 4V with my voltmeter. I just want to make sure that I will not brick my Raspberry Pi which has arrived yesterday after only 4 months :o
I have read the following section from the RPi Wiki:
"GPIO voltage levels are 3v3 and are not 5v tolerant. There is no over-voltage protection on the board - the intention is that people interested in serious interfacing will use an external board with buffers, level conversion and analog I/O rather than soldering directly onto the main board."

Posts: 2
Joined: Sun Jul 01, 2012 12:02 pm
Location: Germany
by mahjongg » Sun Jul 01, 2012 3:30 pm
I2C devices do not push the I2C lines high, and rely only on the pullups for logic '1', as the PI's I2C ports have (1K8) pullups to 3V3 already you do not need to provide you own.

If you are "bitbanging" I2C on standard GPIO's instead of using the real I2C interface, then just add 1K8 pullups to 3V3 yourself on these GPIO pins.

Also if you have a slow 5V signal that you want to interface to a 3V3 input, such as the raspi's, then just use a resistor divider using 2K2 and 3K3 resistors to divide the signal to 3/5th. Also then the 2K2 resistor in series with the signal will protect against accidentally programming the GPIO as output.
User avatar
Forum Moderator
Forum Moderator
Posts: 7935
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands
by mrumpf » Tue Jul 03, 2012 8:20 pm
Because I'm not sure whether I understand you correctly I tried to create some schematics: ... ermometer/

You mention that this setup protects against accidentally setting a GPIO port as output. But in fact this does not happen accidentally. The GPIO 25 must be used as output in order to takeover the I2C bus of the device, i.e. sending "0x55" out. Additionally, the clock signal (SCL - DSR - GPIO 23) must be generated against the thermometer, i.e. sending out the clock signal.
So I have 2 outputs and one input GPIO port (CTS - SDA - GPIO 23).
Posts: 2
Joined: Sun Jul 01, 2012 12:02 pm
Location: Germany