I've been having trouble trying to get this to work. So basically, I'm trying to get some sort of bidirectional communication between two arduinos, but it is a one way communication that happens on different times i.e. Board 1 sends message to Board 2, Board two recieves it and sends a message back to Board 1 (that way it's not simultaneous). I'm using RadioHead library for this, these are the codes (after including libraries):
Board 1
Circuit is well built as I can have a one way communication B1->B2 and B2->B1, but when trying both on same code it doesn't work.
Anyone knows how to fix this? Please helppp.
Thanks in advance.
PD: noticed also that one way communication doesn't work when trying to init() both the Tx and Rx so this maybe the source of the problem, but I don't know how to fix this either.
If you are using an AVR based Arduino, you can't have two instances of the library operational at the same time, because they conflict over timer use.
That may be possible with other MCUs, but I doubt such a setup can be practical, when there are so many inexpensive transceivers that also vastly outperform the modules you are using.
Is there a way for me to initialize and "un-initialize" an instance during the loop? That way I can have operational the one that I'm using at that current moment?
Or a better question would be: how can I manage to do this one way communication back and forth on two different times with the modules I'm using without having this issue?
I've read posts that say it's possible but never explain how speciffically
You're right, my bad.
So basically, as said above, the problem was having two instances of RH_ASK operational at the same time (askRx for receiver and askTx for transmitter), and that could be solved by just creating a single instance (driver) that does both tranmsit and receive. These were the codes that worked best:
Board 1:
Also had the problem that B1 won't allways get the msg when listening instantly, that's why I used 2 while cycles: the one for B1 makes it so it listens for 1.5s (0.1 duration loop) or until it receives B2's msg, and B2's makes it so it sends 4 msgs (with 0.1s delay each as well) so that B1 catches one of them.
These delays worked for me so that B2 would be allways ready to receive when B1 finishes it's loop, otherwise 1 of every 2 msgs sent by B1 would be received by B2, and that means a 1.5s delay between communcations (B1 main loop duration).