nRF24l01+ to control Solid State Relay for Home Automation

Hello guys,

Let me say first that I am not good in C and have never worked with libraries and other C stuff. But I am not new to programming and can do with little bit of guidance which is what I seek here. Well, if someone can write the full code that would be wonderful.

Heres what I want to do. I want to control a SSR(solid state relay) using nRF24L01+ . So the relay will be connected to Arduino Duemilinova(im sure I got the spelling wrong), I will send some sort of code (0 and 1 i guess) to turn the relay on or off from another Ardiuno. I want to be able to control them from web which is I will worry about later.

Any help would be wonderful. Thanks guys.....

I just have to choose number one, I like number one, a lot.

Cheers,
Kari

Not much help yet from this forum

dbanerje:
Not much help yet from this forum

I don't think there are too many people who lurk these forums looking to do projects for people. If you're interested in learning it rather than just having people do the work for you, then it would help if you posted more information like what you've tried, the library you're using, some code, etc.

Fair enough, Below is the code I have been trying to modify :

TX

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>

define RELAY_PIN 8

RF24 radio(9,10);

// Network uses that radio
RF24Network network(radio);

// Address of our node
const uint16_t this_node = 1;

// Address of the other node
const uint16_t other_node = 0;

// How often to send 'hello world to the other unit
// const unsigned long interval = 2000;

// When did we last send?
unsigned long last_sent;

// How many have we sent already
unsigned long packets_sent;

// Structure of our payload
struct payload_t
{
unsigned long ms;
unsigned long counter;
};

void setup(void)
{
pinMode(RELAY_PIN, OUTPUT);
Serial.begin(57600);

SPI.begin();
radio.begin();
network.begin(/channel/ 90, /node address/ this_node);
Serial.println("Press the spacebar to toggle relay on/off");
}

void loop(void)
{
// Pump the network regularly
network.update();

unsigned long now = 0;

static int relayVal = 0;
int cmd;

while (Serial.available() > 0)
{
cmd = Serial.read();

switch (cmd)
{
case ' ':
{
relayVal ^= 1; // xor current value with 1 (causes value to toggle)
if (relayVal)
Serial.println("Relay on");
else
Serial.println("Relay off");
break;
}
default:
{
Serial.println("Press the spacebar to toggle relay on/off");
}
}

if (relayVal)
digitalWrite(RELAY_PIN, HIGH);
else
digitalWrite(RELAY_PIN, LOW);
}
// if ( now - last_sent >= interval )
{
// last_sent = now;

//Serial.print("Waiting for spacebar to toggle...");
//payload_t payload = { millis(), packets_sent++ };
RF24NetworkHeader header(/to node/ other_node);
//bool ok = network.write(header,&payload,sizeof(payload));
// if (ok)
// Serial.println("ok.");
// else
// Serial.println("failed.");
}
}

RX

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>

// nRF24L01(+) radio attached using Getting Started board
RF24 radio(9,10);

// Network uses that radio
RF24Network network(radio);

// Address of our node
const uint16_t this_node = 0;

// Address of the other node
const uint16_t other_node = 1;

// Structure of our payload
struct payload_t
{
unsigned long ms;
unsigned long counter;
};

void setup(void)

{

Serial.begin(57600);
Serial.println("RF24Network/examples/helloworld_rx/");

SPI.begin();
radio.begin();
network.begin(/channel/ 90, /node address/ this_node);
}

void loop(void)
{
// Pump the network regularly
network.update();

// Is there anything ready for us?
while ( network.available() )
{
// If so, grab it and print it out
RF24NetworkHeader header;
payload_t payload;
network.read(header,&payload,sizeof(payload));

digitalWrite(8, HIGH);
//delay(200);
//digitalWrite(13, LOW);*/

/Serial.print("Received packet #");
//Serial.print(payload.counter);
//Serial.print(" at ");
// Serial.println(payload.ms);
/
}
}

I just need to know how to send the information to the rx node. Any help?

  network.write (header, &message, sizeof (message)) ;

Seems to be the counterpart of network.read(...) You need to setup the header structure appropriately too.

BTW note the code tags you should use when quoting code (the # button when composing a post)