Hallo robtillaart thanks for your replay. i have tried it but it still did not work.
also i have tried freeRam () method in the beginning it print around 600 after that it decrease around 240.
Transmitter code
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
static char message[25] = {"{\"Red\":255,\"Blue\":255}"};
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;
void setup() {
Serial.begin(9600);
Serial.println("RF24Network/examples/helloworld_tx/");
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
}
void loop() {
// Pump the network regularly
network.update();
Serial.print("Sending...");
RF24NetworkHeader header(/*to node*/ other_node);
bool ok = network.write(header,&message,sizeof(message));
if (ok){
Serial.println(message);
Serial.println("ok");
}
else{
Serial.println("failed.");
}
}
Receiver code
#include <Adafruit_NeoPixel.h>
#include <aJSON.h>
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#define PIN 6
//#include "pitches.h"
//#include <avr/pgmspace.h>
//aJsonObject* root = aJson.createObject();
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);
//int noteDurations[] = {1,2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,1};
//int melody[] = { NOTE_A3};
aJsonObject* AfterReceive;
//Red
//Green
/*Blue
aJsonObject* query2;
//
aJsonObject* query3;
//NumOfRow
aJsonObject* query4;
// The user choose the value that if the value of the sensor reach it to alarm him
aJsonObject* query5;
// The value of the sensor
aJsonObject* query6;
//Oparation Mode
aJsonObject* query7;
*/// The received message from the master
static char message[26];
// CE, CSN
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;
void setup()
{
Serial.begin(9600);
Serial.println(F("Hello"));
Serial.println();
Serial.println(freeRam());
//--- Setup ALL rf radios
SPI.begin();
radio.begin();
network.begin(/*channel*/ 90, /*node address*/ this_node);
strip.begin();
strip.show();
}
void loop()
{
// Pump the network regularly
network.update();
// Is there anything ready?
while(network.available())
{
RF24NetworkHeader header;
network.read(header,message,sizeof(message));
Serial.println(F("Received: "));
Serial.println(message);
//aJson.deleteItem(AfterReceive);
AfterReceive = NULL;
if (AfterReceive == NULL){
AfterReceive = aJson.parse(message);
Serial.println(F("After Json parse"));
}
if (AfterReceive != NULL){
Serial.println(F("Inside if"));
aJsonObject* query = aJson.getObjectItem(AfterReceive , "Red");
int string =int( aJson.print(query));
Serial.print(query->valueint);
strip.setPixelColor(0,int(query),0,0);
aJson.deleteItem(query);
Serial.println();
Serial.println(freeRam());
aJsonObject* query1 = aJson.getObjectItem(AfterReceive , "Blue");
char* string1 = aJson.print(query1);
Serial.print(query1->valueint);
aJson.deleteItem(query1);
aJson.deleteItem(query1);
/* query2 = aJson.getObjectItem(AfterReceive , "Green");
char* string2 = aJson.print(query2);
Serial.print(query2->valueint);
aJson.deleteItem(query2);
strip.setPixelColor(3,0,int(query2),0);*/
strip.setPixelColor(1,0,0,int(query1));
strip.setPixelColor(2,int(query),0,int(query1));
strip.show();
Serial.println();
Serial.println(freeRam());
Serial.println();
Serial.println(freeRam());
break;
}}
Serial.println();
Serial.println(freeRam());
}
int freeRam ()
{
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
[code]
[/code]