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?