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 Jeremys #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 youll 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 cant 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 thats something youll 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:
- Adafruit MCP9808 Precision I2C Temperature Sensor Guide (another look at temperature sensors and IC2)
- The tronixstuff tutorial on Arduino and IC2
- Arduinos in-depth reference to the Arduino Wire library
- Maxim Integrateds Proven Implementation of the I2C bus
On the subject of sourcing electronic components, if you havent tried using Octopart, a search engine for electronic parts, you might want to give it a try. Its been very useful for most parts Ive 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. Im 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 sensors input to the Arduino into a computer display of the measured temperature, in both Celsius and Fahrenheit. If you dont already know how, youll 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 dont 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 thats 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 cant find the time to go through the video, if youre 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 youre 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!
**********
0 komentar:
Posting Komentar