Hello @want0f, in the first sketch are you using 2 times the same setup and loop? O suppose not but can you see in the library if RF24 already is defined? A redefinition means it is defined already somewhere. I´ll load the code up when I´m home, maybe then I´ll see the problem.
This line tells you where it thinks the problem is: "1f2n9k2.dnz6\sketch_aug21a\arduino_wireless_test_reciever.ino:7:11: error: redefinition of 'RF24 radio'
RF24 radio(9, 8); // CE, CSN" The 7:11:error tells me there is a problem around line 7 in the aforementioned information. Try to comment it out and see what happens.
Hi @want0f I've uploaded the code and I don't receive any errors:
I've installed following libraries:
RF24 by TMRh20 and BTLE by Florian Echtler, which libraries do you have installed?
Following I've uploaded the code in seperate sketches 1 for the transmitter and 1 for the receiver:
//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 8);
//address through which two modules communicate.
const byte address[6] = "00001";
void setup()
{
radio.begin();
//set the address
radio.openWritingPipe(address);
//Set module as transmitter
radio.stopListening();
}
void loop()
{
//Send message to receiver
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
delay(1000);
}
1 Into another sketch:
//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//create an RF24 object
RF24 radio(9, 8); // CE, CSN
//address through which two modules communicate.
const byte address[6] = "00001";
void setup()
{
while (!Serial);
Serial.begin(9600);
radio.begin();
//set the address
radio.openReadingPipe(0, address);
//Set module as receiver
radio.startListening();
}
void loop()
{
//Read the data if available in buffer
if (radio.available())
{
char text[32] = {0};
radio.read(&text, sizeof(text));
Serial.println(text);
}
}
Note that the IDE is accessing 2 sketches in the sketch folder. Either of them may be perfect but both of them contain at least some of the same definitions, hence the errors
@UKHeliBob@want0f Yeah I suppose this is the problem, you have used 2 sketches with the same unsaved name. Save 1 as f.e. sketch_transmitter and the other as sketch_receiver.
When testing radio communication it is tempting to do what you did but it will not work because all of the .ino files open in the same instance of the IDE will be compiled together
Save each file in a different location. If you are using IDE 1.x then you can open both in separate instances of the IDE. Do not use file/new to open the second file otherwise both will use the same COM port and if you change it in one then it will also change in the other. Instead, open the first file then start a new instance of the IDE and open the second file in it. That way each sketch can use a different COM port
If you are using IDE 2.x then File/New will work OK as COM port changes for one sketch will not affect the other one
It looks like Windows makes that easy for apps that support it. Hold the shift key down when you do the thing that launches an app, presto! 2nd (or Nth) instance.
So far as bit of googling goes for MacOS tells me, it's not as simple.
But the terminal command open is the key. I have not tried this yet; I have enough trouble with one instance. cough!