Jeenode wireless temperature sensor

On February 5, 2012, in arduino, Technology, by steve

Well, after much fiddling, I now have a single Jeenode temperature sensor node broadcasting temperature readings to another Jeenode which displays the readings on its serial port.

You’ll see there is space in the data packet for sending all four Jeenode port values and its battery level (to be worked out later).

Next step is to work on optimising the power usage of the sensor node.

The config is a Jeenode SMD with a Sparkfun TMP102 board attached to Port 1 on the Jeenode.

The sensor node code (Jeenode_temperature_sensor_tmp102_rf102b_v1_2) is:

#include <JeeLib.h>
#include <Ports.h>

//    TMP102 on Jeenode port 1
//      SDA to DIO
//      SCL to AIO
int tmp102Address = 0x48;  // ADD0 to ground on TMP102
PortI2C   myport(1, PortI2C::KHZ100);
DeviceI2C temperature(myport, tmp102Address); 

// RF stuff
#define RF_NODEID 5
#define RF_CHANNEL 111

// this must be added since we're using the watchdog for low-power waiting
// ISR(WDT_vect) { Sleepy::watchdogEvent(); }

// number of millisecs to powerdown and sleep for between reading and sending reading
#define DELAY 30000

//data Structure to be sent, called payload

typedef struct {
      	  int            nodeid;		// sending node ID
          unsigned  long uptime;               // time since node boot
          float          battery;               // Jeenode battery level       
	  float          data_1;
          float          data_2;
          float          data_3;
          float          data_4;
} Payload;
Payload data;

 
void setup() {
  rf12_initialize(RF_NODEID, RF12_868MHZ, RF_CHANNEL);
  Serial.begin(57600);
  Serial.println("Initalising...");
  data.nodeid = RF_NODEID;
}  
  

void loop() {
  while (!rf12_canSend())
    rf12_recvDone();
  
  data.data_1 = getTemperature();
  data.uptime = millis();
  
  Serial.print(data.uptime/1000.0);
  Serial.print("\t");
  Serial.println(data.data_1);
    
  rf12_sendStart(0, &data, sizeof data);
  // rf12_sendWait(2);

  delay(DELAY);
//  rf12_sleep(RF12_SLEEP);
//  Sleepy::loseSomeTime(DELAY);
//  rf12_sleep(RF12_WAKEUP);
}

// Function to get temperature from TMP102 and return it as a float in Celsius
float getTemperature()
{   
  temperature.send();             // go into send mode
  temperature.write(0x00);        //
  temperature.receive();          // grab it
  byte MSB = temperature.read(0); // Whole degrees
  byte LSB = temperature.read(1); // fractional degrees
  temperature.stop();             // done

  int TemperatureSum = ((MSB << 8) | LSB) >> 4; //it's a 12bit int, using two's compliment for negative
  float celsius = TemperatureSum*0.0625;
  
  // Serial.print(MSB,BIN);
  // Serial.print(" ");
  // Serial.print(LSB,BIN);
  // Serial.print("\t");
  // Serial.print(TemperatureSum, BIN);
  // Serial.print("\t");
  // Serial.print(celsius);
  // Serial.println();
  
  return celsius;
}

The receiving node code (Jeenode_temperature_receiver_tmp102_rf102b_v1_2) is:

#include <JeeLib.h>

// RF stuff
#define RF_NODEID 1
#define RF_CHANNEL 111

#define BLUE_LED 9

// this must be added since we're using the watchdog for low-power waiting
// ISR(WDT_vect) { Sleepy::watchdogEvent(); }

// number of millisecs to powerdown and sleep for between reading and sending reading
#define DELAY 5000
// receive buffer size
#define BUFFER_SIZE 64

