Skip to content

Instantly share code, notes, and snippets.

@aniline
Created October 31, 2015 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniline/3e129902daf067759877 to your computer and use it in GitHub Desktop.
Save aniline/3e129902daf067759877 to your computer and use it in GitHub Desktop.
ESP8266 + Arduino IDE + nRF24 thingy test prog
#include <SPI.h>
#include <Arduino.h>
#include "nRF24L01.h"
#include "RF24.h"
/* Radio */
RF24 radio(5, 4);
uint64_t address[] = { 0xF2F2F2F20100 };
//uint64_t o_address[] = { 0xF2F2F2F20200 };
uint64_t o_address[] = { 0x0002F2F2F2F2 };
void setup () {
Serial.begin(115200);
Serial.setDebugOutput(true);
radio.begin ();
radio.powerUp ();
radio.setAutoAck(0);
radio.setPALevel(RF24_PA_MIN);
radio.setRetries(0, 0);
/* To write */
// radio.openWritingPipe(address[0]);
/* To read */
radio.openReadingPipe(1, o_address[0]);
radio.startListening();
radio.printDetails ();
}
void dump_hex(const char *msg, unsigned char *buf, int len) {
int i;
os_printf("%s %d\r\n", msg, len);
Serial.flush();
for (i = 0; i < len; i++) {
if ((i % 16) == 0) {
Serial.flush();
os_printf("\r\n%03x: ", i);
}
os_printf(" %02x", buf[i]);
}
os_printf("\r\n");
Serial.flush();
}
void loop () {
uint8_t pipeNo;
uint8_t buf[36];
uint8_t obuf[18];
if (radio.available(&pipeNo)) {
memset(buf, 0, 36);
radio.read(buf, 32);
dump_hex("Rx data", buf, 16);
}
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment