Batteries: watch polarity, use protected cells and a charger with protection, never charge damaged cells unattended.
Door / window sensor
A battery sensor with a reed switch that wakes from deep sleep only when the door opens.
A load-cell scale with a temperature probe tracks honey flow and hive health on solar or a Li-ion cell.
Smart home Board: ESP32 DevKit V1 (WROOM-32) Level: ●●○ ⏱ 2–3 h
Batteries: watch polarity, use protected cells and a charger with protection, never charge damaged cells unattended.
A hive on a scale shows the nectar flow as a steady gain, sometimes a kilogram or two a day, and a swarm as a sudden loss. For a beekeeper with several apiaries, that saves trips and helps to time the extraction.
Four load cells in a bridge under the corners, an HX711 amplifier, and a waterproof junction box. Calibrate with a known weight such as bottles of water. Load cells drift with temperature, so log the temperature next to the weight and correct the trend, or compare only readings taken at the same hour.
| Module | Module pin | ESP32 pin | Note |
|---|---|---|---|
| HX711 DT / SCK | digital | GPIO16 / GPIO17 | VCC 3V3 |
| HX711 E+ E- A+ A- | load cells | four cells in a bridge | follow the colour code of your cells |
| DS18B20 DATA | 1-Wire | GPIO4 | 4.7 kΩ pull-up to 3V3 |
#include <WiFi.h>
const char* WIFI_SSID = "YOUR_WIFI";
const char* WIFI_PASS = "YOUR_PASSWORD";
bool connectWiFi(uint32_t timeoutMs = 20000) {
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASS);
uint32_t t0 = millis();
while (WiFi.status() != WL_CONNECTED && millis() - t0 < timeoutMs) {
delay(250);
Serial.print(".");
}
Serial.println();
if (WiFi.status() == WL_CONNECTED) {
Serial.print("IP: ");
Serial.println(WiFi.localIP());
return true;
}
return false;
}
#include <PubSubClient.h>
const char* MQTT_HOST = "192.168.1.10"; // IP of your Raspberry Pi / mini-PC
const uint16_t MQTT_PORT = 1883;
const char* MQTT_USER = "esp32";
const char* MQTT_PASS = "mqtt-password";
WiFiClient netClient;
PubSubClient mqtt(netClient);
bool mqttConnect(const char* clientId) {
mqtt.setServer(MQTT_HOST, MQTT_PORT);
uint32_t t0 = millis();
while (!mqtt.connected() && millis() - t0 < 10000) {
if (mqtt.connect(clientId, MQTT_USER, MQTT_PASS)) return true;
delay(500);
}
return mqtt.connected();
}
#include <HX711.h>
#include <OneWire.h>
#include <DallasTemperature.h>
HX711 scale; OneWire ow(4); DallasTemperature ds(&ow);
float CAL_FACTOR = 22000.0; // raw units per kg: calibrate with a known weight (see tips)
const uint64_t SLEEP_US = 15ULL * 60ULL * 1000000ULL;
RTC_DATA_ATTR float tareOffset = 0;
void setup() {
Serial.begin(115200); ds.begin();
scale.begin(16, 17);
if (scale.wait_ready_timeout(2000)) {
if (tareOffset == 0) { scale.tare(10); tareOffset = scale.get_offset(); } else scale.set_offset(tareOffset); // first boot with an empty platform = zero
scale.set_scale(CAL_FACTOR);
float kg = scale.get_units(10);
ds.requestTemperatures(); float t = ds.getTempCByIndex(0);
if (connectWiFi() && mqttConnect("beehive1")) {
String j = String("{"weight_kg":") + String(kg, 2) + ","temp_c":" + String(t, 1) + "}";
mqtt.publish("home/beehive1/state", j.c_str(), true); mqtt.loop(); delay(200);
}
}
scale.power_down();
esp_sleep_enable_timer_wakeup(SLEEP_US); esp_deep_sleep_start();
}
void loop() {}
Buy the parts kit · Estimated total: $19.30
Ukraine: we buy and sell these parts ourselves, order them on this site.
Some links are affiliate links: we may earn a commission at no extra cost to you.
Batteries: watch polarity, use protected cells and a charger with protection, never charge damaged cells unattended.
A battery sensor with a reed switch that wakes from deep sleep only when the door opens.
Mains 220–230 V can kill. Work with the power off, use certified isolated modules in an enclosure, fuse the line, and ask a qualified electrician if you are not sure.
Heats the water heater only in the cheap night tariff zone or from surplus solar power, with a temperature limit.
Batteries: watch polarity, use protected cells and a charger with protection, never charge damaged cells unattended.
A battery sensor that wakes up rarely and sends an alert when the temperature falls toward freezing.
Comments
No comments yet. Share your experience or ask a question.