No, this is not a commercial offer, such is the cost of the component parts of the system, which you can assemble after reading the article.
A little background:
Some time ago I decided to start bees, and they did appear ... for the whole season, but did not come out of wintering.
And this is despite the fact that everything seemed to be doing the right thing - autumn complementary foods, warming before the cold.
The hive was a classic wooden system "Dadan" on 10 frames of 40 mm boards.
But that winter, because of the temperature "swings", even experienced beekeepers lost much more than usual.
So came the idea of ​​a hive condition monitoring system.
After the publication of several articles on Habr-e and communication on the forum of beekeepers, I decided to go from simple to complex.
Weight is the only indisputable parameter, but as a rule, existing systems monitor only one "reference" hive.
If something goes wrong with him (for example, the departure of a swarm, the disease of bees), then the indicators become irrelevant.
Therefore, it was decided to follow the weight change of three beehives at once with one microcontroller, and add other “buns” after.
The result was an autonomous system with an operating time of about a month on a single charge of 18650 battery and sending statistics once a day.
He tried to simplify the construction as much as possible, so that it could be repeated even without diagrams, using only one photo.
The logic of operation is the following: when you first start / reset, the readings of sensors installed under the hives are stored in the EEPROM.
Then, every day, after dusk, the system “wakes up”, reads the readings and sends SMS with the weight change for the day and from the moment of switching on.
In addition, the voltage value of the battery is transmitted, and when it drops to 3.5V, a warning about the need for charging is given, because below 3.4V the communication module does not turn on, and the weight readings are already “floating”.
"Do you remember how it all began. Everything was for the first time and again."
Yes, it was such a set of "hardware" that was originally, though only strain gauges and wires survived to the final version, but first things first.
In fact, the bay cable is not needed, it just turned out to be at the same price as the 30m flatly.
If Vac is not afraid of dismantling 3 smd-LEDs and half a hundred points of ordinary (lead-out) soldering - then go!
So, we need the following set of equipment / materials:
The battery can be taken from the disassembly of laptops - at times cheaper than the new one, and the capacity will be much more than that of the Chinese UltraFire - I got 1500 versus 450 (this is from the 6800 firewall ;-)
In addition, you will need uncured hands, soldering iron EPSN-25, rosin and solder POS-60.
5 years ago I used a Soviet soldering iron with a copper tip (I didn’t send me a soldering station - I took it for a test drive and finished the EPSN circuit).
But after his failure and several Chinese monstrous under (e) trees, the latter had the name Sparta - a thing as harsh as the name stopped
on the product with a thermostat.
So let's go!
To begin with, we evaporate two LEDs from the GSM module (the place where they were circled in an orange oval)
Sim-krtu insert contact pads to the printed circuit board, beveled corner on the photo is indicated by the arrow.
Then we perform the same procedure with the LED on the Arduino board (the oval to the left of the square chip),
Solder the comb to the four contacts (1),
We take two resistors for 20k, twist the pins on one side, solder the twist to the A5 pin hole, the remaining pins in RAW and GND of ardukin (2),
The photoresistor shortens the legs to 10mm and solders it to the GND and D2 terminals of the board (3).
Now it's time blue electrical tape double-sided tape - sticking it on the SIM card holder of the communication module, and on top - arduino - a red (silver) button facing us and located above the sim card.
Solder power: plus from the capacitor of the communication module (4) to the RAW arduino contact.
The fact is that the communication module itself requires 3.4-4.2V for its power supply, and its PWR contact is wired to a step-down downconverter, therefore, to operate from li-ion, the voltage must be bypassed bypassing this part of the circuit.
In Arduino, on the contrary, we power up through a linear converter - at low current consumption, the drop-out voltage drop is 0.1V.
On the other hand, by applying a stabilized voltage to the HX711 modules, we eliminate the need to modify them at a lower voltage (and, at the same time, from an increase in noise as a result of this operation).
Then we solder the jumpers (5) between the PWR-A1, URX-D4 and UTX-D5 pins, GND-G ground (6) and finally the power from the 18650 battery holder (7), connect the antenna (8).
Now we take a USB-TTL converter and wire Dupont with ARDUINO (comb 1), contacts RXD-TXD and TXD-RXD, GND-GND:
The photo above is the first version (of three) of the system used for debugging.
And now we will for some time digress from the soldering iron, and move on to the program part.
I will describe the sequence of actions for Windows:
First, you need to download and install / unzip the Arduino IDE program - the current version is 1.8.9, but I use 1.6.4
For simplicity, unpack the archive in the folder C: \ arduino- "number_Your_version", inside we will have the folder / dist, drivers, examples, hardware, java, lib, libraries, reference, tools, as well as the arduino executable file (among others).
Now we need a library to work with the HX711 ADC - green button "clone or download" - download ZIP.
Content (folder HX711-master) is placed in the directory C: \ arduino- "number_Your_version" \ libraries
Well, of course, the same driver for USB-TTL from the same github - from the unpacked archive, simply start the installer with the SETUP file.
Ok, we launch and configure the program C: \ arduino- "number_Your_version" \ arduino
Go to "Tools" - select the "Arduino Pro or Pro Mini" board, Atmega 328 3.3V 8 MHz processor, port - number except for system COM1 (it appears after installing the CH340 driver with a USB-TTL adapter connected)
Ok, copy the following sketch (program), and paste it into the Arduino IDE window
char phone_no[]="+123456789012"; // Your phone number that receive SMS with counry code #include <avr/sleep.h> // ARDUINO sleep mode library #include <SoftwareSerial.h> // Sofrware serial library #include "HX711.h" // HX711 lib. https://github.com/bogde/HX711 #include <EEPROM.h> // EEPROM lib. HX711 scale0(10, 14); HX711 scale1(11, 14); HX711 scale2(12, 14); #define SENSORCNT 3 HX711 *scale[SENSORCNT]; SoftwareSerial mySerial(5, 4); // Set I/O-port TXD, RXD of GSM-shield byte pin2sleep=15; // Set powerON/OFF pin float delta00; // delta weight from start float delta10; float delta20; float delta01; // delta weight from yesterday float delta11; float delta21; float raw00; //raw data from sensors on first start float raw10; float raw20; float raw01; //raw data from sensors on yesterday float raw11; float raw21; float raw02; //actual raw data from sensors float raw12; float raw22; word calibrate0=20880; //calibration factor for each sensor word calibrate1=20880; word calibrate2=20880; word daynum=0; //numbers of day after start int notsunset=0; boolean setZero=false; float readVcc() { // Read battery voltage function long result1000; float rvcc; result1000 = analogRead(A5); rvcc=result1000; rvcc=6.6*rvcc/1023; return rvcc; } void setup() { // Setup part run once, at start pinMode(13, OUTPUT); // Led pin init pinMode(2, INPUT_PULLUP); // Set pullup voltage Serial.begin(9600); mySerial.begin(115200); // Open Software Serial port to work with GSM-shield pinMode(pin2sleep, OUTPUT);// Itit ON/OFF pin for GSM digitalWrite(pin2sleep, LOW); // Turn ON modem delay(16000); // Wait for its boot scale[0] = &scale0; //init scale scale[1] = &scale1; scale[2] = &scale2; scale0.set_scale(); scale1.set_scale(); scale2.set_scale(); delay(200); setZero=digitalRead(2); if (EEPROM.read(500)==EEPROM.read(501) || setZero) // first boot/reset with hiding photoresistor //if (setZero) { raw00=scale0.get_units(16); //read data from scales raw10=scale1.get_units(16); raw20=scale2.get_units(16); EEPROM.put(500, raw00); //write data to eeprom EEPROM.put(504, raw10); EEPROM.put(508, raw20); for (int i = 0; i <= 24; i++) { //blinking LED13 on reset/first boot digitalWrite(13, HIGH); delay(500); digitalWrite(13, LOW); delay(500); } } else { EEPROM.get(500, raw00); // read data from eeprom after battery change EEPROM.get(504, raw10); EEPROM.get(508, raw20); digitalWrite(13, HIGH); // turn on LED 13 on 12sec. delay(12000); digitalWrite(13, LOW); } delay(200); // Test SMS at initial boot // mySerial.println("AT+CMGF=1"); // Send SMS part delay(2000); mySerial.print("AT+CMGS=\""); mySerial.print(phone_no); mySerial.write(0x22); mySerial.write(0x0D); // hex equivalent of Carraige return mySerial.write(0x0A); // hex equivalent of newline delay(2000); mySerial.println("INITIAL BOOT OK"); mySerial.print("V Bat= "); mySerial.println(readVcc()); if (readVcc()<3.5) {mySerial.print("!!! CHARGE BATTERY !!!");} delay(500); mySerial.println (char(26));//the ASCII code of the ctrl+z is 26 delay(3000); // raw02=raw00; raw12=raw10; raw22=raw20; //scale0.power_down(); //power down all scales //scale1.power_down(); //scale2.power_down(); } void loop() { attachInterrupt(0, NULL , RISING); // Interrupt on high lewel set_sleep_mode(SLEEP_MODE_PWR_DOWN); //Set ARDUINO sleep mode digitalWrite(pin2sleep, HIGH); // Turn OFF GSM-shield delay(2200); digitalWrite(pin2sleep, LOW); // Turn OFF GSM-shield delay(2200); digitalWrite(pin2sleep, HIGH); digitalWrite(13, LOW); scale0.power_down(); //power down all scales scale1.power_down(); scale2.power_down(); delay(90000); sleep_mode(); // Go to sleep detachInterrupt(digitalPinToInterrupt(0)); // turn off external interrupt notsunset=0; for (int i=0; i <= 250; i++){ if ( !digitalRead(2) ){ notsunset++; } //is a really sunset now? you shure? delay(360); } if ( notsunset==0 ) { digitalWrite(13, HIGH); digitalWrite(pin2sleep, LOW); // Turn-ON GSM-shield scale0.power_up(); //power up all scales scale1.power_up(); scale2.power_up(); raw01=raw02; raw11=raw12; raw21=raw22; raw02=scale0.get_units(16); //read data from scales raw12=scale1.get_units(16); raw22=scale2.get_units(16); daynum++; delta00=(raw02-raw00)/calibrate0; // calculate weight changes delta01=(raw02-raw01)/calibrate0; delta10=(raw12-raw10)/calibrate1; delta11=(raw12-raw11)/calibrate1; delta20=(raw22-raw20)/calibrate2; delta21=(raw22-raw21)/calibrate2; delay(16000); mySerial.println("AT+CMGF=1"); // Send SMS part delay(2000); mySerial.print("AT+CMGS=\""); mySerial.print(phone_no); mySerial.write(0x22); mySerial.write(0x0D); // hex equivalent of Carraige return mySerial.write(0x0A); // hex equivalent of newline delay(2000); mySerial.print("Turn "); mySerial.println(daynum); mySerial.print("Hive1 "); mySerial.print(delta01); mySerial.print(" "); mySerial.println(delta00); mySerial.print("Hive2 "); mySerial.print(delta11); mySerial.print(" "); mySerial.println(delta10); mySerial.print("Hive3 "); mySerial.print(delta21); mySerial.print(" "); mySerial.println(delta20); mySerial.print("V Bat= "); mySerial.println(readVcc()); if (readVcc()<3.5) {mySerial.print("!!! CHARGE BATTERY !!!");} delay(500); mySerial.println (char(26));//the ASCII code of the ctrl+z is 26 delay(3000); } }
In the first line, in quotes char phone_no [] = "+ 123456789012"; - instead of 123456789012 we put our phone number with the country code, which will receive SMS.
Now press the check button (above the number one in the screenshot above) - if below (under the triple on the screen) "Compilation is complete" - then we can flash the microcontroller.
So, USB-TTL is connected to ARDUINO and the computer, we put the charged battery in the holder (usually the LED at a frequency of once a second starts to blink on the new arduinka).
Now the firmware - we are training to press the red (silver) button of the microcontroller - this will need to be done strictly at a certain moment !!!
There is? We press the button "Load" (above the two in the screenshot), and carefully look at the line at the bottom of the interface (under the triple screen).
As soon as the inscription "compilation" is replaced by "loading" - we press the red button (reset) - if everything is ok - the lights on the USB-TTL adapter blink, and at the bottom of the interface the words "loaded"
Now while we are waiting for the arrival of the test SMS on the phone, I will tell you how the program works:
In the photo - the second version of the debug stand.
The first time the system is turned on, the system checks the bytes number 500 and 501 of the EEPROM, if they are equal, then the calibration data is not recorded, and the algorithm goes to the settings section.
The same thing happens if the photoresistor is shaded when turned on (cap from the pen) - the reset mode is activated.
Strain gauges should already be installed under the hives, since we simply fix the initial level of zero and then measure the change in weight (now just zeros come, since we haven’t connected anything yet).
At Arduino, the built-in LED of pin 13 will start blinking.
If the reset does not occur, the LED lights up for 12 seconds.
After that, a test SMS is sent with the message "INITIAL BOOT OK" and the battery voltage.
The communication module is turned off, and after 3 minutes, the Arduino board puts the HX711 ADC board into sleep mode and goes to sleep.
Such a delay was made so as not to catch the pickups from a working GSM module (after turning it off, it takes some time for the fonits).
Further, we have an interrupt on the photosensor on the second pin (the pullup plus feature is enabled by the pullup function).
At the same time, after triggering another 3 minutes, the state of the photoresistor is checked - in order to avoid repeated / false positives.
What is characteristic, without any adjustment, the system works 10 minutes after the astronomical sunset in cloudy weather and after 20 minutes in clear.
Yes, so that at every power up the system does not reset, at least the first HX711 module must be connected (pins DT-D10, SCK-A0)
Then the load cell readings are taken, the weight change from the previous response (the first number in the row after Hive) and from the first start is calculated, the battery voltage is checked and this information is sent as SMS:
By the way, received SMS? Congratulations! We are in the middle of the road! The battery can be removed from the holder, the computer will not be needed further.
By the way, the mission control center turned out so compact that it can fit in a mayonnaise jar, in my case a translucent box of 30x60x100mm in size (from business cards) was perfect.
Yes, the sleeping system consumes ~ 2.3mA - by 90% due to the communication module - it does not turn off completely, but goes into standby mode.
Proceed to the manufacture of sensors, for the beginning let's touch the layout of the sensors:
This is a hive plan - top view.
Classically, 4 sensors are installed in the corners (1,2,3,4)
We will measure differently. Or rather, even in the third. Since the guys from BroodMinder do it differently:
In this design, the sensors are installed at positions 1 and 2, points 3.4 rely on the beam.
Then the sensors account for only half the weight.
Yes, this method has less accuracy, but still it is difficult to imagine that the bees build up all the frames with “tongues” from the cells along one wall of the hive.
So, I propose to reduce the sensors to point 5 in general - then there is no need for shielding the system, and using light hives does not require just one sensor.
In general, two types of modules on the HX711 were tested, two types of sensors, and two variants of their connection — with a full Wheatstone bridge (2 sensors) and with a half, when the second part is supplemented with 1k resistors with a tolerance of 0.1%.
But the latter method is undesirable and is not recommended even by manufacturers of sensors, so I will describe only the first one.
So, on one hive, we will have two strain gauges and one HX711 module, the decoupling scheme is as follows:
From the ADC board to the Arduino, there are 5 meters of 4-wire telephone cable - we also remember how bees do not like GSM devices in the hive .
In general, we leave “tails” of 8 cm on the sensors, we clean the twisted pair and we solder everything as in the photo above.
Before starting the carpentry, put the wax / paraffin in a suitable melt in a water bath.
Now we take our timber and divide by three pieces of 100mm
Further we mark a longitudinal groove 25 mm wide, 7-8 mm deep, with the help of a hacksaw and a chisel we remove the excess - a U-shaped profile should come out.
Is the wax warming up? - Dip our ADC boards there - this will protect them from moisture / fog:
We place it all on a wooden base (must be treated with antiseptic from rotting):
And finally, fix the sensors with self-tapping screws:
There was another option with blue electrical tape but for reasons of humanity I don’t cite it ;-)
From the side of Arduino we do the following:
We clean our telephone cables, we twist the colored wires together, we puddle.
After that, we solder to the board contacts as in the photo:
Everything, now for the final check, we put the sensors on sectors of the circle, on top - a piece of plywood, reset the controller (put the battery with the pen cap on the photodiode).
In this case, the LED on arduinka should blink and test SMS should arrive.
Next, remove the cap from the photocell, and go to collect water in a 1.5 liter plastic bottle.
We put the bottle on plywood and if several minutes have already passed from switching on, we put the cap back on the photoresistor (imitating the sunset).
After three minutes, the Arduino LED will light up, and you should receive an SMS with weight values ​​of about 1 kg in all positions.
Congratulations! system successfully assembled!
If we now make the system work again, then in the first column of the weight we get zeros.
Yes, in real conditions, the photoresistor is preferably oriented vertically upwards.
Now I will give a brief manual for use:
What's next?
Sincerely everything, sincerely yours, the electric beekeeper Andrei
Source: https://habr.com/ru/post/444326/