A Connected Hive
A Connected Hive
A Connected Hive
A Connected Hive
by UnCanard
A connected hive is a type of bee hive that uses technology to monitor the health and behavior of the bees inside. This is
done through the use of sensors and other devices that are placed inside the hive.
The sensors are able to collect data on a variety of factors, such as the temperature inside the hive, the amount of honey
being produced, and the activity levels of the bees. This data is then sent to a central database, where it can be analyzed
by beekeepers and researchers.
One of the main bene ts of a connected hive is that it allows beekeepers to monitor the health of their bees in real time.
This can help them to identify problems early on and take action to address them, which can improve the overall health
of the hive.
Additionally, the data collected by connected hives can be used to study the behavior of bees and better understand
how they function. This can help researchers to develop new strategies for improving bee health and supporting the
growth of healthy populations of bees.
Overall, connected hives o er a new way of studying and caring for bees, and they have the potential to revolutionize
the way we manage these important pollinators.
Supplies:
Software
We will use an arduino MKR WAN 1310 to send all the data from our sensors. It will use the lora network to send the
values, this network allows to send data at long distance but with a very low ow. This network is very used in the world
of IOT.
First we need to creat a account on the things network.
The Things Network is a community network based on LoRa technology that complies with the LoRaWAN standard. This
technology allows objects to transmit small amounts of information while consuming very little energy. The community
deploys gateways connected to the Internet.
1. Create an account on TTN
2. Create an application
3. Registering a Device
bool connected;
int err_count;
int con;
short value1, value2, value3 = 3; // data to send
void setup() {
//Initialisaion Lora
modem.begin(EU868);
}
void loop() {
if ( !connected ) {
int ret=modem.joinOTAA(appEui, appKey);
if ( ret ) {
connected=true;
modem.minPollInterval(60);
Serial.println("Connected");
modem.dataRate(5); // switch to SF7
delay(100); // because ... more stable
err_count=0;
}
}
con++;
Serial.print("Join test : ");
Serial.println(con);
if ( connected ) {
int err=0;
/*Envoie des valeurs*/
modem.beginPacket();
modem.write(value1);
modem.write(value2);
modem.write(value3);
err = modem.endPacket(true); //Send packet
/*confirmation of transmission*/
if ( err <= 0 ) {
// Confirmation not received - jam or coverage fault
err_count++;
if ( err_count > 50 ) {
connected = false;
}
// wait for 2min for duty cycle with SF12 - 1.5s frame
for ( int i = 0 ; i < 120 ; i++ ) {
delay(1000);
}
} else {
err_count = 0;
}
}
}
The set of pictures shows how to connect the components. Moreover, with the general connection diagram, you can see
how to put the switch, the resistors and the Lipo Rider
We assemble the measuring gauge with two metal structures. This set will be placed under the beehive to measure its
weight.
A Connected Hive: Page 3
We connect the measuring gauge with the X711 Grove 101020712 ampli er.
#define PIN 6
#define DHTTTYPE DHT22
void setup() {
dht.begin();
}
void loop(){
/*reading data from the sensor*/
Serial.println(dht.readTemperature());
Serial.println(dht.readHumidity());
}
Waterproof DS18B20
// Sensor of the temperature DS18B20
uint8_t address_DS18B20[8];
DS18B20 ds(3);
int nbrCapteurTempDS18B20 = 2;
float tabTempDS18B20[2]; // one wire sensor table
void setup() {
}
void loop(){
tempDS18B20();
for(int i = 0; i < nbrCapteurTempDS18B20; i++){
Serial.println(tabTempDS18B20[i]); //reading the value of the component i
}
}
void tempDS18B20(void){
int j = 0;
for(int i = 0; i < 2; i++){
tabTempDS18B20[nbrCapteurTempDS18B20] = -1;
}
while(ds.selectNext()){
ds.getAddress(address_DS18B20);
Serial.print("Address:");
#include <HX711.h>
void setup() {
//Initialisation of the sensor of the weight
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
}
void loop(){
Serial.println(poids()); //reading the value
}
Accu Li-Ion 3,7 V 1050 mAh PR474446 + Lipo Rider Pro + Cellule solaire SOL2W
We have added a LipoRider board to power our arduine board. It manages the battery management, we can connect a
solar panel to it.
To save energy, I use our system in deep sleep mode. The autonomy increases from a few days to more than a month.
//Low power mode in Arduino
#include "ArduinoLowPower.h"
void loop(){
/*
main program
*/
After connecting all our sensors and nishing our prototype on the breadboard we can develop its PCB.
First you need to install Kikad to draw your own card. If you want a share my prototype of PCB here.
A Connected Hive: Page 9
At the end you can print on your on drill or you can use a drilling company like pcbway.
Now we need to send all our measurements to beep so that they can be recorded and displayed on several graphs. To do
that we need to implement each block in blue of the rst attached diagram.
I) The rst block is used to
Convert our binary frame to an integer.
1. Go to TTN
2. Go to your application -> endDivices -> payload-formatters -> uplink
3. Set "Formatter type" to: "Custom Javascript formatter"
4. Follow the names of the variables given by beep
5. We'll see later where to nd it but it's the key to our beep hive
6. Creat Payload formater
function decodeUplink(input) {
var decoded = {};
decoded.key ="0sd6rz7kll3zcq0s";
return {
data: decoded,
};
}
II) The second block is used to format the data sent by TTN to format them for beep. (Normally bepp understands TTN
frames but I couldn't get it to work).
1. On a server of your choice (AZUR, AWS) create a REST API which has as URI serverAdress/ttnToBeep
2. Add formatter
3. Recover only the "decoded_payload"
4. function format(message){return message.uplink_message.decoded_payload;}
5. Add a weebhook on TTN
6. Go to application -> Integrations -> Weebhooks
7. Click on "Add custom webhook"
8. Give a Weebhook ID to your weeb hook ex: beep
9. In "Base URL" add the endpoint of your server
10. Tick uplick message to POST data when the device send datas
11. You need Bearer Token nous pour nous identi er nous allons voir dans la partie III.2 comment le récuprer.
12. When the message is received, make a POST request to "https://api.beep.nl/api/lora_sensors?
key=0sd6rz7kll3zcq0s"
13. with the key parameter that we added to the TTN payload formatter. More information here
Step 7: Integration