This is a very simple library that I wrote earlier this year, I've just now added a couple example sketches and some documentation, so that folks might actually stand a chance of figuring it out.
The library works in conjunction with the standard Arduino SPI library to interface one or more MAX6675 Cold-Junction-Compensated K-Thermocouple-to-Digital Converters from Maxim Integrated Products.
I've posted the library on github, click the Downloads button to download the library, examples, and ReadMe as a .zip or .tar.gz file.
Questions, comments, suggestions, gripes, etc., always welcome!
One guy's notes on his exploration of the Arduino open-source electronics prototyping platform
Showing posts with label software. Show all posts
Showing posts with label software. Show all posts
21 July 2011
28 April 2011
A "Minimal" Arduino/XBee/Pachube Sensor Network
One or two people have asked in online forums for code from my sensor network, and while I'm usually happy to share, it's full of a lot of extraneous stuff (RTCs, NTP, displays, thermocouples) that might not be of interest to everyone, but more importantly, that probably only obscures the fundamentals of XBee networking and communicating with Pachube.
So with that in mind, I cut out the extraneous stuff, and just left the bare essentials: A remote sensor unit which transmits a single reading from a photocell once per minute to a base unit which connects to the internet and forwards the data on to Pachube.
Bill of materials -- Base unit:
(1) Arduino Uno, Through-hole or SMD edition
(1) Arduino Ethernet shield
(1) XBee ZB low power Zigbee Module, Digi Product ID XB24-Z7CIT-004, XB24-Z7WIT-004, XB24-Z7SIT-004, or XB24-Z7UIT-004 (these differ only in the antenna, they are functionally equivalent)
(1) Adafruit Industries XBee Adapter
(1) LED for heartbeat (optional)
(1) 330-ohm resistor for heartbeat LED (optional)
XBee configuration:
Bill of materials -- Remote unit:
(1) Arduino Uno or similar (Through-hole, SMD edition, Boarduino, etc.)
(1) XBee ZB low power Zigbee Module, Digi Product ID XB24-Z7CIT-004, XB24-Z7WIT-004, XB24-Z7SIT-004, or XB24-Z7UIT-004.
(1) Adafruit Industries XBee Adapter
(1) CdS photocell
(1) 10K resistor
XBee configuration is same as above, except:
Here are the sketches. Unzip into the Arduino Sketchbook folder. Before uploading, be sure to disconnect the XBee from Arduino pin 0. Also be sure to enter your MAC, IP, and Pachube API key in the base station main module, and your Pachube feed number and the address of your network coordinator XBee in the main module for the remote unit.
Here is the Pachube feed. Pretty boring, but at least you can see that it does work. Not sure how long I'll leave it running, probably until I need the parts for something else! Feedback and questions welcome!
Note that in the following wiring diagrams, the XBees plug into the Adafruit adapter, which in turn plugs into the breadboard. The XBee pins do not (in fact, cannot, spacing is different) connect to the breadboard. The adapter plugs into the breadboard, this is represented by the 10-pin header below the XBee.
So with that in mind, I cut out the extraneous stuff, and just left the bare essentials: A remote sensor unit which transmits a single reading from a photocell once per minute to a base unit which connects to the internet and forwards the data on to Pachube.
Bill of materials -- Base unit:
(1) Arduino Uno, Through-hole or SMD edition
(1) Arduino Ethernet shield
(1) XBee ZB low power Zigbee Module, Digi Product ID XB24-Z7CIT-004, XB24-Z7WIT-004, XB24-Z7SIT-004, or XB24-Z7UIT-004 (these differ only in the antenna, they are functionally equivalent)
(1) Adafruit Industries XBee Adapter
(1) LED for heartbeat (optional)
(1) 330-ohm resistor for heartbeat LED (optional)
XBee configuration:
- Load the Zigbee Coordinator API firmware (I'm using Version 2170).
- Set the PAN ID as desired, to match that of the sensor unit(s).
- Set API mode 2 (AP=2).
- Set baud rate to 9600.
Bill of materials -- Remote unit:
(1) Arduino Uno or similar (Through-hole, SMD edition, Boarduino, etc.)
(1) XBee ZB low power Zigbee Module, Digi Product ID XB24-Z7CIT-004, XB24-Z7WIT-004, XB24-Z7SIT-004, or XB24-Z7UIT-004.
(1) Adafruit Industries XBee Adapter
(1) CdS photocell
(1) 10K resistor
XBee configuration is same as above, except:
- Load the Zigbee Router API firmware (I'm using Version 2370).
Here are the sketches. Unzip into the Arduino Sketchbook folder. Before uploading, be sure to disconnect the XBee from Arduino pin 0. Also be sure to enter your MAC, IP, and Pachube API key in the base station main module, and your Pachube feed number and the address of your network coordinator XBee in the main module for the remote unit.
Here is the Pachube feed. Pretty boring, but at least you can see that it does work. Not sure how long I'll leave it running, probably until I need the parts for something else! Feedback and questions welcome!
Note that in the following wiring diagrams, the XBees plug into the Adafruit adapter, which in turn plugs into the breadboard. The XBee pins do not (in fact, cannot, spacing is different) connect to the breadboard. The adapter plugs into the breadboard, this is represented by the 10-pin header below the XBee.
![]() |
| Wiring the base unit |
![]() |
Wiring the remote unit |
![]() |
| My base unit |
![]() |
| My remote unit (using a Boarduino) |
25 January 2011
A simple wireless sensor network
A lot of pieces come together in this project. It seems to be working well; I'm pretty happy with it. I'll jump right in and give a high level description of the pieces.
I started this blog with digital clocks and this project starts with one as the sensor unit. It consists of a Arduino Pro Mini 328 (check the size of that guy!), a "Chronodot" Real-Time Clock (RTC) module from Macetech based on the Maxim DS3231 chip, and an XBee ZigBee module from Digi International (part no. XB24-Z7WIT-004). Just for fun and to generate a little more data to collect, I connected a simple Cadmium-Sulfide (CdS) photocell to one of the Arduino's A/D inputs to measure light intensity wherever the sensor unit happens to be. The readout is a 16x2 LCD from Sparkfun. See the picture below.
A few words on the parts. The Arduino Pro Mini has the same ATmega328 microprocessor and basic specs as the Arduino Uno, but is much smaller! I soldered on headers so it would plug into a breadboard. What it doesn't have is a power supply or a USB interface. Both Sparkfun and Adafruit make nice little breadboard power supplies that work great and accept the same wall wart input as the Uno. As for the USB connection, you'll need an FTDI breakout board (about the size of a small postage stamp) and FTDI drivers to do the interface. Once you have that (and it's pretty easy), the USB interface works pretty much the same as the Uno.
The DS3231 RTC is pretty cool too. If you keep it between freezing and about 100°F, it will keep time within two parts per million, which is about a minute per year. It accomplishes this by monitoring its own temperature (a major cause of oscillator drift) and switching capacitors in and out of the crystal oscillator circuit to trim the frequency. The crystal itself is on-chip which also helps accuracy. A very sweet piece of engineering. In addition to the date and time, we can also read the temperature from it (in °C to the nearest quarter degree).
Last we have the XBee module, which uses the ZigBee specification, based on the IEEE 802.15.4 standard. These modules are low power and don't offer terribly high bandwidth, which is just fine for sensor networks which tend to send very small amounts of data at any one time. The really neat thing is that XBee modules form themselves (with just about zero help from you!) into self-healing mesh networks. They can be configured either as network coordinators, routers, or end devices. Every network must have exactly one coordinator. Routers can do anything an end device can, plus forward messages between devices. End devices cannot route traffic, and must do all their business through a parent node which is either a coordinator or a router. Additionally, end devices can sleep in a low-power mode which would be very good for battery-powered remote sensors. If an end device is sleeping, its parent node will store traffic for it. The XBee in my sensor module is configured as a router.
Now we come to what I call the "base" unit. This consists of an Arduino Uno, with an Ethernet shield added on top and connected to my internet router. Also we have an XBee module, configured as the network coordinator, and a seven-segment LED display.
The whole thing works like this. Once a minute, the sensor unit sends the temperature and light intensity data to the base unit. The base unit sends the data to Pachube (click here to go to the Pachube feed for this project) and displays the temperature on the LED display. We can then download the data from Pachube, or have it create charts like below. These are live charts and will refresh every few minutes (not sure how often exactly, haven't found the spec on Pachube yet). So if you refresh this page, you will see current data, assuming that a cat hasn't chewed through any wires on my end in the meantime.

&l=Arbitrary+units+(0-1023+from+A/D+converter)&s=4&r=2)
DS18B20 Temperature Sensor
It would be straightforward to add additional sensor units to this project. One idea I have in mind is to measure the temperature of my wood stove with a thermocouple. Maybe send a text message to my mobile phone if it got over a certain temperature.
I started this blog with digital clocks and this project starts with one as the sensor unit. It consists of a Arduino Pro Mini 328 (check the size of that guy!), a "Chronodot" Real-Time Clock (RTC) module from Macetech based on the Maxim DS3231 chip, and an XBee ZigBee module from Digi International (part no. XB24-Z7WIT-004). Just for fun and to generate a little more data to collect, I connected a simple Cadmium-Sulfide (CdS) photocell to one of the Arduino's A/D inputs to measure light intensity wherever the sensor unit happens to be. The readout is a 16x2 LCD from Sparkfun. See the picture below.
![]() |
| Sensor Unit. L to R: Arduino, RTC, XBee, Photocell and XBee status LEDs, power supply. |
A few words on the parts. The Arduino Pro Mini has the same ATmega328 microprocessor and basic specs as the Arduino Uno, but is much smaller! I soldered on headers so it would plug into a breadboard. What it doesn't have is a power supply or a USB interface. Both Sparkfun and Adafruit make nice little breadboard power supplies that work great and accept the same wall wart input as the Uno. As for the USB connection, you'll need an FTDI breakout board (about the size of a small postage stamp) and FTDI drivers to do the interface. Once you have that (and it's pretty easy), the USB interface works pretty much the same as the Uno.
The DS3231 RTC is pretty cool too. If you keep it between freezing and about 100°F, it will keep time within two parts per million, which is about a minute per year. It accomplishes this by monitoring its own temperature (a major cause of oscillator drift) and switching capacitors in and out of the crystal oscillator circuit to trim the frequency. The crystal itself is on-chip which also helps accuracy. A very sweet piece of engineering. In addition to the date and time, we can also read the temperature from it (in °C to the nearest quarter degree).
Last we have the XBee module, which uses the ZigBee specification, based on the IEEE 802.15.4 standard. These modules are low power and don't offer terribly high bandwidth, which is just fine for sensor networks which tend to send very small amounts of data at any one time. The really neat thing is that XBee modules form themselves (with just about zero help from you!) into self-healing mesh networks. They can be configured either as network coordinators, routers, or end devices. Every network must have exactly one coordinator. Routers can do anything an end device can, plus forward messages between devices. End devices cannot route traffic, and must do all their business through a parent node which is either a coordinator or a router. Additionally, end devices can sleep in a low-power mode which would be very good for battery-powered remote sensors. If an end device is sleeping, its parent node will store traffic for it. The XBee in my sensor module is configured as a router.
Now we come to what I call the "base" unit. This consists of an Arduino Uno, with an Ethernet shield added on top and connected to my internet router. Also we have an XBee module, configured as the network coordinator, and a seven-segment LED display.
![]() |
| Base unit. Arduino and Ethernet shield at top. XBee, status LEDs, temperature display on breadboard. |
The whole thing works like this. Once a minute, the sensor unit sends the temperature and light intensity data to the base unit. The base unit sends the data to Pachube (click here to go to the Pachube feed for this project) and displays the temperature on the LED display. We can then download the data from Pachube, or have it create charts like below. These are live charts and will refresh every few minutes (not sure how often exactly, haven't found the spec on Pachube yet). So if you refresh this page, you will see current data, assuming that a cat hasn't chewed through any wires on my end in the meantime.

&l=Arbitrary+units+(0-1023+from+A/D+converter)&s=4&r=2)
DS18B20 Temperature Sensor
It would be straightforward to add additional sensor units to this project. One idea I have in mind is to measure the temperature of my wood stove with a thermocouple. Maybe send a text message to my mobile phone if it got over a certain temperature.
Subscribe to:
Posts (Atom)





