0
\$\begingroup\$

I'm trying to build a smart scale using this ESP32, which is connected to a HX-711 amplifier + load-cell. It's also connected to an HC-12 RF communication sensor.

Here are pictures of my setup: https://i.sstatic.net/jrxtf.jpg

The purpose of this device is to measure weight changes and transmit the current weight to a distance device using the RF sensor.

No need for Wifi or Bluetooth on this board.

The problem is that this device should be wireless, and the batteries are getting drained in a couple of days at best, and I'm kind of helpless at the moment.

I went down to take weight measurements every 8 hours, and during those 8 hours I'm putting my ESP32 into a hibernation mode which should be the best one for battery consumption saving, but that also doesn't help.

I started to think that the ESP32 is not meant for this assignment and that maybe there's a better alternative board that might do the job and keep the battery alive for a few weeks/months instead of a couple of days.

Can anybody recommend a different board, or maybe suggest what else can I do to make this circuit run without draining in a couple of days?

As mentioned, I do not need the Wifi and Bluetooth, and mainly using the ESP32 due to its deep-sleep/hibernation mode.

I'll also add the main parts of my code, maybe the problem is there:

#include <WiFi.h>
#include "esp_sleep.h"
#include <Arduino.h>
#include "HX711.h"

const int LOADCELL_DOUT_PIN = 22;
const int LOADCELL_SCK_PIN = 23;

HX711 scale;

int currentWeight = 0;
int previousWeight = -100;

uint64_t TIME_TO_SLEEP = 60*60*8;
#define uS_TO_S_FACTOR 1000000ull

void setup() {
  WiFi.mode(WIFI_OFF);
  WiFi.disconnect();
  btStop();
  rfSetup();
  weightSetup();
  delay(1000);
}

void loop() {
  weightLoop();
  delay(2000);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH,   ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_OFF);
  esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL,         ESP_PD_OPTION_OFF);

  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);
  esp_deep_sleep_start();
  delay(1000);
}

void weightSetup() {
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale(173.90393);
}

void weightLoop() {
  scale.power_up();
  currentWeight = (scale.get_units());
  delay(1000);
  scale.power_down();
  sendWeightToHub(currentWeight);
}

void rfSetup() {
  HC12.begin(BUED);
}

void sendWeightToHub(int newWeight) {
  HC12.write(String(newWeight).c_str());
}

Last thing - When I check the current in the multimeter the current - I get 0.01 (out of 20mA) when sleeping, and up to 0.05 (again, out of 20mA) when awake. That doesn't add up to draining the battery in 2 days though, so I guess I did something wrong there.

Any suggestions?

\$\endgroup\$
18
  • 1
    \$\begingroup\$ Your current measurement description is a little confusing - please update with correct values using units. Also please provide the mAh rating of your battery. The ESP32 should absolutely be sufficient for this project, but you may not be optimizing it perfectly. Also be aware that different DEV boards can reach lower deep sleep currents, so your specific board may be the wrong one for the job. \$\endgroup\$
    – InBedded16
    Commented Apr 28, 2023 at 15:04
  • \$\begingroup\$ Hey, thank you for the fast response @InBedded16. I'm kind of new to this area, and learning as I go, so I'm not too familiar with all the terms and methods. That being said, when connecting the circuit to the multimeter, and setting the multimeter to 20mA, I can see in sleep mode a value of 0.01, and when it measures and communicate via RF, it peeks up to 0.05 for about 10 seconds. The battery I'm using has the number of 18650, which according to the web should have 1800mAh: batteryspace.com/…, is there a way to measure it? \$\endgroup\$
    – Avi Levin
    Commented Apr 28, 2023 at 16:24
  • \$\begingroup\$ Since you wrote that the board seems to be a good fit for that project, the only variable that is still puzzling to me is the battery. Would love to get a feedback and improvements suggestions, and an advice on which batteries will work the best for this kind of project. Regarding the board itself - I attached a link to the exact board I'm using at the top of the post. are there any other types of esp32 that might be better for that matter? \$\endgroup\$
    – Avi Levin
    Commented Apr 28, 2023 at 16:39
  • \$\begingroup\$ You do not write how do you know that the LiFePO4 cell is empty. The voltage curve is very flat. Normally you use the cell only between 20 and 90%, this means between 3.23V and 3.33V. Link: footprinthero.com/lifepo4-battery-voltage-charts (under the headline "3.2V LiFePO4 Cell Voltage Chart") (1800mAh/10mA)/24h = 7.5 days if you use the full capacity. 5.25 Days if you use only 70%. \$\endgroup\$
    – MikroPower
    Commented Apr 28, 2023 at 17:12
  • 1
    \$\begingroup\$ Ok @EdinFifić you should now be able to see all the images of my circuit as well, all in this link: imgur.com/a/OR3dPeI So there's the circuit, the battery image and the code, I gave everything I have :) I'm sorry I don't have a diagram but as I mentioned I'm a fresh beginner so I'm not too organized unfortunately. \$\endgroup\$
    – Avi Levin
    Commented Apr 28, 2023 at 21:07

