I don't know about others, but the several R4 and Mega units that I have had now for a couple weeks, seem to have a very similar problems.
I have had very similar issues with Power-up of the Moteino R4 and the Mega's that I have here. I think they are fantastic devices, but I have seen some inconsistencies on startup with them when using V-IN power to them stand alone with USB chargers and/or batteries. The inconsistency happens when the power is applied and they are stand alone. It seem that the RFM69 does not always get a full reset during power-up from what I can tell, and it seems to get worse when there is a bit low battery, but enough to run it.
To catch this in action, I added an additional "catch/fail" line to the initialize() routine in the RFM69 library upon "first contact" to the unit from the library.
I added a line of code just past here ...
...
unsigned long start = millis();
uint8_t timeout = 50;
do writeReg(REG_SYNCVALUE1, 0xAA); while (readReg(REG_SYNCVALUE1) != 0xaa && millis()-start < timeout);
...
to ...
...
unsigned long start = millis();
uint8_t timeout = 50;
do writeReg(REG_SYNCVALUE1, 0xAA); while (readReg(REG_SYNCVALUE1) != 0xaa && millis()-start < timeout);
//Fail the init routine if timed out/still not 0xaa.
if( readReg(REG_SYNCVALUE1) != 0xaa ) { return false; }
...
The reason for this is that there is no exit with fail test for the very first exchange of info on the SPI to the the RFM69.
In my calling program, if the init fails, I resort to blinking the on-board LED rapidly (80 ms blink rate) and halting the entire sketch. This way I will know for sure if I have a bad boot sequence and the device is NOt going to communicate properly.
================
What was happening for me is while they were connected to the FTDI (R4), or the usb directly (Mega with usb on board), they worked flawlessly and perfectly, but put them on a separate power source,... they have trouble. With my sketch set to blink rapidly on init failure, powering the devices up via plugging them into a battery several times over reveals that at least for me, they do fail the init randomly.
I suppose someone with no error checking at the init routine failure would get very frustrated and scratch their head if this were happening to them. At first, I blamed it on all kinds of stuff in the Sketch I had made. Why would they not work unless connected to my PC?. - I even blamed it on the Serial etc,.. but in the end I found out what fixed it for me. It had nothing whatsoever to do with the sketch, or its libraries. It was a hardware problem, where the reset pin was not being held low long enough for both devices to reset properly when powered only by the VIN and no other connections. I didn't want to spend all night trying to find the exact value capacitor, etc. and simply wanted to prove my theory,.. so I pulled an old small (0.1uF) capacitor out of a bad circuit board i had laying around, tested it to make sure it was good, then placed it across the the reset pin to ground. -- VIOLA!!! --- 100% perfect boot sequence every single time I applied power to them.
I ended up just placing the capacitor on all my boards when they operate stand alone, and removing it when connected to the pc and it has completely solved the random boot issue I have been seeing with them. Nice big fat reset signal no matter how low the battery level might be.
I know I should take the time to eventually go find the correct value to use, but this does it for me so far no problem. I just unplug the capacitor before plugging the board back into the Pc for re-flashing for now.