SMS-monitoring of the weight of three beehives for $30

SMS-monitoring of the weight of three beehives for $30

No, this is not a commercial offer, this is the cost of the system components that you can assemble after reading the article.

A little background:

Some time ago I decided to get bees, and they did appear ... for the whole season, but did not leave the winter.
And this despite the fact that he seemed to be doing everything right - autumn complementary foods, warming before the cold.
The hive was a classic wooden system "Dadan" for 10 frames from a 40-mm board.
But that winter, due to temperature swings, even experienced beekeepers lost much more than usual.

This is how the idea of ​​a hive health monitoring system came about.
After publishing several articles on Habr and talking on the beekeepers' forum, 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 it (for example, swarm departure, bee disease), then the indicators become irrelevant.

Therefore, it was decided to monitor the change in the weight of three hives at once with one microcontroller, and add other "goodies" after.
As a result, we got an autonomous system with an operating time of about a month on a single 18650 battery charge and sending statistics once a day.
I tried to simplify the design as much as possible, so that it could be repeated even without diagrams, from one photograph.

The logic of operation is as follows: at the first start / reset, the readings of the sensors installed under the hives are stored in the EEPROM.
Further, every day, after sunset, the system “wakes up”, reads the readings and sends SMS with a change in weight per day and from the moment it was turned on.
In addition, the value of the battery voltage is transmitted, and when it drops to 3.5V, a warning is issued about the need for charging, because below 3.4V the communication module does not turn on, and the weight readings are already “floating away”.

"Do you remember how it all began. Everything was for the first time and again.
SMS-monitoring of the weight of three beehives for $30
Yes, it was such a set of "iron" that was originally, though only strain gauges and wires survived to the final version, but first things first.
In fact, the cable bay is not needed, it just turned out to be the same price as 30m straight.

If you are not afraid of dismantling 3 smd-LEDs and half a hundred points of conventional (output) soldering, then go!