// Payload data structure
typedef struct {
      	  int            nodeid;		// sending node ID
          unsigned  long uptime;                // time since node boot      
          float          battery;               // Jeenode battery level       
	  float          data_1;
          float          data_2;
          float          data_3;
          float          data_4;
} Payload;
Payload data;

 
void setup() {
  rf12_initialize(RF_NODEID, RF12_868MHZ, RF_CHANNEL);
  
  pinMode(BLUE_LED, OUTPUT);
  digitalWrite(BLUE_LED, HIGH);        //off  

  Serial.begin(57600);
  Serial.println("Initalising...");
  // flash the LED to signify booting
  digitalWrite(BLUE_LED, LOW);
  delay(100);
  digitalWrite(BLUE_LED, HIGH);
  delay(150);
  digitalWrite(BLUE_LED, LOW);
  delay(200);
  digitalWrite(BLUE_LED, HIGH);
}  
  

void loop() {
  if (rf12_recvDone()) {
    if (rf12_crc == 0) {
      Serial.print(millis()/1000.0);
      Serial.print("\t");
      Serial.print(rf12_hdr, BIN);
      Serial.print("\t");
      Serial.print(rf12_len);
      Serial.print("\t");
      
      data=*(Payload*) rf12_data;
      Serial.print(data.nodeid);
      Serial.print("\t");
      Serial.print(data.uptime/1000.0);
      Serial.print("\t");
      Serial.print(data.data_1);
      Serial.println();
      
      // quick double flash on receipt of packet
      digitalWrite(BLUE_LED, LOW);
      delay(75);
      digitalWrite(BLUE_LED, HIGH);
      delay(75);
      digitalWrite(BLUE_LED, LOW);
      delay(75);
      digitalWrite(BLUE_LED, HIGH);
    } 
  }
}
Tagged with:  

Games – Nightfighter 4, 5 & 6

On February 3, 2012, in Games, by steve

Paul and played three games of Nightfighter this afternoon.

Scenario 2A Lash Up X 2
Blenheim intercepting three HE111H. The Germans won both times, although Paul managed to inflict one point of damage on one plane. I flailed around and failed to locate any planes when it was my turn to be the Germans!

Scenario 2D Rabaul
I took the Japanese with one fighter and a very insensitive radar. I managed to fire once at a B-17 just before it moved off the board and then failed (again) to locate the remaining bomber. After the scenario, it turned out I’d actually located the bomber and pointed at the correct hex, then lost it again. Grrrr….

Tagged with:  

Arduino temperature anomalies

On January 16, 2012, in arduino, by steve

I’ve seen a couple of temperature anomalies with my external temperature probe the last couple of days.

20120116-085048.jpg

If I zoom in, this is what I see each morning at the same time.

20120116-085155.jpg

20120116-085142.jpg

I think I know what is going on here. I think the temperature spike is caused by direct sunlight on the sensor after the sun clears the house across the road and before the sensor moves into shadow for the rest of the day….

Tagged with:  

Game – Elusive Victory 4

On November 11, 2011, in Games, by steve

