Amel yalaouiMélissa HettalNayselBdeiwi181818
Published

Bee-Happy - Connected beehive

A connected hive is the beekeeper's best ally for monitoring bees, making bee monitoring easier and saving the beekeeper time.

BeginnerFull instructions provided2,408
Bee-Happy - Connected beehive

Things used in this project

Hardware components

DS18B20 Programmable Resolution 1-Wire Digital Thermometer
Maxim Integrated DS18B20 Programmable Resolution 1-Wire Digital Thermometer
×3
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×2
Nano 33 BLE Sense
Arduino Nano 33 BLE Sense
×1
SparkFun Load Cell Amplifier - HX711
SparkFun Load Cell Amplifier - HX711
×1
solar panel SOL2W. .
×1
Carte LiPo Rider Pro 106990008
×1
Batterie Li-Ion 3,7V 1050 mAh
×1
Grove Connector
×1
Antenne Sigfox, LoRa et GSM X000016
×1
Sigfox Breakout board BRKWS01
×1

Software apps and online services

Arduino IDE
Arduino IDE
KiCad
KiCad
Ubidots
Ubidots
Sigfox
Sigfox
fritzing

Hand tools and fabrication machines

Bantam Tools Desktop PCB Milling Machine
Bantam Tools Desktop PCB Milling Machine
PCB Holder, Soldering Iron
PCB Holder, Soldering Iron
Solder Wire, Lead Free
Solder Wire, Lead Free
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)
Drill / Driver, Cordless
Drill / Driver, Cordless
Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter
Breadboard, 270 Pin
Breadboard, 270 Pin
Plier, Cutting
Plier, Cutting
3D Printer (generic)
3D Printer (generic)
Servo Motor, Premium Male/Male Jumper Wires
Servo Motor, Premium Male/Male Jumper Wires

Story

Read more

Schematics

Schéma sur labdec

Code

Code

Arduino
#include "DHT.h"

#define MAXIMWIRE_EXTERNAL_PULLUP
#include <MaximWire.h>

#include "HX711.h"

//TEMPERATURE INTERNE
#define PIN_BUS D3
MaximWire::Bus bus(PIN_BUS);
MaximWire::DS18B20 device;
#define PIN_BUS1 D4
MaximWire::Bus bus1(PIN_BUS1);
MaximWire::DS18B20 device1;

//TEMPERATURE EXTERNE
#define DHTPIN 2  // Digital pin connected to the DHT 
#define DHTPIN2 7

DHT dht[] = {
  {DHTPIN, DHT22},
  {DHTPIN2, DHT22},
};

//POIDS
const int LOADCELL_DOUT_PIN = 5;
const int LOADCELL_SCK_PIN = 6;
int zero;
HX711 scale;

//BATTERIE
const int BATTERYPIN = A0;    //pin de la batterie
const float TensionMin = 3.2; //tension min
const float TensionMax = 4.2; //tension max

// PHOTORESISTANCE
int photocellPin = A1; 
int valLum =0; 
float Luminosite;

//BOUTON DE POUSSOIR
int bouton;  
const int led = D8; 

/**     FONCTION BATTERIE      **/
int getBattery ()
{
  int b = analogRead(BATTERYPIN); //valeur analogique
  float Vin,Vbat;
  Vin =(float(b)/1024)*3.3;
  Vbat=Vin*(float(197)/float(150));

  int p = ((Vbat - TensionMin) / (TensionMax - TensionMin)) * 100; //mettre en pourcentage

  if (p > 100) //max is 100%
    p = 100;

  else if (p < 0) //min is 0%
    p = 0;

  Serial.print("Batterie:");
  Serial.println(p); 
  return p;
}


/*  tab[0] => temp_ext , tab[1] => temp_int, tab1[0] => hum_ext,tab1[1] => hum_int  */
/**     FONCTION TEMPERATURE INTERIEUR/EXTERIEUR DHT22      **/
int getTempHum_ext(int* tab,int* tab1,int count){
  float temp[2];
  float hum[2];
  for(int i = 0; i<2; i++){
    temp[i]=dht[i].readTemperature(); 
    hum[i]=dht[i].readHumidity(); 
  }
  count++;
  for(int i=0;i<2;i++){
    tab[i] = round((temp[i]+15)*10);
    tab1[i] = round(hum[i]*10);
  }
    Serial.print("Temperature_ext:"); 
    Serial.println(tab[0]); 
    Serial.print("Humidite_ext:"); 
    Serial.println(tab1[0]); 
    Serial.print("\t"); 

    Serial.print("Temperature_int:"); 
    Serial.println(tab[1]); 
    Serial.print("Humidite_int:"); 
    Serial.println(tab1[1]); 
  return count;
}

