I have 3 Moteino R6s with +5v LDOs (i.e., not the 3.3v 8MHz version) that have weather shields with BME280 sensors incorporated. Two of these are powered by a small solar cell and a supercapacitor, very similar to what Felix describes here: https://lowpowerlab.com/2017/09/15/weathershield-supercapacitor-tiny-solar-cell/. One of these Moteinos/BME280 sensors hangs every few _months_, while the other two have been running for "years" (most recent START is 615d5h according to the Gateway app). The hangs are definitely rare, but _seem_ to occur more often during the winter on the sensor where I have this problem. Winter lowest temps where I live range between 0*C and 4*C. From just looking at the code I speculated that the BME280 sensor was failing to respond to one or more I2C commands so I added a watch dog timeout (WDT) around the BME280 I2C transactions code and if the WDT expires I do a restart. Five months later the same node hung again.
Obviously debugging using a serial console is a no go. Perhaps I could put my WDT around more code after the Moteino performs a WAKEUP from a low power sleep. I don't have much experience with WDTs and don't know if it is feasible to recover from the I2C bus hang anyway. Heck, maybe it's the RF69WC radio that's hanging and the BME280 sensor is just fine and instead I need a WDT around all the SPI transactions.
That's why I reaching out for help on the forum. Perhaps my expectations are just unreasonable and I should just be happy power-cyclying my weather shields every few months, or I should set up an alert for me to go do a power-cycle if there's been no update in XX days.
So... Trying to benefit from collective wisdom here. Should I strive for "years of uptime" or concede to "reboot every few months"?
Connect the BME sensor you suspect to create problems to one of the other Moteinos and see if it still hangs.
If powered by a small solar cell, during *winter* months, I would first suspect a brownout.
I would monitor the voltage, which should verify if this theory is correct.
Depending what your code does when it first powers up (say after a BOD event) I would be conservative with the transmit power of the radio or spending too much MCU time in active mode. That may help keeping a weak power supply more stable and make it easier for the supercap to provide the power.
Possibly a brownout. I recall looking at the plot of voltage readings and they didn't trigger a concern. But I'm used to the discharge curve for batteries and not capacitors. I'll wait until the end of a sunny day and then unplug the solar cell and watch what happens and how long the station runs for. I'm essentially running the stock Examples/WeatherStation code.
OK. My WeatherMote has been running >74 hrs on just the charge stored in a 7.5F supercapacitor. Very impressive! Vcc is down to 3.41V now so I don't expect it to run much longer. Discharge curve after disconnecting the solar cell shows a steady linear decay (see attachment). Based on this data I'm thinking that a low-voltage brownout is not causing my issue (because even in the middle of winter in central California the sun shines at least some of the time most days) and that it's either a "random" hardware glitch with my particular components (radio or BME280), or it's a temperature-related hardware glitch. Again, these hangs only occur every few months.
Does anyone know if the WDT on the ATmega328 can restart the CPU if it's stuck in the middle of a SPI or IC2 bus transaction? Or, better yet, can someone point me to a forum post(s) that discuss use of the WDT?
I think you mean BOD (brown out detector). That is set to 2.7v on Moteinos by default.
I would check the datasheet on the BOD (https://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-7810-Automotive-Microcontrollers-ATmega328P_Datasheet.pdf), it has the most accurate information.
The WDT is a timer and is typically used to wake the device from sleep or make sure the device does not completely hang due to things like poor code, infinite loops etc (ie provide a means to reset it and come out of a locked condition).
I guess I wasn't clear in my previous post -- sorry. I don't believe a low supply voltage situation is occurring. My Vcc is almost always 4.5v or more, and usually 4.95v. My recent testing was to see how low it could go and still keep running my weather node. The node doesn't stop running until Vcc reaches 4.3v after ~3 days. So I don't believe the BOD is triggering.
And I'm not using the WDT to wake from sleep, but rather to reset the MCU if a bus transaction with the BME280 or the RFM69 radio hangs. I enable a 2 second WDT in loop() before I take readings from the BME280 and I disable it after I've sent the readings to the gateway node. (The WDT is also used by the LowPower library during calls to powerDown(), but I'm done using the WDT for my purposes by then and so there's no conflict.)
I recently made a small change to my WDT code to disable it in setup(), as advised in the ATmega328p data sheet. If I still get hangs, I'll try what @Kylix suggests and swap BME280 sensors for one known to be good. But this will involve some disassembly of my nodes, so I've been reluctant to do it until now. And, again, these hangs only occur relatively rarely, so troubleshooting is very much a wait-and-see proposition.
One thing to keep in mind is that the Moteinos have an LDO with a dropout voltage, and so it's needed to keep that VIN at least 3.55-3.6v to avoid BOD issues.
As the datasheet says, there is no reason that the MCU does not do what it was asked, while the voltages are above the BOD, unless what it is asked is wrong, ie bad code/libraries, and that's not uncommon :-)
My two bits. Is there an AMP/Current flow issue in the cold. Maybe insulation issue or moisture inside the wire or connector? I had an issue with a 9V button. The user had nicked the insulated wire causing outside moisture to get inside the wire and in the cold months things wouldn't work very well. I know my issue was bigger voltage and more amps/current flow that what you have. A solution might be to wrap the wire or get a higher quality insulated wire? Just a thought.