Setup:
Transmitter and Receiver code uses RadioHead/RH_ASK.h
433 MHz receiver connected to a Nano
433 MHz transmitter connected to either a Nano or Pro Mini.
Everything work when communicating from Nano to Nano.
No communication between Pro Mini and Nano.
In either case, the transmitter and receiver code are identical.
I tracked this down to different pulse lengths sent to the transmitter module.
The duration of the on-level for first train of pulses at the beginning of a transmission are are 0.5 msec with the Nano an 0.3 msec with the Pro Mini.
That probably means that the receiver code running on the other Nano does not recognize the transmission from the Pro Mini as proper protocol.
So, I suspect that there is some issue with setting up timers.
Interestingly, delay() works properly on both platforms.
Questions:
Which timers are being used by the RadioHead library? Any know issues with that?
What would be the proper protocol timing - 0.5 msec or 0.3 msec?
Any help or suggestions are greatly appreciated. Thanks!
The diodes decouple switches, so that each can generate an interrupt on pin2 - not used in the code as shown. The SSR is nothing special, turns on/off with a 1 / 0. The boost converter is off-the-shelve to get from 3V to 5V.
The transmitter's Din is connected to the pin 12, and the receiver's data pin is connected to D11.
Any input on my original questions:
Which timers are being used by the RadioHead library? Any know issues with that?
What would be the proper protocol timing - 0.5 msec or 0.3 msec?
I do not understand the question. You are limited by law, world wide, to a specific number of short transmissions per second because those frequencies are shared by many types of users.
My question about timing refers to the pulse width of the first few pulses sent by the controller to the RF transmitter. I want to understand whether the Nano (0.5 msec) or the Pro Mini (0.3 msec) has the correct timing.
I suspect you are looking at the synchronizing signals sent by the transmitter internal controller and has nothing to do with either ARduino. You do have documentation on the 433 MHz device don't you?
OK, I figured out the problem:
I forgot to undo some experimental changes in boards.txt which changed the clock frequency.
As a result F_CPU had the wrong value, which messed up the computation in RH_ASK::timerCalc() by always returning too small a number in nticks, ultimately causing the pulse width to be too short.
Thank you very much to everybody who spent (wasted) cycles on this problem. My apologies.
Regarding the question about the diodes: I want to generate an interrupt by pulling down pin 2 whenever a button is pushed. In the ISR I will detect which button was pushed by querying pins 3-5. The diodes ensure that only that pin is low which is connected to the active button. Without the diodes all pins would be pulled low.
Ah, makes sense, but I don't think we'd have ever figured that out! Good that you found the issue.
You do know that you have interrupts on any GPIO, right? You only have to read the input register to figure out which pin triggered it. I'm not sure if this will also work if you need the interrupt to wake the controller from sleep; is that why you're stuck with pin2?
Good point.
I defaulted to pin 2 because attachInterrupts() only allows pins 2+3 as sources for interrupts.
I read through the relevant sections in the ATmega328P data sheet and I see how that should work. If I actually will end up with 3 buttons (instead of 1 toggle button), I will explore that further.
Thanks !!