/**     FONCTION TEMPERATURE INTERIEUR      **/
void getTemp_int(int* tab,int* tab2){
  MaximWire::Discovery discovery = bus.Discover();
  MaximWire::Discovery discovery1 = bus1.Discover();
  int i = 0; 
  int k=0;
   do {
       MaximWire::Address address;
       if (discovery.FindNextDevice(address)) {
           if (address.GetModelCode() == MaximWire::DS18B20::MODEL_CODE) {
               MaximWire::DS18B20 device(address);
                 float temp = device.GetTemperature<float>(bus);
                 
                 tab[i] = round(temp*10); 
                 Serial.print("temp =");
                 Serial.print(temp);
                 Serial.print(i);
                 Serial.print("*C\t");
                 Serial.println();
                
                 i++; 
                 device.Update(bus);
           } else {
               Serial.println();
           }
       } else {
           Serial.println("NOTHING FOUND");
       }
    } while (discovery.HaveMore());  

   do {
       MaximWire::Address address1;
       if (discovery1.FindNextDevice(address1)) {
           if (address1.GetModelCode() == MaximWire::DS18B20::MODEL_CODE) {
               MaximWire::DS18B20 device1(address1);
                 float temp1 = device1.GetTemperature<float>(bus1);
              
                 tab2[k] = round(temp1*10); // diviser par 20 sur ubidots 
                 
                 Serial.print("temp1 =");
                 Serial.print(temp1);
                 Serial.print("*C\t");
                 Serial.println();
                 k++; 
                 device1.Update(bus1);
           } else {
               Serial.println();
           }
       } else {
           Serial.println("NOTHING FOUND**");
       }
    } while (discovery1.HaveMore());
    }
    
/**     FONCTION POIDS      **/   
int getPoids(int* tab){

  float temp = 0;
  int poids_reel = 0;
  

  for(int i=0;i<10;i++){
    float p = scale.get_units(10);
    Serial.print ("poids:");
    Serial.print(p);
    Serial.println("kg\n");
    tab[i] = round(p*10);
    temp+=tab[i];
  }
  poids_reel = temp/10;
  return poids_reel;
}

/**    FONCTION PHOTORESISTANCE   **/
int photoRes(void){
  
  valLum = analogRead(photocellPin);
  int a = (float(valLum)/1024)*100;
  Serial.print("lum "); 
  Serial.println(a);
  return a;
  
}

void sommeil(){
  scale.power_down();
  digitalWrite(PIN_ENABLE_I2C_PULLUP,LOW); //teindre rsistance de pull-up 
  digitalWrite(PIN_ENABLE_SENSORS_3V3,LOW); //teindre les capteurs
  delay(3000);
  
}

void reveil(){
   scale.power_up();
   delay(5000);

}

void setup() {
  Serial1.begin(9600);
  digitalWrite(LED_PWR,LOW); //teindre la Led 
  dht[0].begin();
  dht[1].begin(); 
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale(28881.84f);
  zero = 132606;
  scale.set_offset(zero);

  pinMode(bouton, INPUT); // Initialise la broche 4 comme entre
  pinMode(led, OUTPUT);   // Initialise la broche 12 comme sortie
}


void loop(){

// si l'on appuie sur le bouton alors le sytme est en marche
if (digitalRead(bouton) == 1){
     digitalWrite(led,HIGH);
     delay(2000);
     digitalWrite(led,LOW);
     
    int bat = 0; 
    
    // variables pour la temprature et humidit externe
    int count=0;
    int temp_extint[2];
    int hum_extint[2];
  
    // variables pour la temprature interne
    int temp_int[3]; 
    int temp_int1[3];
  
    // variable pour le poids 
    int poids[10];
    int poids_reel =0;

    // variable pour les trames 
    int trame[3];
  
    //valable pour photorsistance
    int pRes =0;

    for(int i=0;i<10;i++){
      poids[i] = 0;
    }
  
    for (int j=0;j<3;j++){
      trame[j]=0;
    }
    
    poids_reel=getPoids(poids);
    bat = getBattery(); 
    count = getTempHum_ext(temp_extint,hum_extint,count);
    getTemp_int(temp_int,temp_int1);
    pRes= photoRes();
  
    trame[0]= (temp_extint[0] << 22) | (hum_extint[0] << 12) | (temp_int[0] << 2);
    trame[1] = (temp_int[1] << 22)| (temp_int1[0] << 12)|(poids_reel<<2);
    trame[2] = (hum_extint[1] <<22)|(bat << 12)|(pRes<<2); 
   
  
    if(count < 3){
      Serial1.println("AT$SF="+String((int)trame[0],HEX)+String((int)trame[1],HEX)+String((int)trame[2],HEX));
      Serial.println("AT$SF="+String((int)trame[0],HEX)+String((int)trame[1],HEX)+String((int)trame[2],HEX));
    }
   sommeil();
    delay(15000); 
   reveil();
}
}
  

Credits

Amel yalaoui
1 project • 0 followers
Contact
Mélissa Hettal
1 project • 0 followers
Contact
Naysel
1 project • 0 followers
Contact
Bdeiwi181818
1 project • 0 followers
Contact
Thanks to Team bee happy. .

Comments

Please log in or sign up to comment.