I'm working on a bee hive scale that I would like to run off of an 18650 for a year or more. The scale works but has higher sleep current than it should, drawing about 250 uA, much higher than the 6.5 uA reported on Nick Gammon's brilliant page:
https://www.gammon.com.au/power
My main problem is that I'm not really sure how to debug this issue. Normally I can isolate one part of a circuit, but I can't breadboard the entire circuit out because a lot of the parts are SMD. My next step is to populate the board a bit at a time, but I'm wondering if there are better ways to figure out what is going on?
While this is a general question of how to debug low level current leakage in sleep mode, I've provided as much information about my specifics as I can below in case there is something obvious.
On the hardware side, the scale is controlled by an ATmega328p connected to 6 HX711 load cell amplifiers, with a SSM3J327R P-Channel MOSFET switching a MCP1825S LDO to create a 3.3 V supply line. The switched 3.3 V line turns on an HTU21D temperature and humidity sensor, SFH3710 phototransistor, and RFM95W LoRa module. Logic level shifting is done with BSS138s and 10k resistors as shown here:
The full schematic is attached although it does not include the small HX711 boards which are essentially the HX711 reference schematic connected by a USB-C cable. They don't seem to be the problem because I can unplug all HX711s and the current draw during sleep is the same.
On the software side, sleep is set up essentially per Sketch H in Nick Gammon's power page cited above and the draw during sleep is 600 uA. The pins to the SSM3J327R and HX711 clocks are kept high, which keeps them off. Changing pin 10 (SPI SS) to LOW (INPUT or OUTPUT) right before sleep changes the sleep current to 250 uA. Changing the rest to LOW (other than the two cited above which need to stay high) doesn't drop it further.
Running the script on a breadboard DIP ATmega328p does show the expected single digit uA current draw during sleep, so at least the sleep code and my cheap multimeter are working as should be expected. I've attached the full code in case it is helpful.
My understanding of electronics is decent at the high level (ie a MOSFET is an on/off switch) but is extremely shallow in terms of the real world variations (ie what are the implications of IGSS leakage). Since transistors are sort of black magic to me, my instinct is to assume I don't have those set up right and my current draw is due to the BSS138s not behaving as I expect them to when the 3.3V line is switched off, but I really don't know.
Any help would be appreciated. Thanks to you all.
hive_scale_remote_hub_v2_1.pdf (83.2 KB)
Hive_Scale_v2_Remote.ino (18.2 KB)