DHT22 and RFu – 328/SRF and RFu Developer Kit

DHT22 and RFu – 328/SRF and RFu Developer Kit

RFu - 328/SRF Arduino compatible wireless node
RFu – 328/SRF Arduino compatible wireless node

The RFu – 328/SRF is an Arduino compatible wireless node.It’s equipped with a 16Mhz Atmel ATMega 328P preloaded with the Arduino Uno bootloader. It can be programmed over the air as well as directly to the board’s serial or SPI pins with an FTDI breakout board.

The RFu Devekoper kit is a moderately easy way to test and learn how to use the RFu 328.

RFu Developer Kit
RFu Developer Kit

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:
RFu – 328/SRF Arduino compatible wireless node
RFu Developer Kit
2 x 1.5V AA Battery Holder  with  wire leads
2 x 1.5 AA batteries
OR the supplied 1.5 to 3.3v step up PowerPod and 1 x 1.5 V AA
DHT22
Breadboard
Connector Cables
10 kOhm Resistor
Female Pin Headers
2 x 82mm cable for Whip Antenna
Solder Iron and equipment of your choice

We now connect the cables as follows. While we show the XINO RF (no RFu – 328/SRF in Fritzing) in below picture. We have to recreate this with the development board and the RFu – 328/SRF.

Sketch Xino RF with DHT22
Sketch Xino RF with DHT22
RFu - 328/SRF RFU Development board
RFu – 328/SRF RFU Development board with DHT22

First we have to construct the Development Board
It comes with the following components:

RFu Developer PCB Kit
Power Pod (1.5V to 3.3V DC) with 4 Pin Male Header
2 x AA Battery Clips (Battery Not Included!)
2 x 10 Pin Female Headers (2.54mm Pitch)
1 x 8 Pin Female Header (2.54mm Pitch)
1 x 4 Pin Female Header (2.54mm Pitch)
1 x 40 Point Mini Breadboard
1 x Push Button
1 x Red LED
1 x 470 Ohm Resistor
5 x Jumper Cables (Random length and colour)
0.1uf capacitor (104)
Some of these are optional or for different constructions. Be also warned that you might receive different pieces. I did not receive a capacitor or any pin headers besides the male one for the powerpod. It is good to have some of them in stock and a basic electronics set will keep you stocked on standard components.

You can take several ways to construct the development kit. I found no consistent explanation on Ciseco’s webpages.

My Route:
Solder the 2×1.5 battery holder, not supplied [see above] (and not the battery clips) to + and -.

plus minus
+ – on the Development board

Solder the 1 x 4 Pin Female Header

1 x 4 Pin Female Header
1 x 4 Pin Female Header

to the 4 soldering holes in the power pod area. The two holes to the left are for measuring.

power pod area
power pod area

Now solder the  1×8 Female pin header and a bought one (aka from Amazon) to the 3v3 GND area on the RFu Development board.

3.3 V and Ground area
3.3 V and Ground area

Them solder the 2 supplied 1×10 female pin headers to this area.

rfu328 area
RFu 328 contact area. USE the outer 10 hole lines!

Use the bigger 10 hole areas to the left and right. The smaller ones are the contact area for the RFu 328. The ones in the middle you can ignore.

You can also ignore the button switch, the led or the resistor, unless you want to test your setup with the Arduino Blink sketch or similar.

Now solder the (or a) 104 capacitor

104 Capacitor 0.1 uF
104 Capacitor 0.1 uF

into the two holes the arrow points to in below picture.

Two holes for a 104 capacitor
Two holes for a 104 capacitor

Now you are finished with the preparations.

You can insert now the RFu 328 into the smaller holes above the Ciseco letters making sure that PIN 1 is in the upper left corner.

I would advise soldering the whip antenna on the RFu beforehand. The capacitor will be slightly in the way. This seems to be normal.

Another setup from another site gives an impression of the setup without the construction on the breadboard.

Homelabs ORG setup

Alternative Route:
Alternatively you can clip the two supplied battery CLIPS

Battery Clip Install area
Battery Clip Install area

Careful you can select a size for AAA or AA batteries.

Then attach the power pod with the male pin headers.

END of Alternative Route.

Once you have all parts together, we now need to prepare OTAMP (Over the Air micro Programming).

For that we need the SRF stick.

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

Once you have the stick inserted open up a terminal program (Serial Tools on Mac or REALTERM, CoolTerm or simply the serial monitor in the Arduino software)

First we need to tell the SRF stick it should go into OTAMP mode.
Here you will use AT commands. Type in your serial tool

+++
ATRE
ATRP3
ATWR
ATAC
ATDN

IMPORTANT THERE IS NO Carriage return after +++ it will just say OK.

+++OK
ATRE
OK
ATRP3
OK
ATWR
OK
ATAC
OK
ATDN
OK

This document gives some information on what these commands mean.
+++   = activate AT mode
ATRE =Load Factory settings
ATRP3 = Enable remote programming (the document seems old and does not state option 3)
ATWR = Write changes to flash memory
ATAC = Apply Changes
ATDN = Exit AT mode

Now disconnect your serial tool (so the Arduino programmer can use the USB serial of the SRF stick) so you can start OTAMP.

Follow the setup higher in the document to connect the DHT22.
Connect power in to 3v3, and GND to this area.

3.3 V and Ground area
3.3 V and Ground area

The DHT data cable goes into pin 5
A schematic is found here:

Pins on RFu328
Pins on RFu328

You can now activate your RFu 328. Do this by connecting 3v3 to Vin in the power pod area with a female to femal or male to male lead whatever your setup.

power pod area
power pod area

Now all Arduino commands should go over the air. Select SRF stick as COM Port and the Arduino Uno board as below.

If all is well an upload will go a bit slower but normal. If you have problems it will say it can not find the programmer or there are sync problems. Sync problems can appear if you did not close your serial tool after the AT commands.

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 Uno Board and the correct COM Port for your setup. The Com (Serial) Port your SRF Stick 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 RFu328 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.