Temperature and Humidity on SainSmart LCD

SainSmart LCD Keypad Shield for Arduino with Franzis Duemilanove Clone, DHT22 and Wireless Things XRF

The task is to use  an old Franzis Duemilanove Clone, a DHT22 and a Ciseco XRF to deliver LLAP (or the Language of the Internet of Things) via Radio (868 MHz) and to display Temperature and Humidity on the LCD.

The old Franzis Arduino Duemilanove came from one of their first starter learning kits. These kits were also sold in the UK at Maplin stores.

The Arduino Duemilanove (“2009”) was a microcontroller board based on the ATmega168 or ATmega328. It had a 14 digital input/output pins , 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button.

Franzis Duemilanove Clone
Franzis Duemilanove Clone

The SainSmart LCD Keypad Shield for Arduino can be bought at Amazon.co.uk and fits the Arduino Uno, Mega 2560 and the Duemilanove.

The SainSmart LCD Keypad shield for Arduino includes a 16×2 HD44780 LCD module and a 5 push button keypad for menu selection and user interface programming.

SainSmart LCD Keypad Shield
SainSmart LCD Keypad Shield

There are some tutorials on SainsSmart’s webpages.

We will use it to simply display the temperature of a DHT22.

How to set up the DHT22 Temperature and Humidity sensor is described in several articles on this site.

DHT22 with mini breadboard
DHT22 with mini breadboard
DHT22 installation
DHT22 installation

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.

Ciseco XRF
Ciseco XRF

List of Hardware:
XRF
Arduino Uno or  Mega 2560 or Duemilanove.
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

We simply plug in the LCD shield into our Arduino board. Before you might want to solder 3 female pin headers to the LCD shield.

SainsSmart LCD shield on Arduino
SainsSmart LCD shield on Arduino
SainsSmart LCD shield on Arduino
SainsSmart LCD shield on Arduino

We now attach our DHT22 to the LCD Shield. Connect power to 5V on the LCD Shield, and GND to GND of the DHT22 to one of the 2 GND pins on the LCD shield. Now connect data on the DHT to pin 11 on the LCD shield. D11 is the 3 pin from the left on J2. See this schematic from SainsMart. This is the jumper field besides the lettering “LCD Keypad shield” on the shield.

 

XRF Pinout
XRF Pinout
rx tx on arduino
rx tx on arduino

Attach the XRF to theXRF Mini Module .

Now we connect the TX (xrf) to RX of the shield, RX (XRF)  to TX of the shield (J2) which is a pass through of the Arduino below.

Then connect pin 1 on the XRF (v3.3) to v3.3 on the shield and ground of the XRF to the remaining GND on the shield.

Above picture should just demonstrate where RX TX is on the Arduino, ignore the connections. Use the XRF pinout to find the right connections on the XRF.

When everything is set up play the following code with a USB cable on the Arduino, using the correct port, in this case using board Duemilanova and and as the processor atmega168. Depending on your Arduino, your mileage may differ.

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

//////////////////////////////////////////////////////////////////////////
// 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 <LiquidCrystal.h>
#include <DFR_Key.h>
//Pin assignments for SainSmart LCD Keypad Shield
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
//---------------------------------------------

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

#define DHTPIN 11
// 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);
DFR_Key keypad;
int localKey = 0;
String keyString = "";
String hummi = "";
String temmi = "";


void setup() {
  Serial.begin(115200);
  delay(1000);				// allow the radio to startup
  LLAP.init(DEVICEID);
  dht.begin();
  LLAP.sendMessage(F("STARTED"));
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Temp/Hum Display");
  delay(2500);
}
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;
    temmi = String(t / 10);
    hummi = String(h / 10);
    // check if returns are valid, if they are NaN (not a number) then something went wrong!
    if (isnan(t) || isnan(h)) {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("there is an:");
      lcd.setCursor(0, 1);
      lcd.print("Error");
      LLAP.sendMessage(F("ERROR"));
    } else {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Temp:" + temmi + "\337C");
      lcd.setCursor(0, 1);
      lcd.print("Humi:" + hummi + "%");
      LLAP.sendIntWithDP("HUM", h, 1);
      delay(100);
      LLAP.sendIntWithDP("TMP", t, 1);
    }
  }
}

When you power up this setup the LCD will display temperature and humidity.

Temperature and Humidity on SainSmart LCD
Temperature and Humidity on SainSmart LCD
Temperature and Humidity on SainSmart LCD
Temperature and Humidity on SainSmart LCD

Your full setup might look like this

LCD Shield
XRF Duemilanove DHT22 LCD Shield

xrflcddmn

 

With a SRF stick (described here),

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

or a Voyager+  you can then pick up also the over the air send LLAP messages on another computer.

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