Moteino connected to breadboard- RF interference
Hi.
I'm testing RF communication between 2 moteinos (moteino v4, RFM69HW, 433mhz, distance between moteinos is 2m).
One moteino is connected to breadboard, together with Raspberry PI and LCD display.
Receiving works fine, but there is problem with sending.
I send data with sendWithRetry method, but it hangs there forever. I would like to know why sending doesn't timeout (default retry count is 2 and retry wait time 15ms) ?
I've noticed that sending is successful as soon as I touch senders antenna with hand.
My questions:
- Moteino's antenna is near other wires ... is this the reason for sending problems, wires probably causes electrical interference ?
- why sendWithRetry doesn't timeout ?
Thanks
Can you include the sketch you're using on the HW?
I took source from Garagemote base/node sketch(https://github.com/LowPowerLab/RFM69/blob/master/Examples/GarageMote_base/GarageMote_base.ino)
Sorry, my code is a mess at the moment (doing some changes), but radio sending part is the same as in original garagemote sketch:
-define section:
#define NODEID 1
#define NETWORKID 100
#define FREQUENCY RF69_433MHZ
#define RFBUFFERSIZE 3
RFM69 radio;
- setup method:
radio.initialize(FREQUENCY,NODEID,NETWORKID);
radio.setHighPower();
radio.encrypt(ENCRYPTKEY);
- loop method:
LOGlcd("Sending..."); //last message printed
//here I'm doing some parsing from serial input, and I get: char* doorCommand, which is "OPN"
if (radio.sendWithRetry(node, doorCommand, RFBUFFERSIZE)) { //it stops here...
LOGlcd("Command sent."); //this prints right after I touch antenna
} else {
LOGlcd("Error sending.");
}
LOGlcd("End.");
I guess it's possible to have interference from other wires. Any way you could isolate the Moteino from the wiring to see if it goes away?
I ran into this issue at some point but I can't remember if there was a software issue or just hardware related. Anyway always good to use the latest RFM69 code on github.
I've isolated it and it works.
But I still don't know why it didn't timeout ?
I'm using lattest RFM69.h/.cpp lib from github.
I didn't debug it, but it probably stops in while loop here:
void RFM69::send(byte toAddress, const void* buffer, byte bufferSize, bool requestACK)
{
writeReg(REG_PACKETCONFIG2, (readReg(REG_PACKETCONFIG2) & 0xFB) | RF_PACKET2_RXRESTART); // avoid RX deadlocks
[u][b]while (!canSend()) receiveDone();[/b][/u]
sendFrame(toAddress, buffer, bufferSize, requestACK, false);
}
Well it works fine now. I'll install garagemote, but I hope that some day command won't hang in that while loop, and resume(door will open) after I'll be away from home :)
RF and antennas is a complex subject and I can't explain a lot of things I wish I could.
For the most part these radios work great. The wire antennas are not perfect but for the performance/price I think they are great.
I did notice far fewer quirks/issues with 915Mhz radios though (not to say that there are many issues with 433s). Again .. not something I can easily explain why.
I recall when I had this same deadlock issue the code was stuck in that while loop, because a register (rssi?) was not going below the busy treshold (presumably from the noise..?).
Thanks for quick responses.
I've done some more tests, and it works fine. I'll install it to my garage doors tomorrow and I hope that there won't be any deadlocks :)
I'll include a TOTP(Time-based One-time Password) token with that open/close command, so even if there will be some deadlocks on base node and if command resumes from that deadlock after some time, node will ignore it, because token won't be valid anymore.