joergkeller / beehive-sensor

Temperature and humidity measurement in a beehive using Arduino and LoRaWan (TTN).
MIT License
13 stars 7 forks source link

Beehive sensor data

Weight, temperature and humidity measurement in a beehive using Arduino and LoRaWan (TTN).\ Deutscher Text.

Arduino compile test

To support bee keepers in monitoring their bees with minimal interference, a set of sensors will measure and transmit the current state in short intervalls. Design goals:

System Overview

Device Hardware

Three boards have been tested:

Used pins:

Pin Function Wiring Uno+Shield / Dragino CubeCell
1-wire Temp sensor pull-up resistor 4k7 to VCC D5 GPIO5
DHT-11/22 pull-up resistor 4k7 to VCC D4 GPIO4
HX711 Dout A0 GPIO2
HX711 Sck A1 GPIO3
Push-Button to GND (active low, triggers interrupt) D3 GPIO7 (aka battery test control)
LED to VCC (active low) A2 GPIO1

Transmitted LoRa message (binary encoded)

Checkout this project

Local installation of git and Arduino IDE assumed.\ Install the CubeCell board: https://heltec-automation-docs.readthedocs.io/en/latest/cubecell/quick_start.html (current version 1.3.0).

cd <project-root>
git clone https://github.com/joergkeller/beehive-sensor.git
cd beehive-sensor
git submodule init
git submodule update

To fetch the latest updates:

cd beehive-sensor
git stash
git pull
git submodule update
git stash pop
Arduino Settings Value
File > Preferences > Settings > Board Manager URLs https://github.com/HelTecAutomation/CubeCell-Arduino/releases/download/V1.3.0/package_CubeCell_index.json
File > Preferences > Settings > Sketchbook location C:\...\beehive-sensor
File > Open... C:\...\beehive-sensor\arduino_beehive_sensor_lora\arduino_beehive_sensor_lora.ino
Tools > Board CubeCell-Board
Tools > LORAWAN_REGION REGION_EU868 or your region
Tools > LORAWAN_CLASS CLASS_A
Tools > LORAWAN_DEVEUI CUSTOM
Tools > LORAWAN_NETMODE OTAA
Tools > LORAWAN_ADR ON
Tools > LORAWAN_UPLINKMODE UNCONFIRMED
Tools > LORAWAN_NET_RESERVATION OFF
Tools > LORAWAN_AT_SUPPORT OFF
Tools > LORAWAN_RGB ACTIVE or DEACTIVE
Monitor baud rate 115200

The project already includes all required libraries (that is the reason for the submodule commands and for the local sketchbook location).

Then

  1. Create free TTN account/application/device and enter OTAA/ABP authorization codes in credentials.h
  2. Create free ThingSpeak account/channel and a TTN ThingSpeak integration with the appropriate values
  3. Compile/upload sketch
  4. Activation with OTAA takes some time (even half an hour or so)
  5. Press button to enter 'manual mode'
    • no LoRa messages sending, blinking LED instead
    • continous weight measuring for calibration, calculate offset/scale (eg. see Excel sheet)
    • for temperature compensation, measure weights at different temperatures also
    • scanning 1-wire temperature sensors one by one, note ids
    • press button again to start LoRa activation
  6. Enter 1-wire sensor ids and weight calibration to calibration.h
  7. Compile/upload sketch again
    • Wait for OTAA activation
    • First measure should appear in the local monitor, as TTN data and in ThingSpeak channel