DHT22 with mini breadboard

DHT22 + Arduino Nano + Ciseco XRF

Here we will combine an Arduino Nano, a DHT22 and a Ciseco XRF to deliver LLAP (or the Language of the Internet of Things) via Radio (868 MHz).

Ciseco XRF
Ciseco XRF

The Ciseco XRF is a wireless node. It is low powered  and XBee shaped and has a RF serial data module. Operates in the ISM bands (868 to 915 MHz). It can be programmed over the air with a SRF – USB Stick or a Voyager+, as well as directly to the board’s serial or SPI pins with an FTDI breakout board.

The DHT22 is an inexpensive temperature and humidity sensor which can measure, depending on supplier between -50 (-40) and +50 (+125) °C and humidity 0-100%RH. It takes 3.3 – 4V input and delivers output as a digital signal via single-bus.

DHT22
DHT22 1.) VCC 2.) Data 3.) Not used 4.) Ground

It is therefore ideally suitable to measure temperature with an Arduino type board.

The Arduino Nano is a small, complete, and breadboard-friendly board based on the ATmega328 (Arduino Nano 3.x). It has more or less the same functionality of the Arduino Duemilanove, but in a different package. It lacks only a DC power jack, and works with a Mini-B USB cable instead of a standard one. The Nano was designed and is being produced by Gravitech.

Arduino Nano om Breadboard
Arduino Nano om Breadboard

To pick up the radio signals we will use the SRF-Stick with a 8.2 cm whip Antenna. To equip the whip antenna one needs to melt a channel into the plastic housing.

SRF stick with 82mm Whip Antenna
Ciseco’s SRF stick with 82mm Whip Antenna

The access point where the whip antenna is soldered into is explained in this picture.  The linked web page also explains where to add the whip antenna on the SRF shield.

List of Hardware:
XRF
Arduino Nano
DHT22
XRF Mini Module (optional for ease of use of the XRF)
1 or 2 Breadboards
Connector Cables
10 kOhm Resistor
Female Pin Headers
2 x 82mm cable for Whip Antenna
Solder Iron and equipment of your choice
Mini USB cable

For the DHT22 setup, we now connect the cables as follows.We have to recreate this with our breadboard or breadboards.

DHT22 + XRF + Arduino Nano
DHT22 + XRF + Arduino Nano

With a mini breadboard we connect the Arduino Nano as follows.

DHT22 on mini Breadboard connecting to an Arduino Nano
DHT22 on mini Breadboard connecting to an Arduino Nano

We need to now XRF to the Nano. Here we use TX(XRF)to TX(Nano) and RX(XRF) to RX(Nano). It is often the other way round with many devices as what the sender sends the receiver receives and vice versa, but with my XRF it worked this way. Then we connect the XRF Pin 1 to the 3.3V of the Nano and Pin 10 to another GND on the Nano.

XRF Pinout on Ciseco
XRF Pinout on Ciseco

The factory setting on the XRF is as such that all data received will automatically be send. It is that simple.

Once we have connected all parts, we hook up the SRF stick to a PC (Linux, Mac or Windows) and load the Arduino Software.

Software List:
Arduino Software
AdaFruit DHT Library
Ciseco’s LLAP Library

Download the libraries and add them to Arduino. From version 1.6.2 this can be done in the menu. The process is explained here. Then select the Arduino Nano Board and the correct COM Port for your setup. The Com (Serial) Port your SRF Stick is connected to.

Once this is done add the following Code in to your Arduino Document: (unlike in other setups, we are not talking directly to the radio and therefore do not need the radio code, it as such commented out)

//////////////////////////////////////////////////////////////////////////
// LLAP temperature and humidity sensor using a DHT22
//
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
//
// will work with any Arduino compatible however the target boards are the 
// Ciseco XinoRF and RFu-328, for LLAP over radio
// 
//
// Uses the Ciseco LLAPSerial library
// Uses the Adafruit DHT library https://github.com/adafruit/DHT-sensor-library
//////////////////////////////////////////////////////////////////////////

