Hi everyone!
I've been working on a small motion sensor project to learn more about electronics and wireless communication. It consists of a stationary motion sensor and a portable, battery powered receiver. To "shrinkify" the receiver, which currently consists of an Arduino Uno and an RFM69HW+logic level converter very unprofessionally soldered mid-air(it's a miracle that it even works, lol), I decided to buy a Moteino R6 and an accompanying RFM69HCW radio module(bought separately, as I am able to solder and buying them seperately ended up being cheaper)
I also bought a generic FTDI adapter board(chip seems genuine and works fine) which I'm using to upload code to the Moteino.
To verify everything works, I uploaded a simple blink sketch(not interfacing with the radio at all at this point) and everything worked fine.
After that. I started building up a more complete test, where the Moteino sends an "alarm packet"(I've implemented this by simply sending the character "a", which the receiver listens for and then sounds an alarm) every second over to the old receiver. This at first did not seem to work but I quickly realized I should probably define "IS_RFM69HW_HCW" as I have such a module. After uploading the code, the receiver did actually receive one packet and sound the alarm, however afterwards it seemed to go into a broken state. The LED was no longer blinking, the Serial comms were completely cut and the Moteino did no longer reset. I had to remove and reapply power, hook up a button that pulls RST/DTR to GND(So I can keep the Moteino in a reset-loop, preventing it from hanging) and be quick with uploading a new, not broken sketch.
I am unsure of what exactly is going wrong. Do RFM69Hxx modules work without the aforementioned define statement? Is my module broken? Am I just missing something insanely obvious?
This is the test code I'm uploading to the Moteino, I'm not going to include the code of the receiver side as it's very long(includes stuff for driving an LCD and a Rotary Encoder) but if needed, I can also share that. I can also share some pictures of how I have the Moteino connected if needed.
#include <LowPower.h>
#include <RFM69.h>
#include <RFM69registers.h>
#include <RFM69_ATC.h>
#include <RFM69_OTA.h>
#include <SPI.h>
#define FREQUENCY RF69_868MHZ
#define ENCRYPT false
#define USEACK true
#define NETWORKID 0
#define MYNODEID 2
#define TONODEID 1
#define IS_RFM69HW_HCW //This breaks the poor Moteino :(
RFM69 radio;
void setup() {
//Initialize everything needed, set the registers controlling the bitrate to match the receiver
pinMode(9, OUTPUT);
Serial.begin(9600);
radio.initialize(FREQUENCY, MYNODEID, NETWORKID);
radio.writeReg(0x03, 0x34);
radio.writeReg(0x04, 0x15);
}
void loop() {
//Blink the LED, print something on the Serial interface, read the radios' registers and send a packet
digitalWrite(9, HIGH);
delay(500);
digitalWrite(9,LOW);
delay(500);
Serial.println("Hello World!");
radio.readAllRegsCompact();
radio.sendWithRetry(TONODEID,'a',1,2,100);
}
Unsure of why everything after the first comment appears commented out above, please forgive me as it's my first time posting here.
Thank you for any help and again, sorry if this turns out to be an extremely simple fix clogging up the forum.
The good news is that uploading code does not break Moteinos, usually ;)
Good soldering is also essential, as cold solder joints or poor contacts can act erratically and cause a lot of grief. A decently soldered and oriented antenna is also important, or else a Moteino can suffer a great signal mismatch and perhaps work very poorly or not at all. This is where hardware becomes a little hard (vs software) and it's why your "is my xyz.. broken" questions can not have good answers. Moteinos are shipped in a guaranteed working state, beyond shipping a good module I cannot give any guarantees what comes after.
IS_RFM69_HCW is absolutely required if you have a HW/HCW module, that definition usually triggers calling radio.setHighPower() which is really the essential thing to happen for HW/HCW. My strong recommendation is always just use HCW modules, makes things a lot easier and consistent than trying to mix with W/CW which IMO are a total afterthought, maybe maybe using them with coin cells is a little more appropriate but ... even then HCW is well suited.
Given your description of "Moteino going to lunch scenario", I believe the culprit is the code.
For beginners I always advise to start from known working library examples (https://github.com/LowPowerLab/RFM69/tree/master/Examples), then incrementally modify/add code until you achieve what you want or observe anything breaking in which case you can easily backtrack and determine any breaking code since the last working state.
I hate to update the issue like this even though it works now but...
It... literally just works now. The only thing I changed was to print a line on the serial monitor after literally every line of setup() and loop() to maybe find the exact point it "breaks" but said breakage did not ensue. Maybe keeping the serial interface busy kept it from hanging, no idea.
It's up and running and the only troubleshooting to do now is the rather unimpressive range of around .5 to literally 0m(I assume this is due to my technically functional but not very good 1/4 wavelength antenna without a dipole) but I'm somewhat confident I can probably resolve that on my own as a lot of others have already encountered the same issue(although any help is still appreciated, I'll detail the problem I and probably hundreds of other people have run into below)
I'm unsure whether the antenna is actually the issue here or not. The signal from the old reciever to the Moteino has an RSSI of around -15db at 30cm or so, while the other way round I'm seeing -90db or less, most of the time nothing coming through at all. Both have the same antenna mentioned above. So the Moteino receives signals just fine but the TX power is very low(i really hope this isn't the result of a bad module :'()
I've tried different values for radio.setPowerLevel() with no real change. Would it be helpful to modify my code to make use of ATC?
Quote from: acidicmayonnaisepool on February 14, 2022, 01:33:01 PM
I've tried different values for radio.setPowerLevel() with no real change. Would it be helpful to modify my code to make use of ATC?
Yup, already mentioned that starting from working library examples (https://github.com/LowPowerLab/RFM69/tree/master/Examples) is the way to go. Then you know code is not the issue. Of course ensure configuration is correct. Mind that IS_RFM69_HCW parameter, match the frequency also. Keep the antenna straight up/perpendicular to the board (not coiled!).