Tutorial 7 for Arduino: I2C and Processing


This tutorial was featured on the official Arduino blog on 3/9/2011

As promised, this week brings another communications tutorial! In this video, we’ll use both the serial and processing knowledge that we gained last week, plus an I2C enabled temperature-sensing IC. We’ll use processing to generate a pretty room temperature display on your computer screen. If you are new to processing, they have an excellent set of tutorials to help you get started.

You can download the files associated with this episode here:

GNU GPL License Distributed under the GNU General Public (Open-Source) License.
Please Attribute and Share-Alike.


  1. P.S. I downloaded an older version of Processing: 1.5.1. and that version works just fine. Still, I’d like to know what’s changed in V 2 that makes such a difference.

  2. Jeremy ~ thanks for all your excellent tutorials. It’s been a tremendous help.

    Can you tell me what the distance limitations are for I2C or SPI communications? What is the best way to achieve long distances between the master and slave devices? I would like to have a string of temperature and humidity sensors as well as be able to control relays connected to ATTiny processors. Any suggestions would be appreciated.


    • I2C and SPI protocols are designed for on-board communication, or ocassionally between boards via board-to-board connectors. If you are looking to go long distance consider CAN bus, RS-485, UART, or USB.

  3. Yes, I had thought that might be the problem too Jeremy. But now Processing version 2.1.1 has been released and while it does seem to accept the “readStringUntil(‘.’)” command it still hitches up on the “substring()” functions and shuts down the serial port without finishing parsing the data. I used some print() commands to see what is happening on the serial monitor. I can see that the readStringUntil(‘.’) is doing what it should do, but there are spurious ‘null’ signals coming through every once in a while between the expected data and processing is telling me it can’t deal with the ‘null’ data so it shuts the serial port down. I checked the Arduino side and the serial monitor shows consistently clean data coming from the Arduino. There are no spurious ‘null’ signals coming from the Arduino. So, I’m guessing that there must be some larger incompatibility issue with Processing and the newest version Mac OS 10.9.1. Maybe some sort of Java incompatibility? Even the older 1.5.1 version of Processing is fragile. It works most of the time but it too has a tendency to freeze up and there are Java mismatch error messages showing that I don’t understand. I wonder if anyone else is having trouble using Processing on their Macs?

  4. Hi Jeremy,
    Videos are brilliant but is the Arduino able to ‘point’ to an Address in the chip and then just read from that address alone and not then entire data on the chip. e.g 0x1C would be the chip address point to 0x0A then write whatever was needed. so can i just read back from this address and not have the pointer start at 0x00??? This could be the simplest thing but my head is melted!!!! Thanks.

  5. How do you determine the id number of an IC (like the temp. sensor , for example)?
    Or do you just declare it in the program code?

  6. Dear Mr. Blum,

    I have read so many tutorial that my head is spinning now, no matter which program I use or code I use it still will not display my data.

    I just used your code with miner alteration and still nothing is displayed, on the version 2.1.1.

    PS. it will not even compile on the 1.5 version.

    please any help?

  7. I can’t make i2c to work on arduino due, do you have any idea why?

  8. Which is the easiest way to send float numbers through the I2C connections?

  9. I am trying to solve a problem

    I am using Arduino DUE to connect MMA7455 Accelerometer of parallax

    but it seems that I2C doesn’t recognize the entire wiring diagram, please help me because I am in troubles. I tried to copy a lots of codes from but nobody seems to be able to give the right answer. More over in internet many people have the same problem, Now I don’t know if I have to swithc to Arduino UNO.

    Please help me

  10. Hi i need to connect two BMP180 to the I2C line, but the Address of them are the same help please. how can i change the address of the sensor

  11. Pingback: Tutorial 07 for Arduino: I2C Communication and Processing | Faweiz Video

  12. i have tried a project on arduino in which as i rotate potentiometer the data is to be sended to processing monitor but as i don’t rotating potentiometer then also i’m getting some fixed range random values and while turning potentiometer as well.

    • hey, you might be having noise problems, connect your potentiometer to the the breadboard and then connect the other end of the potentiometer to a external small value resistor and then the resistor to the ground.

  13. Pingback: Comunicatie I2C intre placi Arduino | Robofun Blog

  14. Pingback: Interfacing LCD to arduino – Liquid Crystal Displays | Simulacrum Universum

  15. I come across your website with a great Arduino tutorial. Now, I am working on the project that I have to detect the existing of people in the room. I try with motion sensor but it is not working the way I want it to. It sending signal only when people moving. I want to know the existing of the people in that room. Therefore, I found one great sensor that might work, MEMS IR Thermal Sensor – D6T-44-L06. However, it is lacking the tutorial on how to make it work with Arduino. I hope you can share some of your experience with me if you had happened to use that sensor. Thank :D

  16. hi i have a 12bit adc i2c im trying to get working the item is in the link below could you help me with this please ?|pcrid|56512299789|kword|adc121c021cimk|match|p|plid|&CMP=KNC-GUK-FUK-GEN-SKU-G12

  17. Hi Mr.

    I need you to help me … How can I connect 2 arduino together??

    one arduino attach to GSM and other attach to some sensors…

    thank you

Leave a Reply

Required fields are marked *.