Close

First Library Released

A project log for analog.io - A full stack IoT platform

A full stack project dedicated to easily collecting, analyzing and sharing IoT sensor data.

luke-benoLuke Beno 08/29/2015 at 14:251 Comment

A very quick update on this. I recently pushed the first release of the analog_io_lib to Github. With this library you are now able to simultaneously transmit Bluetooth Low Energy packets with nRF24 proprietary RF packets.

The interface is the same as the Serial.print API in Arduino so it is super simple to use. Check out the sample code:

Dual Mode Tx Example:

#include <analog_io.h>
#include <SPI.h>

uint8_t x = 0;
analog_io radio(P3_5, P3_6, P2_5); // CE, CSN, IRQ

const uint8_t txaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };

void setup()
{
  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  
  radio.begin();  // Defaults 1Mbps, channel 0, max TX power

  radio.setTXaddress((void*)txaddr);
}

void loop()
{
  // put your main code here, to run repeatedly:
  radio.print("TX #");
  radio.print(x);
  radio.flush();
  
  delay(250);
  
  radio.print("Beacon #");
  radio.print(x);
  radio.flushBle();
  x++;
  delay(250);
}

RF Receive Example:

#include <analog_io.h>
#include <SPI.h>

analog_io radio(P3_5, P3_6, P2_5); // CE, CSN, IRQ
const uint8_t rxaddr[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0x01 };

void setup() {
  Serial.begin(9600);

  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  
  radio.begin();  // Defaults 1Mbps, channel 0, max TX power

  radio.setRXaddress((void*)rxaddr);
  
  radio.enableRX();  // Start listening
}

void loop() {
  char inbuf[33];
 
  while (!radio.available(true))
    ;
  if (radio.read(inbuf)) {
    Serial.print("Received packet: ");
    Serial.println(inbuf);
  }
}

The library works both with Arduino+a nRF24 module or Energia and my MSP430 Sensor Node hardware. Check it out here:

https://github.com/analog-io/analog_io_lib

Also if you are using a MSP430 Sensor node, here is info on adding support for this hardware to Energia:

https://github.com/analog-io/iot_sensor_node

Discussions

macaroontje wrote 02/27/2016 at 21:59 point

This looks simple but good! I currently use nrf24network for my space heating automation (and temperature logging) which I want to replace by ESP2866 (in SONOFF power switches) and re-use the current low power nrf24 temperature sensors. This library has just the right functionality and seems to work flawless on ESP and atmega328p. Thanks!

  Are you sure? yes | no