QC

Hive monitoring and monitoring

Add sensors to a hive to track the lives of bees.

Devices and components

Arduino-Nano

DS18B20 Programmable Resolution 1-Wire Digital Thermometer

DHT22 temperature sensor

Materials and tools

load cell bar

Project description

Introduction

bee health,

honey production,

bee swarming

control of winter supplies

diseases

influence of pesticides

hive flight,...

Acquisition system

Weight measurement: strain gauge glued to an aluminum bar mounted in bending. Wired half-bridge to avoid temperature variations. The measurement sensitivity is approximately 10 g. Signal digitization carried out using the HX711 module (24-bit analog-to-digital converter)

Temperature measurement: 2 sensors: one inside the hive, the other outside. Measurement using OneWire DS18S20 (accuracy of ±0.5°C, range of -10°C to +85°C) The presence of bee brood can be monitored or not.

Prerequisites

the box should be waterproof, as it will be outside all day and night for a long time.

the power supply is a key parameter, it must be autonomous for a long period (one year), among the solutions we can have a solar panel or sufficient battery power (and optimized consumption).

data transfer to the end user must be wireless and accessible in regions not connected to the Internet, low cost and allow data transfer at regular intervals (e.g. every 2 hours)

Possible additional measures

GPS position of the hive,

Sun light

Estimated at around €100

hive monitoring

arduino

hive monitoring

