Sketch Xino RF with DHT22

DHT 22 and Ciseco XinoRF – Arduino UNO R3 Based Development Board with Radio Transceiver

The XinoRF – Arduino UNO R3 Based Development Board with Radio Transceiver is a digital electronics development board. It’s a hybrid of the widely used Arduino UNO R3 and Ciseco‘s  SRF wireless module. Essentially it adds radio capabilities to the Arduino Uno Rev 3 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.

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.

List of Hardware:
Xino RF
USB Cable with a USB Mini-b (5-pin) connector.
DHT22
Breadboard
Connector Cables
10 kOhm Resistor
2 x 82mm cable for Whip Antenna
Solder Iron and equipment of your choice

Xino RF DHT22
Ciseco’s Xino RF with DHT 22

We now connect the cables as follows.

Sketch Xino RF with DHT22
Sketch Xino RF with DHT22

Once we have connected all parts, we hook up the XINO RF 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 XINO 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 XINO RF 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