среда, 25 марта 2015 г.

nRF24l01 with RF24Network

How to use nRF24l01 trancievers with arduino like repeater, to extend network range. If you have sensors far from base node, you will need some repeater in the "middle". Here is shown working code for Base node 00, repeater node 01 and sensor node 011. Please take care, what the addresses in the code have OCT format, not DEC or BIN. network.update() must be at beginning of the loop, in order to make repeaters.

For Base 00 node:
//node 0
#include 
#include 
#include 

RF24 radio(8,9);
RF24Network network(radio);

const uint16_t node0 = 00;
const uint16_t node1 = 01;
const uint16_t node11 = 011;

struct payload_t
{
  unsigned long ms;
  unsigned long counter;
};

void setup(void)
{
  Serial.begin(115200);
  Serial.println("RF24Network/examples/helloworld_rx/");
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ node0);
}

void loop(void)
{
  network.update();
  while ( network.available() )
  {
    RF24NetworkHeader header;
    payload_t payload;
    network.read(header,&payload,sizeof(payload));
    Serial.print("Received packet #");
    Serial.print(payload.counter);
    Serial.print(" at ");
    Serial.println(payload.ms);
  }
}
For repeater 01 node:
//node 1
#include 
#include 
#include 

RF24 radio(9,10);
RF24Network network(radio);

const uint16_t node0 = 00;
const uint16_t node1 = 01;
const uint16_t node11 = 011;

void setup(void)
{
  Serial.begin(115200);
  Serial.println("Rf24Network Relay");
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ node1);
}
void loop(void)
{
  network.update();
}

For sensor 011 node:
//node 11 
#include 
#include 
#include 

RF24 radio(9,10);
RF24Network network(radio);

const uint16_t node0 = 00;
const uint16_t node1 = 01;
const uint16_t node11 = 011;

const unsigned long interval = 2000; //ms
unsigned long last_sent;
unsigned long packets_sent;

struct payload_t
{
  unsigned long ms;
  unsigned long counter;
};

void setup(void)
{
  Serial.begin(115200);
  Serial.println("RF24Network/examples/helloworld_tx/");
  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ node11);
}

void loop(void)
{
  network.update();
  unsigned long now = millis();
  if ( now - last_sent >= interval  )
  {
    last_sent = now;
    Serial.print("Sending...");
    payload_t payload = { millis(), packets_sent++ };
    RF24NetworkHeader header(/*to node*/ node0);
    bool ok = network.write(header,&payload,sizeof(payload));
    if (ok)
      Serial.println("ok.");
    else
      Serial.println("failed.");
  }
}

пятница, 21 января 2011 г.

Kenwood TS-480 sniffer

Capture the serial data from Kenwood RS232 port which connected to PC and managed by some HAM software like N1MM or AAlog3. Arduino Mega 1280 serial port (Serial1.read) conected to PCs COM RX line. The data outputs from Arduino to KS0108 128x64 GLCD . Also used RS232 to TTL converter based on MAX232CPE. This project is part of Arduino based Solid State HF PA, but may be used like band decoder for atomatic antenna selector with ULN2003 and etc.
If you want to use my code that is fine but I would appreciate acknowledgment of this if you in any way publish your code. The code can be downloaded from this link