Beehive project issue

Salut Alexis et oui de retour et toujours le même problème…

1 Like

Okay, can you give me a link to the HX711.h library that you’re using, so I understand a bit more about how this works, and which value it is that we need to be saving to SPIFFS or the Blynk server?

Edited to add - can you also post a link to the specific HX711 board that you’re using please.


Since you are using Blynk, send it to the server, populate a Table Widget, generate and send regular reports to email via the Report Widget, or something. Even the SuperChart will work, although you have to watch out for the averaging.

Hi @christophebl, is there any particular reason why you aren’t using the ESP sleep function,

ESP.deepSleep(900e6); //15 min sleep ??

I have added a solar powered ESP chip with temp sensor using 1200mah lipo and 5w 5v solar panel to my Aussie Native Bee Hive. Its still in the testing phase however it seems to be working great. I have added a widget button to keep the ESP awake if I need to OTA code to it and it’ll send me an notification alert if it’s been awake longer than 2 min. I’ve bought the weight sensors as you described…its just matter if getting around to doing that part of the project. Basically my ESP will wake up every 15min and run the code, send the temperature reading and go back to sleep after 30 secs and then repeat.

Salut Christophe,

j’utilise un virtualPin pour sauvegarder et restaurer ma consommation de fuel , avec la fonction BLYNK_CONNECTED()

  if ( FirstStart == 0) {
    Blynk.syncVirtual(V79);//synchro Temps fonctionnement
    Blynk.syncVirtual(V77);//synchro  conso totale en L
    Serial.println("Vsync OK")

I think the issue is with the weight sensors library resetting the weight to zero when the sensors are powered-up.

Imagine using a set of electronic kitchen scales…
You place the scales on the kitchen worktop and hit the On button. They’ll self-calibrate and set themselves to zero.
You then place an object on the scales and they will show you it’s weight.
However, if you then turn the scales Off, then On again with the object still in place they will self-zero and tell you that the object weighs nothing.

Making a note of the weight reading you obtained when first weighing the object, and adding this to the zero reading you get when powering-up the scales with the object in place will tell you the new weight.

However, this only works if the weight of the object remains static. If it’s weight has changed since it was last weighed, the self-zeroing function will still tell you that it weight is zero, but you wont know the actual weight that you need to add to this.

The solution needs to be to prevent the HX711 load cell amplifier from doing a self calibration (Tare) function when it’s powered-up, or possibly keeping the HX711 powered constantly.


Hi Pete,

I used this one :

But there is no possibility to use the ModemSleep mode of the ESP under Blynk? I tried a lot of examples that I could find here but without a good result

that’s exactly what’s going on and you’re absolutely right, as soon as the sensor or the ESP goes it recalibrates itself. after that is why I wanted to use the ModemSLEEP mode so that the CPU remains in operation.
May thanks again for the time you used for me :slight_smile:

And which HX711 board are you using?

I started playing with this yesterday and it seemed to work, but I was getting some strange results when trying to measure the Wi-Fi sleep current. It turns-out that my USB power meter isn’t working properly, so I need to use a proper multimeter and power the ESP differently to check what’s happening.


At the begining I put a picture of my HX711 board.

Can you share me the code? :).

This code was working last time, I get it from Alexis_Cabrera

define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

