I have been using the nrf24l01 modules, and tried a few examples (random number, bi directional ack demo, motor drive, dimmer) and has success with all (eventually)
So i moved on to build a radio controlled 240v ~ Fan for a particular pottery project for my wife.
Cutting a long story short all is well, but i wasn't aware of this issue...
The transmitter is hand held, 9v battery operated,10k pot voltage divider to A0 etc. battery failed eventually - and no rf signal being sent but the fan continued, monitoring D3 pwm (which drives my thyristor module) i noticed the output was still active - i then edited tx code to minimum rf power to intentionally make the rx lose reception and the same result occurred.
Took it for granted that if it loses reception that the pwm D3 would be switched off.
Had a read up on the subject, and seems to be an edit required named failsafe ?
When i thought about it anyone using the nrf modules for a rc car, drone etc would use this option - otherwise car or drone would carry on into the sunset never to be seen again if rf signal failed.
Had a couple of hours today which was disastrous, but managed to get back up and running and back to square one.
I found several snippets of code and attempted to add to my sketch but as previously mentioned it didn't go very well.
Would be grateful for a little advice if anyone has had the same experience ?
All i need to do is turn off D3 pwm if no signal detected
Do i need to look at the radio signal for 0.5s and if no signal (data) reset. ? or is it the rx that detects the tx is connected rather than data being received ?
I believe it needs to go into line 52 after radio begin.
Nano v3
nrf24l01
Sorry if code is scruffy, it's my first.
Many thanks
The receiver has no way to tell the difference between a transmitter that isn't sending any data and a transmitter that has a dead battery. The only thing you can do is track how long it has been since the last time you received anything and it that exceeds some time limit, go into failsafe mode. This works fine for RC cars/drones since they are in constant contact. This is not the case with the project your describe. Normally, a transmitter does not continually send a signal to keep a fan running.
If you control the transmitter as well, you can set of two way communication so the receiver sends a query to the transmitter every so often and if it does not get a response, it goes into failsafe.
As a side note
const byte Address[6] = " 00009 " ; // Address from which data to be received
how are you stuffing 8 bytes (counting trailing null) into a 6 byte array? I don't think you are using the address you think you are, but if the transmitter has this same defect, it will still work.
blh64:
If you control the transmitter as well, you can set of two way communication so the receiver sends a query to the transmitter every so often and if it does not get a response, it goes into failsafe.
IMHO it will be simpler for the hand unit to transmit a message at regular intervals even if the data is unchanged. Then it is easy for the receiver to identify when the messages stop coming. That's what I use with my radio controlled model trains. I send a message about 5 times per second and the train stops if 5 messages are missed.
For your project a longer interval between messages may be sufficient.
If the hand-unit is sending messages you also have the option to put it to sleep between messages to save the battery - a transmission and its acknowledgement will only take a few millisecs. Whereas if the receiver is querying the hand-unit it must be listening for long enough periods not to miss a query.
The fan is variable by the way not just on or off state, and the tx is adjusted to control this as required via D3 Pwm to my 240v thyristor control board
const byte Address[6] = " 00009 " ; // Address from which data to be received
Yes the tx has the same defect. 8 bytes into a 6 byte array, i wasn't aware of this.... that will probably explain why in serial monitor i was getting random "data not received" messages inbetween "data received" ?
"If you control the transmitter as well, you can set of two way communication so the receiver sends a query to the transmitter every so often and if it does not get a response, it goes into failsafe."
I will watch the tutorial (again) on the above method.
Robin2
I will look into both methods suggested, thank you.
I was working with the deltang train dsm/x and esc equipment until recently for a small r/c business, but 99% of my work was hardware related and not software as you are probably aware.
Will have a good read up on the simple nRF24L01+ Tutorial again.