I’ve made my Pro Micro/Mini ISP breakout board and Raspberry Pi nRF24L01+ breakout board as per my previous post and decided to get on with trying out RF24Mesh. The problem there was that with the newer commits to RF24 and RF24Network, I was getting no response from the Arduino’s to the RPi.

After some debugging with the author of the libraries on GitHub, we managed to find the culprit – not really the clone issue or the differing module issue, but actually a bit of an oddity in how dynamic payloads and dynamic ACKs work together. So with the Development branch re-opened, we now have the modules talking again. It may need some more work to get mesh working though. So for now I’m sticking to RF24Network, not RF24Mesh.

I’ve migrated all of my various sensor modules to a more streamlined setup – essentially there’s a daemon listening on the Pi which directly populates the database now, rather than the previous separate cronjob. It also handles taking measurements from the DS18B20 sensor on the Pi breakout. The daemon also accepts TCP connections should I want to use an ESP8266 sensor, its also handy for debugging using netcat. Each module sends each sensor reading separately, so each RF24 transmission is under 16 bytes long, rather than pushing the 32 byte limit.

One of my new modules is a 3.3v 8MHz Pro Mini 328, from which I have removed the LED’s and regulator to drop the current use. I’ve also configured its fuses and boards.txt to run at 1MHz from the internal oscillator and set all unused digital pins to INPUT_PULLUP. Now its using under 4uA at sleep. The boards.txt entry looks like:

promini1mhz.name=Pro Mini 328 (1.8v, 1MHz internal osc, BOD off)

I then added the BH1750FVI light sensor to the circuit and found that the sleep current was the same as when it was awake taking readings, about 110-145uA, instead of 5uA the manufacturers claim. So I switched to using the BH1750FVI library as it had better sleep support. Alas that didn’t fix things and I decided the module simply wasn’t sleeping. After some reading of the datasheet and playing with code I finally figured out that after calling power_on and reset to wake the device from a power_down, you have to set the resolution mode again. I also found that disabling the pullup resistors on the I2C pins helps, as the module already has internal pullups. I’ve tested it down to 1.5v, which is quite far below any of the components ratings, but it works….

// include libraries
#include <Wire.h>
#include <BH1750FVI.h>
#include <RF24.h>
#include <RF24Network.h>
#include <SPI.h>
#include <LowPower.h>

// global vars
BH1750FVI lightMeter;

// init network ce,csn
RF24 radio(9,10);
RF24Network network(radio);
const uint16_t this_node = 4;
const uint16_t other_node = 0;

void gotoSleep()
    // sleep radio

    // sleep mcu for 225x8/60=30mins
    for(int i=0; i<225; i++)
        LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);

    // wake radio and sensor

void setup(void)
    // set unused digital pins to input pullups to save power
    const int unusedPins[] = {0,1,2,3,4,5,6,7,8,14,15,16,17};
    for (int i=0; i < 13; i++)
        pinMode(unusedPins[i], INPUT_PULLUP);

    // init sensor

    // disable pullups as sensor already has them
    pinMode(SDA, INPUT); // a4
    pinMode(SCL, INPUT); // a5

    // init radio
    network.begin(90, this_node);

void loop()
    // pump network

    // take a sensor reading, pad to 2dp
    long lux = lightMeter.GetLightIntensity() * 100;
    if (lux == 0)
        // take another reading, its not ready
        lux = lightMeter.GetLightIntensity() * 100;

    // create data structure - bh1750=type11
    char txBuffer[16] = "";

    // transmit
    RF24NetworkHeader header(other_node);

    // sleep

I finally got my hands on a Particle Photon. However I found a bug in the way it reports its error status to dfu-util, it flashes ok but says it hasn’t. The fix is in 0.4.5 but requires a bootloader ID upgrade, so it won’t be 100% fixed until 0.4.6, unless I get a JTAG programmer to set it in the meantime. Otherwise it seems to be more mature than the Spark Core – well they fixed most of the issues there before working on the HAL for the Photon I guess.

I’ve also started playing with an MRFC522 RFID reader/writer and some cards/keyrings – worrying how easy it is to clone those things! I’ve also got some HC-05 Bluetooth modules to play with next.

We’ve also made a few commits to arduino-mk this month.