So iam using the NRF24L01 transiver as an alarm system. Iam using 2 which both work but on the one serial monitor now and then a randon number will appear ? Just asking what this could be ?
:1048576
Only that.
Receiver=
#include <FastLED.h>
#include <RF24.h>
#include <RF24Network.h>
#include <SPI.h>
const int buzzer = 7; //buzzer to arduino pin 9
const int led=2; //led pin
const int LED_PIN=6;
const uint64_t pipe[1]= {0xF0F0F0F0E1LL};
#define NUM_LEDS 5
#define DATA_PIN 6
CRGB leds[NUM_LEDS];
RF24 radio(10, 9); // nRF24L01 (CE,CSN)
RF24Network network(radio);// Include the radio in the network
const uint16_t this_node = 01; // Address of our node in Octal format ( 04,031, etc)
void setup() {
Serial.begin(9600);
SPI.begin();
radio.begin();
delay(10);
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
pinMode (buzzer, OUTPUT);
pinMode(led, OUTPUT);
radio.setAutoAck(true);
radio.enableAckPayload();
radio.enableDynamicPayloads();
radio.openReadingPipe(1,pipe[0]);
radio.startListening();
radio.setRetries(15,15);
network.begin(90, this_node); //Frequncy
}
void loop() {
network.update();
while ( network.available() ) { // Is there any incoming data?
RF24NetworkHeader header;
unsigned long buttonState;
network.read(header, &buttonState, sizeof(buttonState)); // Read the incoming data
Serial.print(" button1 :");Serial.println(buttonState);
delay(50);
noTone(buzzer);
fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
if(buttonState==20){
fill_solid( leds, NUM_LEDS, CRGB(200,100,0));
FastLED.show();
delay(500);
tone(buzzer,1000);
fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
FastLED.show();
delay(500);
noTone(buzzer);
fill_solid( leds, NUM_LEDS, CRGB(200,0,0));
FastLED.show();
delay(500);
tone(buzzer,1500);
fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
FastLED.show();
delay(500);
noTone(buzzer);
}else{
fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
FastLED.show();
noTone(buzzer);
}
if(buttonState==30){
fill_solid( leds, NUM_LEDS, CRGB(0,0,200));
FastLED.show();
noTone(buzzer);
delay(500);
fill_solid( leds, NUM_LEDS, CRGB(0,200,0));
FastLED.show();
delay(500);
fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
FastLED.show();
delay(500);
}
}}
Transmitter =
#include <RF24Mesh.h>
#include <RF24Mesh_config.h>
#include <RF24.h>
#include <RF24Network.h>
#include <nRF24L01.h>
#include <SPI.h>
const int button3=7;
const int button2=6;
const int button=5;
const int buzzer=4;
int but2=0; //Button inputs
int but3=0;
int but1=0;
int Number=0; // Varabel
RF24 radio(10, 9); // nRF24L01 (CE,CSN) pins
RF24Network network(radio); // Include the radio in the network
const uint16_t this_node = 00; // Address of this node in Octal format ( 04,031, etc)
const uint16_t node01 = 01; //Each node
const uint16_t node02 = 02;
const uint16_t node03 = 03;
const uint16_t node04 = 04;
const uint16_t node05 = 05;
int beater=0;
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};
void setup() {
Serial.begin(9600);
radio.begin();
delay(10);
SPI.begin();
pinMode(button, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
network.begin(90, this_node); //(channel, node address)Therfor 2400+(channel)= frequncy===== 2.400+90= 2490
radio.stopListening();
radio.setAutoAck(true);
radio.enableAckPayload();
radio.enableDynamicPayloads();
radio.openWritingPipe(pipe[0]);
radio.setRetries(15,15);
}
void loop() {
but1=digitalRead(button); //Finding state of buttons
if(but1==0){
Number=0;
}
but2=digitalRead(button2); //Finding state of buttons
Serial.print(" Button2 :");Serial.println(but2);
if(but2==0){
Number=20;
}
but3=digitalRead(button3); //Finding state of buttons
Serial.print(" Button3 :");Serial.println(but3);
if(but3==0){
Number=30;
}
Serial.print(" Number :");Serial.println(Number); //Writing values to serial monitor
delay(50);
network.update();
unsigned long buttonState = Number;
RF24NetworkHeader header(node01); // (Address where the data is going)
RF24NetworkHeader header2(node02); //Other nodes
RF24NetworkHeader header3(node03);
RF24NetworkHeader header4(node04);
RF24NetworkHeader header5(node05);
bool ok = network.write(header, &buttonState, sizeof(buttonState)); // Send the data
bool ok2 = network.write(header2, &buttonState, sizeof(buttonState)); //Sending the button state to each node
bool ok3 = network.write(header3, &buttonState, sizeof(buttonState));
bool ok4 = network.write(header4, &buttonState, sizeof(buttonState));
bool ok5 = network.write(header5, &buttonState, sizeof(buttonState));
delay(50);
}