Raspberry Pi TC74 I²C

In my previous post I have connected a TC74 via USB to the Raspberry Pi. It works, but I consider it a waste because the Raspberry Pi has GPIO’s available.

So, I have connected a TC74 directly to GPIO-0 & GPIO-1 of the Raspberry Pi.

On the software side, I make use of the Debian Sqeeuze Image, but upgraded the kernel to Chris Boot’s Raspberry Pi Kernel. I have also installed i2c-tools.

With i2cdetect I can see the TC74 on the I²C bus.

And with i2cget, I can read the current temperature (hex) of the TC74.

To make all this available to a webserver like in my previous post, I have changed cgi-bin/temp to the following:

echo Content-type: text/html

# USB : 
# echo "document.write(\"`/home/pi/usb/temp`\");"

# I2C :
Thex=`/usr/sbin/i2cget -y 0 0x48 0 b | cut -d"x" -f2 | tr '[:lower:]' '[:upper:]'`
T=`echo "ibase=16 ; $Thex" | bc`
echo "document.write(\"$T\");"

Which gives the following result when I connect with a web browser to the Raspberry Pi:

12 comments for “Raspberry Pi TC74 I²C

  1. Ian
    September 27, 2012 at 3:23 pm

    hi there just tried this out on two seperate Pis and i2cdetect couldnt find the sensor. I noticed a small yellow/orange blob on your bit of strip board there (capacitor maybe) can you let me know what that is and how it helps make it all work.



  2. September 27, 2012 at 10:26 pm

    The yellow/orange blob is indeed a capacitor of 1µF, which is connected between VDD/GND of the TC74. See http://www.janwagemakers.be/pics/RPI-TC74.jpeg for a quick schematic.

  3. James Wilson
    November 26, 2012 at 7:17 pm

    why use a 1uF? i have mine setup with 2 10K pull ups as the datasheet suggested, is there reason to decouple it?

    • December 1, 2012 at 9:06 am

      The Raspberry Pi already has resistors on the i²c-bus, so on the Raspberry Pi adding pull ups is not needed.

      About the extra capacitor, when I was testing the TC74 with a PIC microcontroller, the output of the TC74 was not very reliable. Adding the capacitor solved the problem. So, I included the capacitor when I connected the TC74 to the Raspberry Pi.

      Is it really needed? Probably not… it will depend on various thing like the length of the wires, I guess.

      Like always, YMMV 😉

  4. James Wilson
    December 1, 2012 at 7:32 pm

    Why is it I ALWAYS forget about it already having pull ups… 😛

    I tried decoupling it and noticed no real improvement in the responses, but as they say, its always wise to over protect. anything more complex ie multiple i2c devices on the bus decoupling is wise.

    On that note, has you ever tried adding several devices to the bus?

    • December 2, 2012 at 10:26 am

      I’ve not tried to add multiple devices to the i²c bus yet. I have a microchip MCP23008 lying around here I like to experiment with, but haven’t come to it…

  5. thank you
    March 27, 2013 at 3:17 am

    Thank You for this excellant work, just want you to know I appreciate it and will use it, pleasekeep up the great work 🙂 Karl Lumpkins, Yuma, Az.

  6. Nick Adams
    April 11, 2013 at 12:42 pm

    Thanks for sharing this I intend to give this a whirl as soon as I get my components delivered. One question where are the wires going off the picture going to?

    Thanks Nick

    • April 12, 2013 at 9:38 am

      In that picture, I was powering the RPI through the GPIO header instead of using the micro USB connector.

  7. robert woodliff
    April 16, 2013 at 10:50 am

    This comment is a reflection of my great lack of knowledge …….. ie I know very little & therfore this will be a very stupid question …… and you may have it some were in the information, that you have given , but I have not seen / found it . As I understand ( this may also be incorrect ) TC74 comes at 5 & 3.3 volts could you please define the exact model number of the device you are using so it don’t get £5 of rubbish I cannot use .
    Regards Bob ( London UK )

    • April 16, 2013 at 10:56 pm

      Hey, I don’t find your question stupid 😉

      I’ve used a TC74A0-3.3VAT.
      FYI, you can try to request some free samples at microchip.

  8. drunkenmonkey
    June 11, 2014 at 2:31 pm

    Thanks for the info, helped me get mine working. Your command works great in a script or terminal but breaks if put in an alias, or a function in .bashrc. This one-liner works in those situations:

    /usr/bin/i2cget -y 1 0x48 0 b | cut -d’x’ -f2 | tr ‘[:lower:]’ ‘[:upper:]’ | sed ‘s|^|ibase=16;|’ | bc | sed ‘s|$|C|’

    and I know a lot of raspi owners are new to linux so if you wanted to put that into a variable called T like in the article:(it replaces the first two lines under # I2C)

    T=$(/usr/bin/i2cget -y 1 0x48 0 b | cut -d’x’ -f2 | tr ‘[:lower:]’ ‘[:upper:]’ | sed ‘s|^|ibase=16;|’ | bc | sed ‘s|$|C|’)

    To add a permanent alias(so ya dont have to remember the command or type the location of a script), useful if you are using through a terminal.

    echo -e “\nalias temp=\”/usr/bin/i2cget -y 1 0x48 0 b | cut -d’x’ -f2 | tr ‘[:lower:]’ ‘[:upper:]’ | sed ‘s|^|ibase=16;|’ | bc | sed ‘s|$|C|’\”\n” >> ~/.bash_aliases

    you can add to ~/.bashrc instead if you wish. To run type “temp” in a terminal (without the “”)..

    Hopefully someone may find this useful.

Leave a Reply

Your email address will not be published. Required fields are marked *