DHT 22 and SRF Shield – Wireless Transceiver for all Arduino Type Boards

DHT 22 and SRF Shield – Wireless Transceiver for all Arduino Type Boards

The SRF shield is a digital electronics development board. It’s a plug and play add-on for all Arduino style prototyping boards with Ciseco‘s  SRF wireless module. Essentially it adds radio capabilities to the Arduino Uno Rev 3 board.
SRF Shield

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.

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:
SRF Shield
Arduino style board.
USB Cable with a the connector of your Arduino board
DHT22
Breadboard
Connector Cables
10 kOhm Resistor
2 x 82mm cable for Whip Antenna
Solder Iron and equipment of your choice

SRF Shield DHT22
Ciseco SRF Shield with DHT22

We now connect the cables as follows. While we show the XINO RF (no SRF shield in Fritzing) in below picture, you can use the same connections on the SRF Shield, which pass through to your Arduino board.

Sketch Xino RF with DHT22
Sketch Xino RF with DHT22

 

DHT22 with mini breadboard
DHT22 with mini breadboard and a Nano. Use the same pins on the SRF-Shield

Once we have connected all parts, we hook up the Arduino with SRF-shield 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 Uno Board and the correct COM Port for your setup. The Com (Serial) Port your SRF shield and Arduino is connected to,

Arduino Board and Com Port
Arduino Choose Board and Com Port

Once this is done add the following Code in to your Arduino Document:

//////////////////////////////////////////////////////////////////////////
// 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>

#define DEVICEID "DF" // 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();
 int h = dht.readHumidity() * 10;
 int 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"));
 } else {
 LLAP.sendIntWithDP("HUM",h,1);
 //delay(100);
 LLAP.sendIntWithDP("TMP",t,1);
 }
 }
}

After the code is uploaded, the SRF-Shield will start sending out LLAP (The Language of Things) .

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 11

I also used a 10 kOhm Resistor with the DHT11.