Saturday, October 11, 2014

RFduino / BLED112 / DS18B20 Temperature Demo

This is another simple temperature monitor.  It uses a DS18B20 sensor which is connected to the RFduino over a 1-Wire bus.  It also adds red and blue LEDs that supply status. 

The red LED blinks unless an error is detected at which time it turns on solid.  The blue LED turns on when a connection is made to the temperature monitor and blinks 5 times if a new temperature is detected.

Below is a mock up of the breadboard temperature monitor and a circuit diagram produced using the fritzing package.

TemperatureDS18B20Project_bb

TemperatureDS18B20Project_schem

If you don’t already have the OneWire library information on it can be found here on the Arduino site which directs you to Paul Stofffregen’s site.  To install download the zip file and then copy to your RFduino libraries directory.  On my system this directory is located at C:\Program Files (x86)\arduino-1.5.7\hardware\arduino\RFduino\libraries.  On your system this will be dependent on where your Arduino IDE with RFduino support is located.

The files for the DS18B20 demo are located here.  This demo uses the same windows program as the TMP007 demo which can be found here in the dhRFduino repository on GitHub.

The LEDs are controlled by setting that are located in the RFduinoBLE_onConnect and RFduinoBLE_onDisconnect routines.  These routines are called when a connection is established to the RFduino and when that connection is terminated.

RFduino / BLED112 / TMP007 Temperature Demo

I decided to build on the temperature example by adding an external sensor to the RFduino.  In keeping with the temperature theme I used a TMP007 temperature sensor from Adafruit.

To read the temperature from the TMP007 I used the TMP007 library from Adafruit. 

Remember when installing libraries to use with the RFduino you need to get them put in the right place in the Arduino tree.  On my system this directory is located at C:\Program Files (x86)\arduino-1.5.7\hardware\arduino\RFduino\libraries.  On your system this will be dependent on where your Arduino IDE with RFduino support is located.

The files for the TMP007 demo are here on GitHub in the dhRFduino repository.

The hardware setup for this demo is very simple.  The TMP007 and the RFduino are connected to power and ground and the SCL and SDA lines on the TMP007 are connected to SCL labeled GPIO5 and SDA labeled GPIO6 on the RFduino.

If this demo is run in DEBUG mode and the serial console is attached to the RFduino status messages will be logged when a connection is made to the RFduino, when the connection is disconnected, the temperature each time the sensor is red and when a new temperature value is detected.