2 Answers 2

1
\$\begingroup\$

First, 18650 is not LIFePO4 battery as you mentioned in your post title, it is Li-ion battery, with nominal voltage of 3.7V, and max charge-up voltage of 4.2v, cut-off voltage at about 2.5V.

Secondly, your board is not designed for battery operation, if the product image you show matched your actual board, the AMS1117 regulator on the board has a very high Quiescent Current of 5mA, and 1.1V dropout voltage. The board also has power LED that is constant On (and likely consumed 1.5-2mA constantly) even during sleep mode, so the current consumption at the deep sleep is likely 6.5-7mA. The high dropout voltage also means that even if your battery is fully charged at 4.2V, with high dropout voltage of 1.1V across the regulator, it will only barely able to output 4.2-1.1=3.1V instead of regulated 3.3V, the ESP32 will probably brown-out at about 3.0V, plus the high leakage current and PWR LED, and a questionable battery, it simply barely work for a while.

Get an ESP32 board that is designed for battery operation, both Adafruit and SparkFun have boards designed for battery operation, so is China's DFRobot.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you so much for the detailed information @hcheung! It makes a lot of sense, and I will certainly check out the boards you suggested. I also had doubts about the battery, but the guy at the store said it's LIFePO4 and I'm not too much of an expert so I followed what he said... May I ask what battery would you recommend me to use for those boards and code? \$\endgroup\$
    – Avi Levin
    Commented Apr 29, 2023 at 10:08
  • \$\begingroup\$ Hmmmm, I'd say "one that's not fake" lol \$\endgroup\$
    – bobflux
    Commented Apr 29, 2023 at 12:50
0
\$\begingroup\$

Besides what hcheung said,

I do not need the Wifi and Bluetooth, and mainly using the esp32 due to its deep-sleep/Hibernation mode.

Then why use ESP32? There are many other microcontrollers that can do what you need, for example STM32 or one of the Arduinos. One of the problems with ESP32 is that the sleep mode with RAM retention is quite power-hungry compared to other micros, and the deep sleep loses RAM so you have to reboot it, which also uses quite a lot of energy.

You would need to be careful about picking a micro and read the fine print on sleep modes if you were running it on a coin cell. But for a 18650, pretty much any micro with a RAM retention sleep mode will do the trick. Ironically, the ESP32 is one of the few that won't work well, because its light sleep mode with RAM retention uses 800µA, whereas most micros will use a couple µA or less.

I was about to recommend Raspberry Pi Pico because it has a buck boost converter which is nice to have when running on battery, but its sleep current is 180µA which is quite high too.

If you want to run from a 18650 and not bother with a buck-boost converter, using a 3V3 LDO will give 3V3 when it is fully charged, dropping to a bit lower than 3V when it is close to discharged. So...

HX711 is specified to run on 2.7V minimum. For micros, most STM32 M0 will run down to 2V, 8-bit AVR runs down to less than 2V if you run it at 4MHz, so it's fine. You don't need a high power micro like ESP32 to measure a weight and transmit it.

The RF module will probably need more, but perhaps you can replace the LDO with a lower dropout one.

So I'd suggest changing the micro, and if possible using parts that can run on the battery voltage directly, or using a 3V3 LDO and parts that will tolerate voltage drop down to 3V.

\$\endgroup\$
1
  • \$\begingroup\$ Great points @bobflux. thank you very much for the detailed and helpfull response as well. I'm looking for the right micro right now, according to the answers I got here so far. Regarding the battery, I'm not sure I want to use this 18650 battery, I got some recommendations above on better alternatives so I might try those, but if you also have a recommendation for a battery that might fit this project, I would love to hear about it. Thanks again! \$\endgroup\$
    – Avi Levin
    Commented Apr 29, 2023 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.