1//*******************************************
2//
3// Systme eruche installe au Joug
4//
5// S.GOUTTEBROZE (c) 01.2017
6//*******************************************
7
8
9#include "HX711.h"
10#include <OneWire.h>
11#include <DHT.h>;
12
13//Constants
14#define DHTPIN 4 // what pin we're connected to = D2
15#define DHTTYPE DHT22 // DHT 22 (AM2302)
16DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
17
18// DS18S20 Temperature chip i/o
19OneWire ds(2); // on pin 4
20
21
22//Variables
23int chk,cpt;
24float hum; //Stores humidity value
25float temp; //Stores temperature value
26
27
28 // the setup function runs once when you press reset or power the board
29unsigned long Weight = 0;
30unsigned long AverageWeight = 0;
31unsigned long AverageWeightot = 0;
32unsigned long AverageWeightold = 0;
33int ini(0);
34int Clock = 7; //3 on board
35int Dout = 6; //2 on board
36
37
38float poidsD(0);
39
40float Tc_100_A,Tc_100_B;
41byte i;
42byte type_s;
43byte present = 0;
44byte data[12];
45byte addr[8];
46char *msg ;
47
48void lire_scaleD() {
49 //Serial.println("Lire D...");
50 // wait for the chip to become ready
51 while (digitalRead(Dout) == HIGH);
52
53 AverageWeight = 0;
54 for (char j = 0; j<100; j++)
55 {
56 Weight =0;
57 // pulse the clock pin 24 times to read the data
58 for (char i = 0; i<24; i++)
59 {
60 digitalWrite(Clock, HIGH);
61 delayMicroseconds(2);
62 Weight = Weight <<1;
63 if (digitalRead(Dout)==HIGH) Weight++;
64 digitalWrite(Clock, LOW);
65 }
66 // set the channel and the gain factor (A 128) for the next reading using the clock pin (one pulse)
67 digitalWrite(Clock, HIGH);
68 Weight = Weight ^ 0x800000;
69 digitalWrite(Clock, LOW);
70 AverageWeight += Weight;
71 delayMicroseconds(60);
72 }
73 AverageWeight = AverageWeight/100;
74 //Serial.print("PoidsDnew=");
75 //Serial.println(AverageWeight);
76
77}
78
79
80
81void setup() {
82
83 Serial.begin(9600);
84
85 //intialize HX711 "Module 4" SCALE D
86 pinMode(Clock, OUTPUT); // initialize digital pin 4 as an output.(clock)
87
88 digitalWrite(Clock, HIGH);
89 delayMicroseconds(100); //be sure to go into sleep mode if > 60s
90 digitalWrite(Clock, LOW); //exit sleep mode*/
91
92 pinMode(Dout, INPUT); // initialize digital pin 5 as an input.(data Out)
93
94 dht.begin();
95
96 Serial.println("ready");
97
98 ini=1;
99
100 // Initialisation...
101
102 lire_scaleD();
103 //poidsD=AverageWeight*0.8774529-7360044.76;
104 //Serial.println(poidsD);
105
106}
107
108
109void loop() {
110
111
112// Pour les tests sans Bluetooth,
113lecture_data();
114envoi_msg();
115
116// Pause entre 2mesures...
117delay(3000);
118delay(1000);
119// pour 10secondes de dlai
120delay(20000);
121// on ajoute 20sec
122
123delay(90054);
124// on ajoute 90sec --> lecture toutes les 2min
125delay(3000); // ajustement pour atteindre 2min
126
127delay(500);
128
129}
130
131
132void lecture_data() {
133 //Serial.println("Loop Readings:...");
134
135// Temperature #A capteur interne boitier
136 ds.reset();
137 addr[0]=16;
138 addr[1]=71;
139 addr[2]=193;
140 addr[3]=37;
141 addr[4]=1;
142 addr[5]=8;
143 addr[6]=0;
144 addr[7]=200;
145
146 // the first ROM byte indicates which chip
147 switch (addr[0]) {
148 case 0x10:
149 //Serial.println(" Chip = DS18S20"); // or old DS1820
150 type_s = 1;
151 break;
152 case 0x28:
153 //Serial.println(" Chip = DS18B20");
154 type_s = 0;
155 break;
156 case 0x22:
157 //Serial.println(" Chip = DS1822");
158 type_s = 0;
159 break;
160 default:
161 Serial.println("Device is not a DS18x20 family device.");
162 return;
163 }
164 ds.select(addr);
165 ds.write(0x44, 1); // start conversion, with parasite power on at the end
166
167 delay(1000); // maybe 750ms is enough, maybe not
168 // we might do a ds.depower() here, but the reset will take care of it.
169
170 present = ds.reset();
171 ds.select(addr);
172 ds.write(0xBE); // Read Scratchpad
173
174 for ( i = 0; i < 9; i++) { // we need 9 bytes
175 data[i] = ds.read();
176 }
177
178
179 // Convert the data to actual temperature
180 // because the result is a 16 bit signed integer, it should
181 // be stored to an "int16_t" type, which is always 16 bits
182 // even when compiled on a 32 bit processor.
183 int16_t raw = (data[1] << 8) | data[0];
184 if (type_s) {
185 raw = raw << 3; // 9 bit resolution default
186 if (data[7] == 0x10) {
187 // "count remain" gives full 12 bit resolution
188 raw = (raw & 0xFFF0) + 12 - data[6];
189 }
190 } else {
191 byte cfg = (data[4] & 0x60);
192 // at lower res, the low bits are undefined, so let's zero them
193 if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
194 else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
195 else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
196 //// default is 12 bit resolution, 750 ms conversion time
197 }
198 Tc_100_A = (float)raw / 16.0;
199
200
201
202// Temperature #B capteur volant
203 ds.reset();
204 addr[0]=16;
205 addr[1]=228;
206 addr[2]=224;
207 addr[3]=37;
208 addr[4]=1;
209 addr[5]=8;
210 addr[6]=0;
211 addr[7]=248;
212 // the first ROM byte indicates which chip
213 switch (addr[0]) {
214 case 0x10:
215 //Serial.println(" Chip = DS18S20"); // or old DS1820
216 type_s = 1;
217 break;
218 case 0x28:
219 //Serial.println(" Chip = DS18B20");
220 type_s = 0;
221 break;
222 case 0x22:
223 //Serial.println(" Chip = DS1822");
224 type_s = 0;
225 break;
226 default:
227 Serial.println("Device is not a DS18x20 family device.");
228 return;
229 }
230 ds.select(addr);
231 ds.write(0x44, 1); // start conversion, with parasite power on at the end
232
233 delay(1000); // maybe 750ms is enough, maybe not
234 // we might do a ds.depower() here, but the reset will take care of it.
235
236 present = ds.reset();
237 ds.select(addr);
238 ds.write(0xBE); // Read Scratchpad
239
240 for ( i = 0; i < 9; i++) { // we need 9 bytes
241 data[i] = ds.read();
242 }
243
244
245 // Convert the data to actual temperature
246 // because the result is a 16 bit signed integer, it should
247 // be stored to an "int16_t" type, which is always 16 bits
248 // even when compiled on a 32 bit processor.
249 raw = (data[1] << 8) | data[0];
250 if (type_s) {
251 raw = raw << 3; // 9 bit resolution default
252 if (data[7] == 0x10) {
253 // "count remain" gives full 12 bit resolution
254 raw = (raw & 0xFFF0) + 12 - data[6];
255 }
256 } else {
257 byte cfg = (data[4] & 0x60);
258 // at lower res, the low bits are undefined, so let's zero them
259 if (cfg == 0x00) raw = raw & ~7; // 9 bit resolution, 93.75 ms
260 else if (cfg == 0x20) raw = raw & ~3; // 10 bit res, 187.5 ms
261 else if (cfg == 0x40) raw = raw & ~1; // 11 bit res, 375 ms
262 //// default is 12 bit resolution, 750 ms conversion time
263 }
264 Tc_100_B = (float)raw / 16.0;
265
266
267
268
269// Lecture du quatrime module connect sur Digital PIN
270//Serial.print("PoidsD_old=");
271//Serial.println(AverageWeightold);
272lire_scaleD();
273//Serial.print("PoidsDnew=");
274//Serial.println(AverageWeight);
275
276while (AverageWeightold-AverageWeight>5) {
277
278 lire_scaleD();
279 if (ini==1) {
280 AverageWeightold=AverageWeight;
281 ini=0;
282 }
283 AverageWeightold=AverageWeight;
284 //Serial.print(".");
285
286}
287
288 AverageWeightold=AverageWeight;
289 poidsD=AverageWeight*4.6645331632-4605.0-39148787.5+16000.0; // capteur de 200kg
290
291
292
293 //Read data and store it to variables hum and temp from DHT22 on pin #D2
294 hum = dht.readHumidity();
295 temp= dht.readTemperature();
296
297}
298
299void envoi_msg() {
300
301 //Serial.println("envoi ok ");
302 char str_tempa[10];
303 dtostrf(Tc_100_A, 4, 2, str_tempa);
304 char str_tempb[10];
305 dtostrf(Tc_100_B, 4, 2, str_tempb);
306 char str_poids[20];
307 dtostrf(poidsD, 4, 2, str_poids);
308 char str_tempc[10];
309 dtostrf(temp, 4, 2, str_tempc);
310 char str_hum[10];
311 dtostrf(hum, 4, 2, str_hum);
312
313 char message[100];
314
315 sprintf(message, ";GRJ;%s;%s;%s;%s;%s;0.0", str_tempa,str_tempb,str_tempc,str_hum,str_poids);
316 Serial.println(message);
317}
318
319
320
321
322
323
324
325




Note: Content and images are from: https://projecthub.arduino.cc/, with some modifications.
If you want it removed due to copyright reasons, please leave a comment. Thank you.
I want to share this article more widely so that everyone knows about Arduino and your project.

Easy remote control

Remotely control an LED with ease. Devices and components Arduino Nano 33 BLE with headers Box 525 Resistors precision 1% - 17 values Breadb...