h1

JeeNodes

November 21, 2013
Front

Front

I’ve been working on a holiday present for my sister which is a temperature monitor for her greenhouse.  Originally I wanted to use  Xbee radios as I had tried them before and have Rob Faludi’s book Building Wireless Sensor Networks.

I recently discovered JeeNodes and decided to give them a try instead as I had found Xbee radios not the easiest to work with.  What you get for roughly $22 is a small Ardunio based on the Really Bare Bones Board with a radio.  Made by JeeLabs with an extensive library that can be found on Github.

Jeenodes couldn’t be easier to use.  They come pre-loaded with a send & receive sketch built in.

All you need to do is open a serial monitor and type in your node ID, radio setup  and a group ID.
Plug in your second radio and type in the same setup except for a different node ID and you are good to go!

Here I am making a greenhouse monitor. One JeeNode and a tmp36 temperature sensor will be outside in the greenhouse.
For the indoor part I’m using an old cigar box outfitted with an LCD, A green, yellow & red led and a Jeenode.
The green led means everything is good and working. The yellow means a problem with the sensor, possibly the battery needs recharging. If the red led comes on, then you need to turn the heat on in the greenhouse. The different statuses will also be reflected on the LCD screen.

I still need to paint the box and do a few more things before I am done.

Update 11/23

Transmitter

// http://jeelabs.net/
//http://opensource.org/licenses/mit-license.php
//11/21/13 Todd Miller GreenhouseTX6

#include <JeeLib.h>
#include <avr/sleep.h>
Port tmp (2);
int value;
MilliTimer readoutTimer, aliveTimer;

void setup() {
tmp.mode2(INPUT);
rf12_initialize(‘T’, RF12_433MHZ, 100);
rf12_easyInit(5); // every 5 seconds send out pkg
Serial.begin(57600);
Serial.println(F(“Initializing ACKTestTX1…”));
delay(45);//wait for power to settle
}

void loop() {
set_sleep_mode(SLEEP_MODE_IDLE);
sleep_mode();
rf12_easyPoll();
value = tmp.anaRead();
calcTemp();
rf12_easySend(&value, sizeof value);
Serial.print(F(“Header = “));
Serial.print((int) rf12_hdr);
Serial.print(F(” Temp: “));
Serial.print(value);
Serial.println(F(” F”));

if (aliveTimer.poll(60000)){
rf12_easySend(0, 0);
Serial.println(F(“Sending ‘Alive’ Message”));
}
}

void calcTemp(){
for (int i=0; i <= 2; i++){
value = value + tmp.anaRead();
delay(2);
}
value = (value/4);
float voltage = value * 3.3;
voltage /= 1024.0;
float temperatureC = (voltage – 0.5) * 100 ;
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
value2=temperatureF;
}

———————————————————

Receiver

// http://jeelabs.net/
// http://opensource.org/licenses/mit-license.php
// digiRead() & digiWrite() – ports D pin
// anaRead() & digiWrite2() – Ports A pin
// mode sets Digital pin mode2 sets ports Analog pin
// 11/21/13 Todd Miller GreenhouseRX6

#include <JeeLib.h>
#include <PortsLCD.h>
Port ledOne (1);
Port ledTwo (2);
Port ledThree (3);
PortI2C myI2C (4);
LiquidCrystalI2C lcd (myI2C);
int temp;
int pkg;
int data;
byte y =0;
byte r = 0;
byte threshold= 34;
int backlightSwitch;

unsigned long interval = 30000;
unsigned long previousMillis;

void setup () {
lcd.begin(20, 4);
homeScreen();
ledOne.mode(OUTPUT);
ledTwo.mode(INPUT); // digital pin for backlight switch
ledTwo.mode2(OUTPUT); // analog pin for led
ledThree.mode(OUTPUT);
Serial.begin(57600);
rf12_initialize(‘R’, RF12_433MHZ, 100);
ledOne.digiWrite(1);
ledTwo.digiWrite(1);
ledTwo.digiWrite2(0);
ledThree.digiWrite(0);
}

void loop () {
unsigned long currentMillis = millis();
backlightSwitch=ledTwo.digiRead();
if (backlightSwitch == LOW)
lcd.noBacklight();
else
lcd.backlight();

if (currentMillis-previousMillis >interval)
yellowLed();

if (rf12_recvDone() && rf12_crc == 0) {
previousMillis=currentMillis;

pkg++;
if (pkg >= 999)
pkg=1;

int* data = (int*) rf12_data;

if(rf12_data[0]<=threshold)
{
redLed();
}
// process data here

else {
greenLed();
lcd.setCursor(5, 3);
lcd.print(”   “);
lcd.setCursor(5, 3);
lcd.print(pkg);
lcd.setCursor(5, 2);
lcd.print(”    “);
lcd.setCursor(6, 2);
lcd.print(rf12_data[0]);
lcd.setCursor(14, 3);
lcd.print((int) rf12_hdr);
}

if (RF12_WANTS_ACK)
rf12_sendStart(RF12_ACK_REPLY,0,0);
}
}

void greenLed()
{
ledOne.digiWrite(1);
ledTwo.digiWrite2(0);
ledThree.digiWrite(0);

if (y==1 || r==1){
homeScreen();
y=0;
r=0;
}
}

void yellowLed()
{
ledOne.digiWrite(0);
ledTwo.digiWrite2(1);
ledThree.digiWrite(0);

if(y==0 || r==1)
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(F(“Check sensor!”));
lcd.setCursor(0, 1);
lcd.print(F(“Battery may need”));
lcd.setCursor(0, 2);
lcd.print(F(“recharging.”));
y=1;
r=0;

}

void redLed()
{
ledOne.digiWrite(0);
ledTwo.digiWrite2(0);
ledThree.digiWrite(1);

if(r==0 || y==1)
lcd.clear();

lcd.setCursor(0, 0);
lcd.print(F(“Check greenhouse!”));
lcd.setCursor(0, 1);
lcd.print(F(“Current Temp:”));
lcd.setCursor(14, 1);
lcd.print(rf12_data[0]);
lcd.setCursor(17, 1);
lcd.print(F(“F”));
r=1;
y=0;
}

void homeScreen()
{
lcd.clear();
lcd.print(F(“Snowdrift Farms”));
lcd.setCursor(0, 1);
lcd.print(F(“Greenhouse Monitor”));
lcd.setCursor(0, 2);
lcd.print(F(“Temp: “));
lcd.setCursor(0, 3);
lcd.print(F(“Pkgs: “));
lcd.setCursor(9, 3);
lcd.print(F(“From:”));
}

Update 12/29

Finally finished temperature monitor.  Here are the final photos.

You can see the Arduino code on Github here.

About these ads

3 comments

  1. I got a couple of these for a mailbox sensor, ran into a snag and then other things came up. Hope to finish one day soon. Are you going to post your code?


    • Let me see if I can get the code up this weekend. I need to clean it up a little first.


  2. My current code has been added. Check below photos.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: