You should be able to a “mac save” then power the unit off completely using your
mosfet switch, then on power-on. it will retain the previous mac settings.
Issue the single command “mac join abp” and send data, mac save again to
save your frame counters etc. and power off with the PIC
Yep, that’s what I do - it’s working well now. I am currently fiddling with the calibration of the charge time for the capacitor, then I’m pretty much done for this node, then I can switch it on and wait to see what comes first, empty battery or my pension - I’m banking on the latter !
I’ve did something similar to what your doing with an ATiny85 only I used an
MCP1252 regulator and had the ATiny toggle the enable pin on the regulator.
It used 0.1uA in standby. The ATiny was in deep sleep, wake on interrupt tied
to a n.o. reed so very little current was used in until the “event” triggered / closed
the reed. Lasts forever on a small lipo.
That sounds really interesting - I choose the PIC because the lack of memory was frustrating to me, I don’t know the ATiny, perhaps I will take a look. In any case you broke my low-current record with it, so I will have to !
Key with mine was it took a physical event to wake the unit. There was no
timer running… I used an ATiny85. Not sure what it’s sleep current was but
I’m think it was appox also about 0.1ua so total of about 200na while sleeping
/ inactive. The ATiny waits for a signal from the radio that it is done before
shutting down power…
Keep in mind the eeprom used to save the values in the RN module might be first to go due to the write limit of eeprom cells…
Good point. I am not using a PIC with EEPROM (didnt realise this at first) so I only have two bytes that survive the reset by XLP every 10 seconds. I use these to count how many resets there have been and send a value every 15 minutes (90 x 10 seconds). I’m probably going to use Flash to store the capacitor calibration values every time the counter rolls over - they say it is good for 10000 writes or 20 years - probably very sceptical of me, but by then I probably wont remember what I made ! (I’m already 60!).
Don’t you also need to store the frame counters?
Yes - I thought so too, but up until now my testing all seems to be working ok. I don’t really understand why. I didn’t expect the Radio to store them over a power loss - I am probably missing something…
Just to prevent laughter I just checked that frame counter checks are enabled, and they are. Bit of a mystery ?
Are you calling
mac save each time now?
No. At the moment I do an OTAA join after programming the device. After this I send an initial value and then I do a mac save. After doing this the radio is switched off and the PIC goes to (XLP) sleep discharging a small capacitor. When it wakes up I check if the low-power-surviving register is at a multiple of 90. If it is is, I do a mac join abp and send a value. In all cases I then increment the register and go back to sleep. I feel lazy just talking about this, I should check it out and come up with an answer to what is going on - tomorrow I’m afraid !
And just to be sure: are the counters increasing in TTN Console…?
Yes, that is going ok. One strange thing is that it seems to be the case that the first transmit after the ‘mac join abp’ doesn’t get through, although I get an ‘mac_tx_ok’ back from the radio. If I then transmit a second time,it works and the counter increments as expected in the console. I will try to figure out what is happening exactly. Perhaps when I understand it I can confirm the behaviour with a mail to Microchip, then I can be certain.
…again just to be sure: the counters are not zero after each
mac join abp, right? So, it’s an ever increasing number in TTN Console?
Still worried I’m missing something, but yes, its couting up fine - if you start teamviewer you can have a look if you like ?
Actually my first point about the first transmission not working is incorrect - it does. I think I was testing too fast and getting blocked in some way. If I wait a minute between actions it all works first time round.
I believe you If you’re in doubt it’s really powered off, then maybe you can try without the
mac join abp…?
Already did - and it fails. I will try to get to the bottom of this and let you know, now its time for my low power mode to kick in, the alarm goes at 6.00 tomorrow morning
FYI … in my experience with the RN2903, mac join abp always succeeds. I’m not sure anything gets sent by the radio at all.