So tonight I started working on the #7 Jeremy Blum ‘Arduino basics’ video tutorial. This video covers I2C communication and the Processing programming language.

I2C (Inter-Integrated Circuit), most commonly pronounced I-Squared-C, lets an Arduino communicate with I2C or TWI (Two Wire Interface) devices. In the case of Jeremy’s #7 video, the device is a temperature sensor. The other focus of this video tutorial is the Processing programming language, and that is used in this video to display the temperature data on a computer display.

I2C will be used a lot for microcontroller (MCU) projects, so you’ll want to become familiar and skilled with it. Wikipedia has this to say about I2C:
I²C...is a multimaster serial single-ended computer bus invented by the Philips semiconductor division, today NXP Semiconductors, and used for attaching low-speed peripherals to a motherboard, embedded system, cellphone, or other digital electronic devices. Several competitors, such as Siemens AG...now Intel mobile communications, NEC, Texas Instruments, STMicroelectronics...Motorola...and Intersil, have introduced compatible I²C products to the market...”
SparkFun has a pretty good tutorial on I2C that provides excellent background reading for better understanding the #7 video. The tutorial gives this overview of the protocol:
The Inter-integrated Circuit (I2C) Protocol is a protocol intended to allow multiple “slave” digital integrated circuits (“chips”) to communicate with one or more “master” chips. Like the Serial Peripheral Interface (SPI), it is only intended for short distance communications within a single device. Like Asynchronous Serial Interfaces (such as RS-232 or UARTs), it only requires two signal wires to exchange information….I2C requires a mere two wires, like asynchronous serial, but those two wires can support up to 1008 slave devices. Also, unlike SPI, I2C can support a multi-master system, allowing more than one master to communicate with all devices on the bus (although the master devices can’t talk to each other over the bus and must take turns using the bus lines).”
The master / slave issue is one that will affect your MCU projects that have multiple I2C devices, like a bunch of temperature sensors. Each slave device needs to have its own ID number, and Jeremy mentions that you can sometimes order an I2C device with a specific ID. So that’s something you’ll need to figure out before you order the components for a project.

Jeremy also talks about the SDA and SCL lines. The SparkFun tutorial says this about those:
Each I2C bus consists of two signals: SCL and SDA. SCL is the clock signal, and SDA is the data signal. The clock signal is always generated by the current bus master...Messages are broken up into two types of frame: an address frame, where the master indicates the slave to which the message is being sent, and one or more data frames, which are 8-bit data messages passed from master to slave or vice versa. Data is placed on the SDA line after SCL goes low, and is sampled after the SCL line goes high...To initiate the address frame, the master device leaves SCL high and pulls SDA low. This puts all slave devices on notice that a transmission is about to start.”
If you want to dive deeper into I2C, here are a couple good places, in addition to the above links, to spend a bit of your time:
  1. Adafruit MCP9808 Precision I2C Temperature Sensor Guide (another look at temperature sensors and IC2)
  2. The tronixstuff tutorial on Arduino and IC2
  3. Arduino’s in-depth reference to the Arduino Wire library
  4. Maxim Integrated’s “Proven Implementation of the I2C bus
The temperature sensor used in the #7 video exercise is a Microchip Technology TC74A0-5.0VAT, which you can get from Newark, Digikey and other electronic component distributors. Jeremy mentions checking the Microchip datasheet for the sensor to find out what each pin is for on the sensor. Those pins are shown in the picture to the right.

On the subject of sourcing electronic components, if you haven’t tried using Octopart, a search engine for electronic parts, you might want to give it a try. It’s been very useful for most parts I’ve researched on it. For the #7 video temperature sensor, it gave a helpful view of the cost and availability of the component.

The above temperature sensor is only one of many available temperature sensors. Microchip Technology makes many models, as do other manufacturers like Texas Instruments or Honeywell. There are also temperature sensors which use different technologies, such as thermistor, thermocouple and RTD. I’m doing background research on temperature sensors for a future post on this blog, so if you have questions about temperature sensors, or have a favorite sensor to recommend, email me at arcatabob (at) gmail {dott} com.
Processing language

With regards to the Processing programming language, the main topics in the #7 video are (1) setting the font to be displayed by the Arduino on your computer screen and (2) writing the code to convert the temperature sensor’s input to the Arduino into a computer display of the measured temperature, in both Celsius and Fahrenheit. If you don’t already know how, you’ll learn how to set up the code to let your temperature sensing circuit use Processing, choose and configure your font, grab the temperature data the sensor sends to the Arduino and do math with those signals. For the font, you need to specify color ‘numbers’ for the R, G and B values (red, green, blue). There are lots of tools to help you with figuring out the color values you want, with a 500+ color chart from Cloford.com or the RGB color codes chart from RapidTables being good places to start if you don’t already have a resource for helping you specify color values.
Arduino LED color picker

Two somewhat technical and time-consuming options to consider are color selectors for a smartphone, such as the apps for Android, or, in a slightly recursive twist, the Arduino LED color picker from Andrew Rapp which, in a way, helps you learn about color after you learn about color.  

I guess that’s enough for tonight on I2C, temperature sensing and Processing. If you think you might be able to come to the July 10 meeting of the Humboldt Microcontrollers Group, take a look at the #7 Blum video and read up on those topics a bit. The topics in the video will be the focus of the July 10 meeting. If you have the electronic parts and the time, go through the exercise in the video.

** Important Note ** -- One of the main goals of this blog and the Humboldt Microcontrollers Group is to help connect and expand the community of microcontroller users in Humboldt County and the North Coast. So even if you can’t find the time to go through the video, if you’re interested in I2C temperature-sensing MCU projects or Processing, if you know lots about one of those topics and want to answer questions or share tips, or if you’re just interested in microcontrollers and want to learn more, please show up at the July 10 meeting from 6 to 8 PM at 1385 8th Street, Arcata, California. If youre coming, bring a friend. If you cant come, send a friend!

**********

Categories: , , , , , , ,

Leave a Reply