Paul and I played Elusive Victory again this afternoon – scenario EV(C3I#4) High Fast Flyer from C3I #23 which we’ve both wanted to try for a while.

Paul took the Egyptians with a record Foxbat and I took the Israel with two pairs of Phantom with BVR missiles.

The Foxbat took off for Cairo west and immediately climbed to very high altitude, headed North towards over the Nile Delta then turned towards the exit area over the eastern Sinai where the Phantoms were on CAP.

Given the Foxbat’s altitude and speed, I knew my only chance was a BVR sparrow shot and that each pair of Phantoms would only likely get one chance each. Also there was no point in trying to cross the Suez to get an early shot because of Egyptian SA-2 defences – which I avoided all game.

I was able to position flight of Phantoms for a shot at extreme head to head range but they missed. The next turn I got the initiative and same flight was able to close and take another head on shot – it hit and crippled the Foxbat.

The Foxbat dropped out of after afterburner and was now a sitting duck for the other Phantom flight which finished it off with another pair of Sparrows.

Tagged with:  

Games – Nightfighter 2 & 3

On September 2, 2011, in Games, by steve

Paul and I played scenario 8 “Steinbock” from GMT’s Nightfighter. The scenario involved the player, with a No. 29 Squadron, RAF. The defender Mosquito NF.XIII trying to intercept five He177A Greif bombers from I/KG 40.

We played it twice with Paul losing the first game as a defender (RAF) and me winning the second game as the RAF.

In the first game, Paul very quickly fixed the first bomber, closed on it and despite the poor visibility shot it down. Unfortunately his crew was blinded by the flash and carried on in a straight line off the map. Game over.

In the second game I was able to use the GCI radar to find his planes, shooting down three of them and damaging one which managed to escape of the map edge. A full moon illuminating the cloud cover certainly helped!

Tagged with:  

Game – Tide of Iron

On August 29, 2011, in Games, by steve

Andy and I played a game of Tide of Iron this evening. It was the first time that either of had played it. Interesting game – sort of Memoir ’44 on steroids crossed with a very simplified ASL. Needless to say Andy won!

Tagged with:  

Interpol

On August 24, 2011, in Family, by steve

Julie and went to see Interpol at Aberdeen’s Music Hall tonight. I’d been really looking forward to it, but unfortunately the concert was just far too loud. I’ve been to loud concerts before, but nothing like this. It was so loud the music was unrecognisable and just painful to try to listen to.

A great disappointment – I must be getting old!

  • Success
  • Say Hello To The Angels
  • Narc
  • Hands Away
  • C’mere
  • Rest My Chemistry
  • Mammoth
  • The New
  • Evil
  • Lights
  • The Heinrich Maneuver
  • Length of Love
  • Memory Serves
  • Slow Hands
  • Not Even Jail
  • NYC
  • Take You On A Cruise
  • Obstacle 1
Tagged with:  

Death Cab for Cutie

On July 5, 2011, in Family, by steve

Just back from seeing Death Cab for Cutie at Rock City with Rob Wix. Very good. If they are in my area again, I’d go and see them in a second.

  • Bend to Squares
  • The New Year
  • We Laugh Indoors
  • Crooked Teeth
  • Photobooth
  • Doors Unlocked and Open
  • Long Division
  • Grapevine Fires
  • Codes and Keys
  • What Sarah Said
  • I Will Follow You Into the Dark
  • I Will Possess Your Heart
  • You Are a Tourist
  • Underneath the Sycamore
  • Meet Me on the Equinox
  • Title and Registration
  • A Movie Script Ending
  • Soul Meets Body
  • Stay Young, Go Dancing
  • Cath…
  • The Sound of Settling
  • Encore:
  • Portable Television
  • Title Track
  • Expo ’86
  • Transatlanticism
Tagged with:  

Game – Labyrinth

On March 18, 2011, in Games, by steve

Paul and I played our first game of GMT Game’s Labrynth this afternoon. I took the West and took the terrorists. To be honest I had no idea what was going on for the first few turns but after invading Afghanistan and forming a pro-American government in Somalia it all started to make sense and I was able to move the game to a victory.

A very interesting and very asymmetrical game with the US trying to encourage stable governements around the Middle East and the terrorist player trying to create Islamic states and/or a major terrorist incident in the US.

Tagged with:  

Game – Twilight Struggle

On February 11, 2011, in Games, by steve

Paul and I played a game of Twilight Struggle this afternoon. I took the Soviets and won by victory points on the second card play of turn two – certainly the quickest game we’ve seen.

On turn one I drew the Europe scoring card and a hand of excellent Soviet cards; I was able to dominate Europe controlling all Battleground states except West Germany by the end of the turn when I played the scoring card. I rebuffed every attempt by Paul to. Lace influence in Europe.

I drew the Asia scoring card on turn two and an awful hand of US cards; played a 2 ops card to control of Afghanistan followed by the Asia card for a clear victory point win.

Excellent game and rather one sided!

Tagged with: