Thursday, November 6, 2014

Weather Station part deaux

2) SOFTWARE

I am still working on the receiver part - but i think i have the outside part pretty much figured out.

My goals are


  • Interface with the Sparkfun Weather instruments
  • Use a battery and charger to keep it running as long as possible before replacing.  The well head i am using as a mounting base - is 80 or so feet from the back door. Plus i have alread tun over a previous setup's rain gauge cable - never want to do that again.
Interfacing with Sparkfun weather instrument.

I grabbed some code from here and hooked it up and tested it.  The code uses interrupts to get the values from the Anemometer and Rain Gage -  and relies on Millis() to calculate the values display.  It is a single source Solution - and uses the most power since the the Arduino runs at full power all the time.

Power Down sleep mode turns off all the clocks and counters on the chip.  I thought through many scenarios to try and figure a way to use other timing sources. One promising one is using a 32,767 watch crystal - but since i am using a pro-mini - getting to the pins was more than I wanted to deal with. Then I saw something on the forums and had a DUH moment - use the outside to gather the raw data - and do data processing on the receiver.


I used the RF24Network library and added these parts 

//nrf2l01 stuff
#include
#include
#include
#include "printf.h"
#include
#include
/*
  nc---n/c---8  7--miso--12  
  11-- mosi--6  5--sck---13 
  08-- csn---4  3--ce----09 
  ++-- Vcc---2  1--gnd---gnd

RF24 (cepin, cspin)
*/
#define CE_PIN 9
#define CS_PIN 8
RF24 radio(CE_PIN, CS_PIN);
RF24Network network(radio);

// Address of our node
const uint16_t this_node = 1;

// Address of the other node
const uint16_t other_node = 0;
/*

then  in setup added
... 
//nrf24l01 setups
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
...

to setup the structure of the packet to send

// Structure of our payload
struct payload_t
{
  float Temperature;//4 bytes
  double unitWind;//4 bytes
  double Gust; //4 bytes
  int WindVane;//2 bytes
  unsigned int UnitRain;//2 bytes
  unsigned long ms;//4 bytes
  long vcc;//4 bytes
  
};

The network header adds 8 bytes so I had to fiddle with the types to make it all fit in 32 bytes.