#include <LLAPSerial.h>
#include <DHT.h>
//#include <SoftwareSerial.h>

#define DEVICEID "DD" // this is the LLAP device ID

#define DHTPIN 5 // what I/O the DHT-22 data pin is connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)

// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(DHTPIN, DHTTYPE);

void setup() {
 Serial.begin(115200);
 //pinMode(8,OUTPUT); // switch on the radio
 //digitalWrite(8,HIGH);
 //pinMode(4,OUTPUT); // switch on the radio
 //digitalWrite(4,LOW); // ensure the radio is not sleeping
 delay(1000); // allow the radio to startup
 LLAP.init(DEVICEID);

 dht.begin();

 LLAP.sendMessage(F("STARTED"));

}

void loop() {
 // print the string when a newline arrives:
 if (LLAP.bMsgReceived) {
 Serial.print(F("msg:"));
 Serial.println(LLAP.sMessage); 
 LLAP.bMsgReceived = false; // if we do not clear the message flag then message processing will be blocked
 }

 // every 30 seconds
 static unsigned long lastTime = millis();
 if (millis() - lastTime >= 30000)
 {
 lastTime = millis();
 float h = dht.readHumidity()*10;
 float t = dht.readTemperature()*10;
 // check if returns are valid, if they are NaN (not a number) then something went wrong!
 if (isnan(t) || isnan(h)) {
 LLAP.sendMessage(F("ERROR"));
 //Serial.print("Error");
 } else {
 LLAP.sendIntWithDP("HUM",h,1);
 //String hummi = String(h);
 //Serial.print("aDDHUM"+hummi+"--");
 delay(100);
 LLAP.sendIntWithDP("TMP",t,1);
 //String temmi = String(t);
 //Serial.print("aDDTMP"+temmi+"--");
 }
 }
}

After the code is uploaded, the Arduino and the XRF will start sending out LLAP (The Language of Things) messages .

LLAP messages
LLAP messages from a DHT22 a DHT11 from different Ciseco devices

LLAP is an attempt to send out clear messages to devices and interfaces to be picked up by code.
a is an identifier for a start of a message
DG DF DH are device identifiers. With above code your device will identify as DF
TMP HUM
identify the type of message (Temperature and Humidity)
numbers show the value of the type of message
— The dashes are filler to always send the same length of messages.

aDFHUM89.2– therefore tells us, we received a message from device DF about the humidity and that the value of said humidity is 89.2%.

To receive such messages from SRF (radio) equipped devices we need also a receiver. We chose the SRF stick. We could also use the Voyager+.

Plug in the SRF stick into a USB port and on Linux and Mac you do not have to get a driver. On my Windows 7, I also needed no driver. Open up Serial Software like Serial Tools on Mac or REALTERM, CoolTerm or simply the serial monitor in the Arduino software. If all went well you should see the XINO RF now sending out message like above.

After we have a data sender and a receiver we can go creative and create our own software from what we pick up on the serial port.

An example is here in XCODE for my own home data collection.

Xcode 7 Xino RF
XCODE 7 Wireless Reader using different devices

One can also use a DHT11,

DHT11
DHT11

which is a lower cost and a lower performing  device of similar nature as the DHT22. If it supplied with a chip as above make sure it’s input’s are matched. I had to rotate mine 180 degrees.

If the DHT11 looks like this,

DHT11
DHT11

one can assume the same polarities as in above DHT22. Nevertheless I have a 3 pin DHT11 on a breakout board. Here the DHT11 faces away from the cables.

SRF shield with DHT11
SRF shield with DHT11

Make sure you define DHT11 in above Arduino sketch


#define DHTTYPE DHT11 // DHT&amp;amp;nbsp;11

I also used a 10 kOhm Resistor with the DHT11.