BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Beehive connected


#1

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;
HX711 scale(SCALE_DOUT_PIN, SCALE_SCK_PIN);

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
DHT dht2(DHT2PIN, DHT2TYPE);

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


void getBatterie()
{
   volt = analogRead(A0);
   volt1=volt/233.8;
   Serial.print("Voltage = ");  
   Serial.println(volt1);
}
  
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");
    return;
  }
  Serial.print("Temperature = ");    
  Serial.println(t2);
  Serial.print("Humidity = ");        
  Serial.println(h2);
} 
  
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 = ");  
  Serial.println(weight);
 
}


void setup()
{
  Serial.begin(115200);
  pinMode(A0, INPUT);
  Blynk.begin(auth, ssid, pass);//starts wifi and Blynk
  Serial.println("Connected to Blynk");
  dht2.begin(); // initialize dht22
  scale.set_scale(-6000/0.128);
  //scale.tare();
}


void loop()
{
  delay(4000);
  getBatterie();
  getDht2Data();
  getWeight();
  
  //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.print(wake_time);
  Serial.println(" seconds");
  Blynk.run(); // Needed to ensure that the Wake Time value is always uploaded to Blynk before going to sleep
  delay(100);
  Serial.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Going to sleep");
  Serial.println();
  ESP.deepSleep(2000 * 1000000);  // Deep Sleep for 33mins
  delay(2000);
}

#2

very nice! Well done!