So, we need the following set of equipment / materials:

  1. Arduino Pro Mini 3V
    You should pay attention to the linear converter chip - it should be exactly 3.3V - on the chip marking KB 33 / LB 33 / DE A10 - the Chinese messed up something with me, and the whole batch
    the boards in the store turned out to be with 5-volt regulators and quartz at 16MHz.
  2. USB-Ttl on the CH340 chip - even 5-volt is possible, but then during the firmware of the microcontroller, the Arduino will need to be disconnected from the GSM module so as not to burn the latter.
    Boards based on the PL2303 chip do not work under Windows 10.
  3. GSM communication module Goouu Tech IOT GA-6-B or AI-THINKER A-6 Mini.
    Why did you stop there? Neoway M590 - a constructor that requires separate dances with tambourines, GSM SIM800L - did not like the non-standard 2.8V logic level, which requires coordination even with a three-volt arduino.
    In addition, the solution from AiThinker has minimal power consumption (when sending SMS, I did not see a current above 100mA).
  4. Antenna GSM GPRS 3DBI (in the photo above - a rectangular scarf with a "tail", at 9 o'clock)
  5. A starter pack for an operator with good coverage at your apiary location.
    Yes, the package must first be activated in a regular phone, DISABLE PIN REQUEST at the entrance, and top up the account.
    Now there are many options with names like "Sensor", "IoT" - they have a slightly lower monthly fee.
  6. wire dupont 20cm female-female — 3 pcs. (for connecting Arduino to USB-TTL)
  7. 3 pcs. HX711 - ADC for scales
  8. 6 load cells for weight up to 50kg
  9. 15 meters of 4-wire telephone cable - to connect weight modules with ARDUINO.
  10. Photoresistor GL5528 (important exactly this, with a dark resistance of 1MΩ and a light resistance of 10-20kΩ) and two conventional 20k resistors
  11. A piece of double-sided "thick" tape 18x18mm - for attaching the arduino to the communication module.
  12. 18650 battery holder and, in fact, the battery itself ~ 2600mAh.
  13. A little wax or paraffin (aroma lamp candle-tablet) - for moisture protection HX711
  14. A piece of wooden beam 25x50x300mm for the base of the strain gauges.
  15. A dozen self-tapping screws with a press washer 4,2x19 mm for attaching the sensors to the base.

The battery can be taken from dismantling laptops - many times cheaper than a new one, and the capacity will turn out to be much larger than that of the Chinese UltraFire - I got 1500 against 450 (this is for the fire 6800 😉

In addition, you will need non-crooked hands, an EPSN-25 soldering iron, rosin and POS-60 solder.

SMS-monitoring of the weight of three beehives for $30

5 years ago I used a Soviet soldering iron with a copper sting (soldering stations didn’t work for me - I took it for a test drive, and finished the circuit with EPSN).
But after its failure and several Chinese monstrous fake (d) trees, the latter had the name Sparta - a thing as harsh as the name, stopped
on a product with a thermostat.

So let's go!

SMS-monitoring of the weight of three beehives for $30

To begin with, we unsolder two LEDs from the GSM module (the place where they were circled in an orange oval)
We insert the SIM card with contact pads to the printed circuit board, the beveled corner in the photo is indicated by an arrow.

SMS-monitoring of the weight of three beehives for $30

Then we carry out a similar procedure with the LED on the Arduino board (oval to the left of the square chip),
We solder the comb into four contacts (1),
We take two 20k resistors, twist the leads on one side, solder the twist into the hole of contact A5, the remaining leads in RAW and GND of the arduino (2),
We shorten the legs of the photoresistor to 10mm and solder it to the GND and D2 pins of the board (3).

Now it's time for the blue electrical tape of double-sided tape - we glue it on the SIM card holder of the communication module, and on top - arduino - the red (silver) button is facing us and is above the SIM card.

We solder the power: plus from the capacitor of the communication module (4) to the RAW arduino pin.
The fact is that the communication module itself requires 3.4-4.2V for its power supply, and its PWR contact is connected to a step-down converter, so to work from li-ion, voltage must be supplied bypassing this part of the circuit.

In arduino, on the contrary, we supply power through a linear converter - at low current consumption, the drop-out voltage drop is 0.1V.
But by applying a stabilized voltage to the HX711 modules, we get rid of the need to modify them for a lower voltage (and at the same time from increasing noise as a result of this operation).

Then we solder the jumpers (5) between the PWR-A1, URX-D4 and UTX-D5 contacts, the GND-G ground (6) and finally the power supply from the 18650 battery holder (7), connect the antenna (8).
Now we take a USB-TTL converter and connect the RXD-TXD and TXD-RXD, GND-GND contacts with Dupont wires to ARDUINO (comb 1):

SMS-monitoring of the weight of three beehives for $30

The photo above shows the first version (out of three) of the system that was used for debugging.

And now we will digress from the soldering iron for a while, and move on to the software part.
I will describe the sequence of actions for Windows:
First, you need to download and install/unpack the program Arduino IDE - the current version is 1.8.9, but I'm using 1.6.4

For simplicity, we unpack the archive into the C: arduino-"your_version number" folder, inside we will have /dist, drivers, examples, hardware, java, lib, libraries, reference, tools folders, as well as the arduino executable file (among others).

Now we need a library to work with the ADC HX711 - green button "clone or download" - download ZIP.
The content (folder HX711-master) is placed in the C: arduino-"your_version_number"libraries directory

And of course, the driver for USB TTL from the same github - from the unpacked archive, the installation is simply launched by the SETUP file.

Ok, run and configure the program C: arduino-"your_version number" arduino

SMS-monitoring of the weight of three beehives for $30

We go to the "Tools" item - select the "Arduino Pro or Pro Mini" board, Atmega 328 3.3V 8 MHz processor, port - a number other than the 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 to which SMS will be sent.

Now we press the check button (above the number one in the screenshot above) - if below (under the three on the screen) “Compilation is completed” - then we can flash the microcontroller.

So, USB-TTL is connected to ARDUINO and a computer, we put a charged battery in the holder (usually on a new arduino, the LED starts blinking at a frequency of once per second).

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 !!!
Eat? Click the "Upload" button (above the two in the screenshot), and carefully look at the line at the bottom of the interface (under the three of the screen).
As soon as the inscription "compilation" is replaced by "loading" - press the red button (reset) - if everything is ok - the lights on the USB-TTL adapter blink happily, and at the bottom of the interface the inscription "Loaded"

Now, while we are waiting for the test SMS to arrive on the phone, I will tell you how the program works:

SMS-monitoring of the weight of three beehives for $30

In the photo - the second version of the debugging stand.

When first turned on, the system checks bytes number 500 and 501 of the EEPROM, if they are equal, then the calibration data is not written, and the algorithm proceeds to the setup section.
The same thing happens if, when turned on, the photoresistor is shaded (with a pen cap) - the reset mode is activated.

The load cells should already be installed under the hives, since we simply fix the initial level of zero and then measure the change in weight (now it will just come zeros, since we have not connected anything yet).
At the same time, the built-in LED of pin 13 will blink on the Arduino.
If no reset occurs, 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 turns off, and after 3 minutes, the Arduino board puts the HX711 ADC boards into sleep mode and falls asleep by itself.
Such a delay is made in order not to catch pickups from a working GSM module (after turning it off, it “phonites” for some time).

Next, we have a photo sensor interrupt on the second pin (positive pullup is enabled with the pullup function).
At the same time, after triggering for another 3 minutes, the state of the photoresistor is checked - to exclude repeated / false positives.
Tellingly, without any adjustment, the system works 10 minutes after astronomical sunset in cloudy weather and 20 minutes later in clear weather.
Yes, so that the system does not reset every time it is turned on, at least the first HX711 module must be connected (pins DT-D10, SCK-A0)

Then the readings of the load cells are taken, the change in weight is calculated from the previous operation (the first number in the line after Hive) and from the first inclusion, the battery voltage is checked and this information is sent in the form of SMS:

SMS-monitoring of the weight of three beehives for $30

By the way, did you get a text message? Congratulations! We are in the middle of the road! The battery can still be removed from the holder, we will not need the computer further.

By the way, the mission control center turned out to be so compact that it can fit in a mayonnaise jar, in my case a translucent box 30x60x100mm in size (from business cards) fit perfectly.

Yes, the sleeping system consumes ~2.3mA - 90% due to the communication module - it does not turn off completely, but goes into standby mode.

SMS-monitoring of the weight of three beehives for $30

We proceed to the manufacture of sensors, for a start, let's touch on the layout of the sensors:

SMS-monitoring of the weight of three beehives for $30

This is the plan of the hive - top view.

Classically, 4 sensors are installed in the corners (1,2,3,4)

We will measure differently. Or rather, even in a third way. Because the guys from BroodMinder do it differently:

SMS-monitoring of the weight of three beehives for $30

In this design, the sensors are installed at positions 1 and 2, points 3,4 and XNUMX rest on the beam.
Then the sensors account for only half the weight.
Yes, this method has less accuracy, but it is still difficult to imagine that the bees built up all the frames with “tongues” of honeycombs along one wall of the hive.

So, I propose to generally reduce the sensors to point 5 - then there is no need to shield the system, and when using light hives, you can do with one sensor at all.

SMS-monitoring of the weight of three beehives for $30

In general, two types of modules were tested on the HX711, two types of sensors, and two options for 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 not recommended even by sensor manufacturers, so I will describe only the first one.

So, on one hive we will install two load cells and one HX711 module, the wiring diagram is as follows:

SMS-monitoring of the weight of three beehives for $30

From the ADC board to the arduino there is 5 meters of a 4-core telephone cable - we remember how bees do not like GSM devices in the hive.

In general, we leave “tails” of 8 cm each on the sensors, clean the twisted pair and unsolder everything as in the photo above.

Before starting the carpentry, put the wax/paraffin in a suitable container to melt in a water bath.

Now we take our timber and divide it into three segments of 100mm each

Next, we mark a longitudinal groove 25 mm wide, 7-8 mm deep, use a hacksaw and a chisel to remove the excess - a U-shaped profile should come out.

Has the wax warmed up? - we dip our ADC boards there - this will protect them from moisture / fog:

SMS-monitoring of the weight of three beehives for $30

We place it all on a wooden base (it is necessary to treat it with an antiseptic from decay):

SMS-monitoring of the weight of three beehives for $30

And finally, we fix the sensors with self-tapping screws:

SMS-monitoring of the weight of three beehives for $30

There was another option with blue electrical tape, but for reasons of humanity I don’t bring it up 😉

From the Arduino side, do the following:

We clean our telephone cables, twist the colored wires together, play tricks.

After that, solder to the contacts of the board as in the photo:

SMS-monitoring of the weight of three beehives for $30

That's it, now for the final check, we put the sensors in the sectors of the circle, on top - a piece of plywood, reset the controller (we put the battery with a pen cap on the photodiode).

At the same time, the LED on the arduino should blink and a test SMS should come.

Then we 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 turning on, we put the cap back on the photoresistor (simulating a sunset).

After three minutes, the LED on the arduino will light up, and you should receive an SMS with weight values ​​\u1b\uXNUMXbof about XNUMXkg in all positions.

Congratulations! the system has been successfully assembled!

If we now force the system to work again, then zeros will be obtained in the first column of the weight.

Yes, in real conditions it is desirable to orient the photoresistor vertically upwards.

Now I will give a short manual for use:

  1. Install load cells under the rear walls of the hives (substitute a beam / board ~ 30 mm thick under the front ones)
  2. Shade the photoresistor and put the battery in - the LED should blink and a test SMS should come with the text "INITIAL BOOT OK"
  3. Position the central block at the maximum distance from the hives and so that the wires do not interfere when working with bees.
    Every evening, after sunset, SMS will come with a change in weight per day and since the launch.
    When the battery voltage reaches 3.5V, the SMS will end with the line “!!! CHARGE BATTERY!!!"
    The operating time from one battery with a capacity of 2600mAh is about a month.
    In the event of a battery replacement, the daily weight changes of the hives are not memorized.

What's next?

  1. Figure out how to arrange all this in a project for github
  2. Have 3 bee colonies in the hives of the Palivoda system (or horned in the people)
  3. Add "buns" - measurement of humidity, temperature, and most importantly - analysis of the buzzing of bees.

That's all for now, sincerely yours, electric beekeeper Andrey

Source: habr.com

Add a comment