Beehive connected


Hello everyone,

I wanted to share my beehive connected project. I want to thank all the people who helped me in the programming. My system is currently being tested out, it allows to measure the weight of my hive, the temperature and the external humidity, the voltage of the battery and the time of wifi connection. 2 small solar panels charge the battery and Deep sleep mode allows me to send the data every 33mins. Currently the weight sensor can weigh max 50Kg but I also have another system that can go up to 200Kg

Future improvement:
Taking temperatures with DS18b20 sensors in the hive, alert when the weight between 2 measurements changes up to 500gr

#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;
float weightCorrection = 3.98; // The weight of the hive to be removed from the result

// 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);
  weight = scale.get_units(1);
  weight = weight-weightCorrection; // The new line, which deducts the correction value from the reading
  Serial.print("Weight = ");  

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

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(2000 * 1000000);  // Deep Sleep for 33mins


very nice! Well done!


Does this code work properly with Blynk?


This may solve the problem with permanent mass on the scale in between power cycles:


Yes the code is working fine since 2 weeks I have a good result with fix weight on it. But i will read your last comment. Thanks


Interesting idea, it would alert if a swarm leave the hive. I am testing the Eventor widget but then I have to keep track of the current weight and adjust it all the time.


Yes exactly, and in fact more focus between noon and 4 pm, it’s where the swarms leave/move out. You also made a hive system connected? me currently I have a problem of duration feeding with my battery. Even with a deep sleep of 30mins my 5000mah battery only takes 2 days … During the deep sleep my ESP8266 consumes 14mah not due to the esp but the rest of the board!!


Yes, right now I’m testing a new off grid solution with a solar panel, 20W and 12V or 5V ( 20W 12V/5V Waterproof Solar Panel Kit ). I use a Wemos D1 mini Pro with external antenna and battery shield. A 18650 Li-ion 3400 mAh battery back up. Everything seems to work pretty well in my indoor test environment so far but we don’t have enough sunlight here this time of the year.

I have a similar system connected since almost a year on another platform. There I can check how the food is consumed and the temperature in, and outside the hive during the winter. Right now the temperature is inside + 23° C and outside of -15° C. The weight of the hive is now 51.8 Kg. It’s 1.6 kg less than a month ago.


Blockchain now saving the world’s bees -


Sounds like a lot of buzzwords to me :smile: