This beehive project is dedicated to remotely monitoring a beehive's activity :
Several sensors collect data. This data is then sent through WiFi to a database, and made accessible on a website.
In this repository, we will focus on collecting and sending the data.
The data visualisation on the website is dealt with on another repository
Edition du diagramme (drive makers lab)
This system is designed to run periodic measurement cycles and send the results online.
For each cycle, we will:
- produce and upload a gif from pictures from the beehive's entrance
- read several parameters about the beehive's environment and conditions :
- Temperature
- Humidity
- Noise
- Weight
- Light
- CO
- NO2
All of this data will then be stored on a online database.
For this project, we use :
- a solar panel and a powerbank for power supply.
- an Arduino Trinket, which will trigger and power on the system for 10 minutes, once an hour.
- an Arduino Uno and a series of sensors. The Arduino Uno will read data from its sensors and send them when requested through a serial port.
- a Raspberry Pi which will read data from the Arduino Uno, take pictures from a camera, transform them into a gif, and then upload all the data online.
To power the system, we use a solar panel and a powerbank.
- ECO-WORTHY 25W 12V Polycrystalline Solar Panel Module Charging RV Boat
- UBEC DC/DC Step-Down (Buck) Converter - 5V @ 3A output
- Tecknet 33000mAh powerbank
- Connect the SD card to your computer
- Open Raspberry Pi Imager
- Choose the last version of Raspberry Pi OS Lite and write it on SD card.
- Insert the micro SD into the Raspberry Pi
- Plug a keyboard and a screen to the device.
- Plug the power supply : the device should boot now !
- Follow the prompts :
- Keyboard configuration
- username : choose 'beeN', with N being the number of your beehive. This will be used to track the beehive's data.
You might notice some intermittent warnings : "Undervoltage detected!". In that case :
- check that you are using a 3A power supply.
- check that there is no bad contact on the board If everything else keeps working, you can ignore them.
Run
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
and add
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="makerslab"
psk="makerslab"
}
Where ssid
and psk
are the Wi-Fi network's name and password.
If you see the following message, you need some extra config to enable Wi-fi connection
Wi-Fi is currently blocked by rfkill.
--> Use raspi-config to set the country before use.
That way, you can use your own computer to edit settings and code on the device.
It is faster, you can use a decent text editor and use copy-paste. To do so, you need to use the same wifi network.
sudo raspi-config
- Interface Options
- I2 SSH > Enable SSH
Get the hostname :
hostname -I
The output should look like this :
172.XX.XX.XX
Then you should be able to connect from your computer :
ssh beeN@172.XX.XX.XX
sudo apt update && sudo apt upgrade -y
Git should already be installed.
To check it : git
If not :
sudo apt-get install git
Python package manager
sudo apt install python3-pip
Enables serial communication on Pi.
sudo pip install picamera
Enables image manipulation.
Resize image from CLI with imagemagick Doc - imageMagick CLI
sudo apt-get install imagemagick
Enables the upload of pictures (and gifs) on Imgur.
pip install pyimgur
Access a firebase DB with Python SDK
- Parmi les dépendances de firebase admin, on trouve le paquet cryptography, dont firebase exige une version récente (cryptography>=3.4.0)
- Les dernières version de ce paquet ont besoin d’une version récente du langage Rust (This package requires Rust >=1.56.0.)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
-
Avant de lancer l’installation de firebase_admin, il faut installer les dépendances nécessaires à l’installation de cryptography. a. Install dependencies for cryptography
sudo apt-get install build-essential libssl-dev libffi-dev \ python3-dev cargo pkg-config
b. Install cryptography
pip install cryptography
This step will probably last quite a long time, while prompting the following information :
Building wheel for cryptography (PEP 517) ... |
- Enfin, on peut lancer l’installation de firebase_admin :
pip install firebase_admin
Type sudo raspi-config
and enable RaspiCam: Interfacing Options
-> Camera
-> Yes
cd && git clone https://github.com/emlyon/makers-beehives-hardware.git
Create secret keys files within the repository:
To move within the repository, type
cd makers-beehives-hardware/
firebase-secrets.json
touch firebase-secrets.json
nano firebase-secrets.json
https://console.firebase.google.com/project/makerslab-beehives/settings/serviceaccounts/adminsdk
imgur-secrets.json
touch imgur-secrets.json
nano imgur-secrets.json
https://imgur.com/account/settings/apps
{
"imgurClientID": "xxxxxxxxxxxxxxx",
"imgurClientSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
Edit the .bashrc
file, which will enable to run a script after autologin.
nano ~/.bashrc
Add this line at the bottom of the file :
python makers-beehives-hardware/beehives.py
Legacy references :
- Raspberry Pi / Python: install pip for Python modules dependencies installation
- How to mount a USB flash drive on Raspberry Pi
- How to setup multiple WiFi networks?
- imagemagick/mogrify
- Camera Module
- Scheduling tasks with Cron
- Change default username
- Execute sudo without Password
The Arduino Trinket will control a relay, in order to power the system on for 10 minutes once an hour.
We will follow this documentation to set up the trinket
-
Open Arduino IDE
-
Install Adafruit's board manager (if not already installed) : Adafruit Arduino AVR Boards
-
Select the Pro Trinket 5V/16MHz (USB) board :
Tools > Board > Adafruit AVR Boards > Pro Trinket 5V/16MHz
-
Next select the USBtinyISP programmer : Tools > Programmer > USBtinyISP
-
Paste the code from trinketRelay.ino file into the IDE window
-
Plug in the Arduino Trinket, make sure you see the green LED lit (power good) and the red LED pulsing. Press the button if the red LED is not pulsing, to get into bootloader mode.
-
Upload the code to the board : Sketch > Upload using programmer
-
Open Arduino IDE
-
Install Adafruit's board manager (if not already installed) : Adafruit Arduino AVR Boards
-
Plug in the Arduino Uno board
-
Paste the code from arduino_beehive.ino into the IDE window
-
Install required libraries from the library interface :
-
Download and install the sensors' custom libraries
For the project's needs, we had to customize some existing libraries :
For each of the following :
-
access to the github repository
-
Install the library into Arduino IDE:
Click on Sketch > Include library > Add .ZIP library, then choose the downloaded .ZIP library.
-
Upload the code to the Arduino Uno board.
If you access the serial monitor, you should see some information about the sensors, which will depend on whether the sensors are plugged or not.
-
-
Using the same process as custom libraries, install the following libraries if needed :
Now, you can wire up the sensors on your board, following our documentation on Notion:
Then, you should be able to fetch data from the sensors :
From the serial monitor, you can request data from the sensors by sending the following serial message : DATA?
Based on https://www.instructables.com/id/Arduino-Bathroom-Scale-With-50-Kg-Load-Cells-and-H/
- Base Shield Grove
- Temperature & Humidity Sensor on D2
- Grove Sound Sensor on A0
- Digital Light Sensor on I2C
- library: http://wiki.seeedstudio.com/Grove-Digital_Light_Sensor/: Digital Light Sensor Library
- code: http://wiki.seeedstudio.com/Grove-Digital_Light_Sensor/ & http://www.ardumotive.com/lux-sensor-en.html
- Multichannel Gas Sensor on I2C