Bees are key pollinating insects for the environment, but they face many dangers that can affect their health and survival. Bees may face:
- Predators: Some species of animals may attack or raid hives in search of food.
- Hive theft: Sometimes beekeepers discover that their hive has been stolen.
- Pesticides: they can be dangerous to bees because they can kill or weaken insects that feed on flowers.
- Environment: They can be affected by a number of environmental factors, such as temperature and humidity fluctuations and air pollution.
It is important to take measures to protect bees and ensure their long-term survival. Therefore, we propose a monitoring system using microcontrollers and sensors can help beekeepers to better understand and protect their beehives.
The system consists of different sensors:
- Humidity/temperature DHT22 x2
- Temperature DS18B20 x2
- Weight HX711 x1
- Light intensity SEN0291 x1
- Sound x1
It is composed of a battery and a solar panel. The device also contains a LiPo Rider Pro card that makes the link between the two components, making it energy self-sufficient.
System SetupSensor
First of all, each component is tested individually in order to verify their proper functioning. To realize this step, a protoboard, microcontroller and a sensor are used. It will be necessary to put the specific code of the sensor in the microcontroller.
The same must be done with all the sensors (DS18B20, HX711, SEN0291). For the connection and testing of these sensors, refer to the component links in the description.
After having tested all of them, we made a general code to have the information of all of it at the same time (ours is in description at the end of the article)
Microphone
In order to study the behavior of the bees, we had to amplify the signal from the microphone. You have to follow the schematic to use the MAX4468 audio amplifier (you can find the document of the component on internet).
You must first test on protoboard and examine the signals on the oscilloscope to verify the proper functioning. However, there can be a lot of noise, which is obvious. So you will have to print the PCB of the audio circuit to get the right results.
Data transmission
Then, the LoRa-E5 module is used to transmit wirelessly the data. This information is sent to a server (TTN) which sends it to a Cloud (Ubidots). The Cloud allows to visualize the data on graphs. To use the module and send data to the server, go to the following link: https://wiki.seeedstudio.com/Grove_LoRa_E5_New_Version/
Finally, to link the TTN server with Ubidots, refer to this link: https://help.ubidots.com/en/articles/5096476-plugins-connect-the-things-stack-to-ubidots
Once on Ubidots, in order to execute our code, we will have to create the different variables and write the code below in the decoder part of the Plugins section.
function format_payload(args){
var ubidots_payload = {};
// Log received data for debugging purposes:
// console.log(JSON.stringify(args));
// Get RSSI and SNR variables using gateways data:
var gateways = args['uplink_message']['rx_metadata'];
for (const i in gateways) {
// Get gateway EUI and name
var gw = gateways[i];
var gw_eui = gw['gateway_ids']['eui'];
var gw_id = gw['gateway_ids']['gateway_id'];
// Build RSSI and SNR variables
ubidots_payload['rssi-' + gw_id] = {
"value": gw['rssi'],
"context": {
"channel_index": gw['channel_index'],
"channel_rssi": gw['channel_rssi'],
"gw_eui": gw_eui,
"gw_id": gw_id,
"uplink_token": gw['uplink_token']
}
}
ubidots_payload['snr-' + gw_id] = gw['snr'];
}
// Get Fcnt and Port variables:
ubidots_payload['f_cnt'] = args['uplink_message']['f_cnt'];
ubidots_payload['f_port'] = args['uplink_message']['f_port'];
// Get uplink's timestamp
ubidots_payload['timestamp'] = new Date(args['uplink_message']['received_at']).getTime();
// If you're already decoding in TTS using payload formatters,
// then uncomment the following line to use "uplink_message.decoded_payload".
// PROTIP: Make sure the incoming decoded payload is an Ubidots-compatible JSON (See https://ubidots.com/docs/hw/#sending-data)
// var decoded_payload = args['uplink_message']['decoded_payload'];
// By default, this plugin uses "uplink_message.frm_payload" and sends it to the decoding function "decodeUplink".
// For more vendor-specific decoders, check out https://github.com/TheThingsNetwork/lorawan-devices/tree/master/vendor
let bytes = Buffer.from(args['uplink_message']['frm_payload'], 'base64');
var decoded_payload = decodeUplink(bytes)['data'];
// Merge decoded payload into Ubidots payload
Object.assign(ubidots_payload, decoded_payload);
return ubidots_payload
}
function decodeUplink(bytes) {
// Decoder for the RAK1906 WisBlock Environmental Sensor (https://store.rakwireless.com/products/rak1906-bme680-environment-sensor)
var decoded = {};
//if (bytes[0] == 1) {
// If received data is of Environment Monitoring type
decoded.temperature = (bytes[0]<<8|bytes[1])/10 ;
decoded.humidity = (bytes[2]<<8|bytes[3]) ;
decoded.temp1 = (bytes[4]<<8|bytes[5])/10;
decoded.temp2 = (bytes[6]<<8|bytes[7])/10;
decoded.poids = (bytes[8]<<8|bytes[9])/100;
decoded.battery=(bytes[10]<<8|bytes[11])/100;
decoded.luminosity=bytes[12]<<8|bytes[13];
return {"data": decoded};
}
module.exports = { format_payload };
Don't forget to replace the values of AppEUI, DevEUI and AppKey from our code with yours that you put on TTN.
if(at_send_check_response("+AT: OK", 100, "AT\r\n")){
is_exist = true;
at_send_check_response("+ID: AppEui", 1000, "AT+ID\r\n");
at_send_check_response("+MODE: LWOTAA", 1000, "AT+MODE=LWOTAA\r\n");
at_send_check_response("+DR: EU868", 1000, "AT+DR=EU868\r\n");
at_send_check_response("+CH: NUM", 1000, "AT+CH=NUM,0-2\r\n");
at_send_check_response("+KEY: APPKEY", 1000, "AT+KEY=APPKEY,\"E2615C4277914656365B2A0F5F012047\"\r\n"); CHANGER HERE
at_send_check_response("+ID: DEVEUI", 1000, "AT+ID=DEVEUI,\"ABCDEF123456789A\"\r\n"); CHANGE HERE
at_send_check_response("+ID: APPEUI", 1000, "AT+ID=APPEUI,\"0000000000000000\"\r\n"); CHANGE HERE
at_send_check_response("+CLASS: C", 1000, "AT+CLASS=A\r\n");
ret=at_send_check_response("+PORT: 9", 1000, "AT+PORT=9\r\n");
delay(200);
is_join = true;
Check that the pins assigned in the code are the same as those physically assigned to the microcontroller. Everything is ready! The system is functional and can be launched.
ImprovementTo make the system more compact, wire-free and to avoid noise, we replaced the protoboard with a PCB circuit from the KiCad software. First there is a PCB for the audio with the audio amplifier.
Now create the schematic and the footprint in KiCad so you can print it.
After printing the PCB, you have to solder the components (the audio amplifier, the resistors, the capacitors) on the PCB taking care to choose the right values of resistors and capacitors.
Then you have to create the final PCB which will contain the Arduino board and the connectors to link all the sensors.
Then we make our system waterproof to protect it from weather conditions. All modules or sensors were placed in a waterproof box. The sensors were extended with cables to be placed in/on the hive.
The box is functional and just needs to be tested!
We decided to post our results on another Cloud, Beep. Here are the results we get.
You can find here our project presentation video.
Comments