The first project I backed on Kickstarter was delivered some time back but I’ve only recently gotten around to trying to do something with it.

I have a bunch of JeeNodes from JeeLabs and wanted to use them as a starting point so read a few articles about getting the RFM12B on the EVE talking to the Raspberry Pi. They suggest bridging CE1 to SS RFM12 and bridging G21/G27 to the third pin of the chip which appears to be FSK/DATA/nFFS (according to the data sheets I’ve seen)- oh and don’t forget to add an antenna!

I then found some code suggested to be working on the older v1 raspi with an RFM01 chip fitted rather than the RFM12B I have: http://www.susa.net/wordpress/2012/08/raspberry-pi-reading-wh1081-weather-sensors-using-an-rfm01-and-rfm12b/

Another site gave some pointers around modifying the code for the v2 raspi: http://amcc.me.uk/2013/01/eve-alpha-collects-weather-data/

The setup seems to work very well with either revision (1 or 2) of the Raspberry Pi though a couple of additional lines of code in wh1080_rf.c need to be tweaked to suit revision 2:

// RPi (Rev1) Init GPIO21 (on pin 13) as input (DATA), GPIO22 (pin 15) as output (nRES)
*(gpio.addr + 2) = (*(gpio.addr + 2) & 0xfffffe07)|(0x001 << 6);
Becomes:
// RPi (Rev2) Init GPIO27 (on pin 13) as input (DATA)
*(gpio.addr + 2) = (*(gpio.addr + 2) & 0xff1fffff)|(0x001 << 6)
And:
// RPi (Rev1) - GPIO21
status = ((*(gpio.addr + 13)) >> 21) & 1;
Becomes:
// RPi (Rev2) GPIO27
status = ((*(gpio.addr + 13)) >> 27) & 1;

I then went on to comment the RFM01 definition in rfm01.h and uncomment the RFM12B definition:

//#define RFM01
#define RFM12B

I also added the following definitions for the RFM12B as without them the code wouldn’t compile:

#define LNA_20 (3 << 4)
#define LNA_14 (1 << 4)
#define LNA_6 (2 << 4)
#define LNA_0 (0 << 4)
#define LNA_XX (3 << 4)

Remove this line from wh1080_rf.h:

#define USE_BMP085

Then onto the main wh1080_rf.c starting with updating to the correct spi port:

static const char *device = "/dev/spidev0.1";

I then used http://tools.jeelabs.org/rfm12b to get all the hex values to update the following lines:

uint16_t cmd_drate = 0xC606;
uint16_t cmd_freq = 0xA640;
uint16_t cmd_config= 0x80e7;
uint16_t cmd_power= 0x82dd;
uint16_t cmd_sync= 0xced4;
uint16_t cmd_afc= 0xc483;
uint16_t cmd_dcycle = 0xc800;
uint16_t cmd_pll= 0xcc57;
uint16_t cmd_fifo= 0xca83;
uint16_t cmd_dfilter = 0xc2ac;

Now when I:

make clean
make
sudo ./wh1080_rf

Initialising RFM12b
SPI: mode 0, 8-bit, 1000 KHz
Ctrl+C to exit
LNA_0,RSSI_73 idx 0 0.00 0.00 0.00 0.00 0.00 0.00
LNA_0,RSSI_79 idx 1 0.00 0.00 0.00 0.00 0.00 0.00
LNA_0,RSSI_85 idx 2 0.00 0.00 0.00 0.00 0.00 0.00
LNA_0,RSSI_91 idx 3 0.00 0.00 0.00 0.00 0.00 0.00
LNA_0,RSSI_97 idx 4 0.00 0.00 0.00 0.00 0.00 0.00
LNA_0,RSSI_103 idx 5 4.21 5.32 4.17 3.26 4.21 5.26
LNA_6,RSSI_73 idx 6 0.00 0.00 0.00 0.00 0.00 0.00
LNA_6,RSSI_79 idx 7 0.00 0.00 0.00 0.00 0.00 0.00
LNA_6,RSSI_85 idx 8 0.00 0.00 0.00 0.00 0.00 0.00
LNA_6,RSSI_91 idx 9 0.00 0.00 0.00 0.00 0.00 0.00
LNA_6,RSSI_97 idx 10 0.00 0.00 0.00 0.00 0.00 0.00
LNA_6,RSSI_103 idx 11 4.21 6.32 5.21 4.26 5.38 4.26
LNA_14,RSSI_73 idx 12 0.00 0.00 0.00 0.00 0.00 0.00
LNA_14,RSSI_79 idx 13 0.00 0.00 0.00 0.00 0.00 0.00
LNA_14,RSSI_85 idx 14 0.00 0.00 0.00 0.00 0.00 0.00
LNA_14,RSSI_91 idx 15 0.00 0.00 0.00 0.00 0.00 0.00
LNA_14,RSSI_97 idx 16 0.00 0.00 0.00 0.00 0.00 0.00
LNA_14,RSSI_103 idx 17 5.26 5.26 4.21 5.21 5.26 4.35
LNA_20,RSSI_73 idx 18 0.00 0.00 0.00 0.00 0.00 0.00
LNA_20,RSSI_79 idx 19 0.00 0.00 0.00 0.00 0.00 0.00
LNA_20,RSSI_85 idx 20 0.00 0.00 0.00 0.00 0.00 0.00
LNA_20,RSSI_91 idx 21 0.00 0.00 0.00 0.00 0.00 0.00
LNA_20,RSSI_97 idx 22 0.00 0.00 0.00 0.00 0.00 0.00
LNA_20,RSSI_103 idx 23 4.30 5.26 4.21 5.26 5.26 4.35
RSSI Duty 0.32

.

So the “interference” I can see suggests that something is hopefully working! I’m still playing around in an attempt to work out what I still need to tweak.

L

About these ads