Hello to everyone and happy new year,i have a question about a project of home automation.
One of the things i want to control is 4 air co devices via ir.I 'm working with nrf24 with 10 nodes in the house,everything works perfect but i have an issue on ir codes airco units.The problem is if put all the codes from ir remote the arduino is running with limit ram memory.Here is the code of an node at living room.
i would be appreciate any kind of help to reduce memory problems.
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include <DHT.h>;
#include <IRLibSendBase.h> //We need the base code
#include <IRLib_HashRaw.h> //Only use raw sender
//off
#define RAW_DATA_LEN 140
uint16_t rawDataOff[RAW_DATA_LEN] = {
8934, 4542, 658, 550, 650, 554, 662, 1646,
602, 606, 662, 542, 658, 1650, 662, 546,
658, 546, 658, 550, 598, 606, 658, 1650,
654, 550, 654, 550, 666, 542, 662, 542,
666, 546, 658, 546, 658, 550, 662, 542,
598, 606, 606, 602, 654, 1654, 602, 602,
602, 610, 658, 546, 598, 606, 602, 606,
662, 542, 662, 1646, 662, 546, 662, 1646,
602, 606, 658, 546, 602, 1706, 598, 610,
598, 20030, 598, 1710, 658, 546, 602, 1706,
662, 542, 662, 546, 654, 550, 662, 542,
658, 550, 662, 546, 666, 538, 602, 606,
602, 602, 658, 550, 602, 602, 662, 1642,
662, 542, 662, 546, 662, 542, 658, 550,
662, 546, 658, 546, 662, 546, 658, 546,
654, 550, 662, 546, 598, 606, 602, 606,
658, 546, 602, 602, 606, 1702, 658, 1650,
654, 550, 662, 1000
};
//--------------------------Heat-------------------------------
//on thermansi 20
#define RAW_DATA_LEN 140
uint16_t rawDataOn20[RAW_DATA_LEN] = {
9022, 4482, 662, 542, 662, 546, 658, 1650,
658, 1646, 666, 542, 662, 1646, 662, 542,
662, 542, 662, 550, 658, 546, 662, 1646,
662, 542, 662, 546, 658, 550, 658, 542,
662, 546, 662, 546, 658, 546, 658, 546,
662, 546, 662, 542, 662, 1646, 662, 1646,
658, 550, 650, 550, 662, 546, 658, 550,
658, 546, 658, 1650, 658, 546, 658, 1650,
662, 546, 658, 550, 594, 1710, 658, 546,
662, 19970, 658, 1646, 658, 550, 662, 1642,
662, 546, 654, 554, 658, 546, 658, 550,
654, 550, 662, 546, 654, 550, 658, 550,
658, 546, 658, 550, 658, 546, 654, 1654,
658, 546, 662, 546, 658, 546, 662, 542,
598, 610, 662, 546, 658, 546, 662, 546,
658, 546, 658, 550, 658, 546, 654, 550,
666, 542, 658, 550, 658, 1646, 662, 1646,
658, 1650, 658, 1000
};
//on thermansi 21
#define RAW_DATA_LEN 140
uint16_t rawDataOn21[RAW_DATA_LEN] = {
8942, 4534, 602, 610, 598, 602, 602, 1706,
602, 1706, 598, 610, 598, 1706, 602, 606,
598, 606, 602, 1710, 598, 606, 602, 1706,
602, 602, 602, 606, 602, 602, 602, 606,
598, 606, 602, 606, 598, 610, 598, 606,
602, 606, 598, 606, 598, 1710, 598, 1710,
598, 606, 602, 602, 602, 606, 598, 602,
606, 606, 598, 1710, 602, 606, 598, 1710,
598, 606, 598, 606, 602, 1706, 602, 606,
598, 20030, 602, 1710, 598, 606, 602, 1706,
598, 606, 598, 610, 598, 606, 602, 602,
662, 546, 602, 606, 598, 606, 602, 606,
598, 610, 598, 602, 662, 546, 598, 1706,
602, 606, 598, 606, 602, 606, 602, 602,
602, 606, 598, 606, 602, 606, 654, 550,
658, 550, 658, 546, 602, 606, 602, 606,
602, 602, 602, 1706, 598, 1706, 602, 1710,
598, 1706, 602, 1000
};
//on thermansi 22
#define RAW_DATA_LEN 140
uint16_t rawDataOn22[RAW_DATA_LEN] = {
8994, 4482, 658, 546, 662, 546, 602, 1702,
602, 1706, 658, 546, 662, 1642, 666, 542,
598, 610, 662, 542, 658, 1650, 598, 1710,
598, 606, 662, 546, 662, 542, 666, 538,
602, 606, 658, 550, 658, 546, 602, 606,
654, 550, 658, 550, 654, 1654, 658, 1650,
658, 546, 658, 546, 606, 606, 654, 550,
662, 542, 662, 1646, 602, 606, 662, 1642,
666, 542, 658, 550, 658, 1646, 662, 546,
662, 19970, 662, 1650, 594, 610, 662, 1642,
662, 546, 598, 606, 662, 546, 658, 546,
602, 606, 598, 606, 602, 602, 658, 554,
662, 542, 654, 550, 658, 550, 598, 1706,
654, 554, 658, 546, 666, 542, 662, 542,
658, 550, 658, 546, 662, 546, 654, 550,
662, 546, 662, 542, 658, 550, 658, 546,
602, 606, 662, 542, 662, 546, 658, 546,
662, 546, 662, 1000
};
//on thermansi 23
#define RAW_DATA_LEN 140
uint16_t rawDataOn23[RAW_DATA_LEN] = {
8990, 4482, 598, 606, 598, 610, 598, 1710,
662, 1646, 598, 606, 662, 1646, 602, 606,
598, 610, 658, 1650, 654, 1650, 598, 1714,
594, 610, 658, 542, 602, 606, 662, 546,
662, 546, 598, 606, 598, 610, 658, 546,
598, 610, 654, 550, 602, 1710, 598, 1710,
598, 606, 658, 546, 654, 554, 598, 606,
654, 554, 658, 1650, 662, 522, 622, 1706,
598, 606, 658, 546, 654, 1654, 662, 546,
658, 19978, 658, 1646, 662, 546, 662, 1642,
662, 542, 662, 542, 666, 542, 666, 542,
662, 542, 658, 554, 658, 546, 658, 546,
662, 542, 662, 546, 662, 542, 598, 1714,
658, 546, 662, 546, 654, 550, 662, 546,
662, 542, 662, 542, 662, 546, 662, 542,
662, 546, 662, 546, 658, 546, 662, 542,
662, 546, 658, 1646, 662, 546, 662, 542,
662, 546, 658, 1000
};
IRsendRaw mySender;
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor
RF24 radio(10, 9); // nRF24L01 (CE,CSN)
RF24Network network(radio); // Include the radio in the network
const uint16_t master00 = 00;
const uint16_t node03 = 03;
const int relay1 = 4;
const int relay2 = 5;
const int relay3 = 6;
const int relay4 = 7;
const int relay5 = 8;
const int relay6 = 14;
const int relay7 = 15;
const int relay8 = 16;
char AcSaloni;
int PAPCstate;
int lastPAPCstate; // the previous reading from the input pin
struct package
{
float tempSaloni;
float humSaloni;
};
typedef struct package Package;
Package data;
/////------------------------------------------
void setup() {
SPI.begin();
Serial.begin(9600);
dht.begin();
radio.begin();
network.begin(95, 03); //(channel, node address)
radio.setDataRate(RF24_1MBPS);
radio.setPALevel(RF24_PA_MAX);
pinMode(relay1, OUTPUT);
pinMode(relay2, OUTPUT);
pinMode(relay3, OUTPUT);
pinMode(relay4, OUTPUT);
pinMode(relay5, OUTPUT);
pinMode(relay6, OUTPUT);
pinMode(relay7, OUTPUT);
pinMode(relay8, OUTPUT);
digitalWrite(relay1, HIGH);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, HIGH);
digitalWrite(relay5, HIGH);
digitalWrite(relay6, HIGH);
digitalWrite(relay7, HIGH);
digitalWrite(relay8, HIGH);
}
void loop() {
network.update();
// ===== Receiving =====
while ( network.available() ) { //Is there any incoming data
RF24NetworkHeader header;
network.read(header, &AcSaloni, sizeof(AcSaloni)); //Read the incoming data
if (header.from_node == 00) {
if (AcSaloni == 2) {
mySender.send(AcSaloni, RAW_DATA_LEN, 36); //Pass the buffer,length, optionally frequency
}
else if (AcSaloni == 3) {
mySender.send(rawDataOn20, RAW_DATA_LEN, 36); //Pass the buffer,length, optionally frequency
}
else if (AcSaloni == 4) {
mySender.send(rawDataOn21, RAW_DATA_LEN, 36); //Pass the buffer,length, optionally frequency
}
else if (AcSaloni == 5) {
mySender.send(rawDataOn22, RAW_DATA_LEN, 36); //Pass the buffer,length, optionally frequency
}
else if (AcSaloni == 6) {
mySender.send(rawDataOn23, RAW_DATA_LEN, 36); //Pass the buffer,length, optionally frequency
}
}
}
delay(10);
//data.tempSaloni = dht.readTemperature();
//data.humSaloni = dht.readHumidity();
//RF24NetworkHeader header(master00); // (Address where the data is going)
//bool ok = network.write(header, &data, sizeof(data)); // Send the data
//Serial.println(data.tempSaloni);
//Serial.println(data.humSaloni);
}