extern "C" {
  #include "user_interface.h"

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "**************";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Livebox-667E";
char pass[] = "****";

#include <Arduino.h>

BlynkTimer timer;

 void setup() 
  Blynk.begin(auth, ssid, pass);
  timer.setInterval(120000L, SleepFunction); 


void SleepFunction() {
    Serial.println("very soon disconnect");
    Serial.println("wifi disconnected");
 //   timer.setTimeout(20000L, WakeUpFunction); //Pas de wifi pendant 100s
   Serial.println(" after delay");
   Blynk.begin(auth, ssid, pass);

void loop(){;;

I already used this mode (Deepsleep) and it works very well when I have temperature sensors but with the weight sensor it’s not the same … As Pete explained

I notice that the code you posted on 14th September included this line:

The documentation for the library says that this is a way of resetting the scale to zero, and if this was included in your deep sleep version of the code that you tried then it would always set the weight to zero when it woke-up from deep sleep, as when deep sleep ends it does a re-boot of the ESP device.

Try this version of deep sleep code (without any scale.tare() command and see if it works:

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "***************************";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "********";
char pass[] = "********";

#include <Wire.h>  // Only needed for Arduino 1.6.5 and earlier
#include "SSD1306.h" // alias for `#include "SSD1306Wire.h"`
#include <DHT.h>
#include <HX711.h>

// Capteur de poids setting
const int SCALE_DOUT_PIN = D5;
const int SCALE_SCK_PIN = D6;
float weight;

// Capteur température DHT22
#define DHT2PIN D7     // what pin we're connected to
#define DHT2TYPE DHT22   // DHT 22
float t2;
float h2;

// Initialize DHT sensor for normal 16mhz Arduino

// Voltage batterie
float volt=0;
float volt1=0.00;

void getBatterie()
   volt = analogRead(A0);
   Serial.print("Voltage = ");  
void getDht2Data()
  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  h2 = dht2.readHumidity();
  // Read temperature as Celsius
  t2 = dht2.readTemperature();
  // Check if any reads failed and exit early (to try again).
  if (isnan(h2) || isnan(t2))
    Serial.println("Défault DHT22");
  Serial.print("Temperature = ");    
  Serial.print("Humidity = ");        
void getWeight()
  String weight = String(scale.get_units(1), 2);
  Serial.print("Weight = ");  

void setup()
  pinMode(A0, INPUT);
  Blynk.begin(auth, ssid, pass);//starts wifi and Blynk
  Serial.println("Connected to Blynk");

void loop()
  //Update Blynk with the latest readings...
  Blynk.virtualWrite(V3, volt1);
  Blynk.virtualWrite(V7, t2); //virtual pin V7 DHT22
  Blynk.virtualWrite(V8, h2); // virtual pin V8 DHT22
  Blynk.virtualWrite(V4, weight);
  float wake_time = (float)millis()/float(1000); // Find out how long since the ESP rebooted
  Blynk.virtualWrite(V2, wake_time);  // Wake time
  Serial.print("Wake Time = ");
  Serial.println(" seconds");; // Needed to ensure that the Wake Time value is always uploaded to Blynk before going to sleep
  Serial.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Going to sleep");
  ESP.deepSleep(30 * 1000000);  // Deep Sleep for 30 seconds

You’ll need a connection between the D0 (GPIO16) and RST pins to allow it to wake.

If you have problems re-flashing your ESP after using this code, connect a wire between D3 (GPIO0) and GND while you remove and re-apply the power. This will put it into flash mode and allow you to re-flash it, rather than having it go to sleep all the time.

I’ve added a Blynk.virtualWrite to pin V2, which shows how long the ESP was awake for. If V2 is already in use then you’ll need to change this, and to see the data you’ll need to add a display widget to V2 to see the info in the app.

I find that the first time it connects to Blynk it can take up to 30 seconds, but after that it’s much quicker (usually 1-5 seconds). I think the issue is that the ESP is getting an IP address from the router first time around, then after that the router remembers the IP that it allocated and re-uses this. If you increase the deep sleep time then the router may purge the allocated IP address from its routing table and connection time m,kay go up again. The solution to this is to use a static IP address, either defined in the code or in the routing table of your router. If the weighing bit works okay and retains the reading then we’ll look at this, otherwise we may need to go back to the modem sleep (which will have the same issues with static IP anyway).

Test the code and let me know if it works with the weight issue.


1 Like


Your code working perfectly! after I have to check with the weight. the value I get are very strange.

    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.0 on NodeMCU

[1187] Connecting to
[2413] Ready (ping: 46ms).
Connected to Blynk
Voltage = 0.01
Temperature = 26.50
Humidity = 99.90
Weight = 21097.00
Wake Time = 2.96 seconds
............................................Going to sleep

Many thanks, I will come back to you soon :slight_smile:

Ok now it’s better, I had:
scale.set_scale( -6000 / 0.3095 );
On the setup part
But when the ESP is on deepsleep and I put a load on my sensor I still have 0

When I remove the scale.tare it’s working better but I need to know if the weight I mesure is correct. I will make some test and tell you if it’s working properly :slight_smile:

Have you removed the

line from your code?


Yes sorry I did read correctly the begening of your message. Now I remove it’s but I need to know if it’s correct and I have to find the zero first I think

I think scale.set_scale command is used to give an accurate reading based on weighing a known weight. You may need to deduct a value from your weight variable to get a zero reading. It’s something you’ll need to play around with to give usable results.

In some ways, it’s not really necessary to have a truly accurate result, provided you know that the hive is now x% heavier than it was previously, but a degree of accuracy would be good.

I’d be interested to see your final results.
As I mentioned before, I have a project in mind where I need to be able to monitor the weight of my propane gas bottles at my holiday home in Spain. I want to do this with a battery powered system, and I don’t really need more than one reading every day. This really needs a deep sleep routine, so if you get your weighing code working well it would be exactly what I need.



It’s working perfectly!!! I’m so happy. Now I have to prepare and make all the test on beehive. I will after make a new post to explain all me project!! :slight_smile:

1 Like

Hello Everyone - I have seen similar load cells that I see here on the internet. I was concerned about using them outdoors. Are there any weather proofing actions you are taking?


hi, since 1 month my load cell is outside, I don’t have any trouble :slight_smile:

1 Like