Hi,
I've got 2 nRF24L01 connected to my PC.
I've downloaded the example code and everything is working fine.
However the example code transmits a string "Hello world".
I want to replace the string with a variable that reads the state of a switch.
Say: When a switch is closed the transmitter board sends a "1", when the switch is open the board transmits a "0".
I spent all afternoon trying to have this working but to no avail.
However on the Serial post I can see the value of the switch.
I connect my NRFs to Arduinos or other microcontrollers, not to a PC.
LRAT:
I want to replace the string with a variable that reads the state of a switch.
But against your intention you send a string initialized by the state, strange.
Claiming that the resulting string will not be sent contradicts the "it is working with strings".
For sending the button state I would use
radio.write(&buttonState, sizeof(buttonState));
BTW I would not use an int to hold values that can only be HIGH or LOW.
I've got it working now. I got rid of the code line "const char text[] = (buttonState,1));" and applied your recommendations. It's now working fine.
The reason why I've got the two boards connected to my pc is because it's a developing environment.
Both UNO-boards are connected to a different COM-port and I've got two Arduine IDE instances open.
Both boards are running indepently from one another.
I want to use the transmitter board to collect pulses from a TBRG (Tipping Bucket Rain Gauge). These tips will then be transmitted to my pc where I can record the data.
My next step will be to have a RTC generating a timestamp every time a tip on the TBRG occurs. This will then be send to my home pc where the tips will be added so that I can see the toatl of rainfall for the day.