Personal aims. A restoration/continuation project would also expose me to a new methodology of work where I wouldn't be completely involved in the full design cycle; rather, I would need to utilize design principles in specific areas of the design cycle. This approach offers unique opportunities to expand my technical capabilities in ways that starting from scratch cannot provide. Working within the constraints of an existing system will push me to develop my underused circuitry skills through practical challenges like power management circuit design, solar charging systems. This methodology mirrors real professional engineering, where 80% of work involves enhancing existing systems rather than building from zero, something I am excited to try.
Introduction
Initial developments:
A fundamental issue: with beehives and large-scale farms is monitoring. Beekeepers are often unaware of what occurs in hives without requiring disassembly. This can also lead to silent issues building up, such as chemical buildups. These issues are exacerbated when a beehive is placed in a remote area
The initial goal of the automated beehive project was to build a Beehive capable of recording data about a Hive's health, such as VOC measurements, Weight, and other factors. This data would then be uploaded and accessed remotely from a Google Sheet.
In its current iteration, the beehive operates only on the local school network, meaning it cannot be used effectively outside that environment. Moreover, a proposed solution of adding a router to the hive would consume too much power, making power modulation necessary to ensure sustainable operation.
In conclusion, the next phase of the project should focus on improving the hive’s connectivity and energy efficiency, enabling it to function independently in remote or outdoor environments while maintaining reliable data transmission and monitoring.
Problem list:
The code auth requires a personal account, meaning tokens need to be renewed
The solar charge controller is exposed to the elements
The solar panel isn't secured
Too much power is consumed by electronics
SPECS/GOALS:
These design specifications are the primary goals for the restoration, with their successful implementation indicating the successful restoration of the beehive
The beehive must be powered primarily by a solar panel.
The regulator must support manual switching to direct additional power to the modem when needed.
The power system must minimize energy waste and allow for at least 1 week of autonomous operation
The charge controller must reliably supply adequate voltage to prevent SD card corruption or Pi shutdowns.
2. Connectivity
The beehive must be capable of connecting to the internet outside the school network.
The system must include a modem or router that can be powered on only when required to upload data.
Connectivity hardware (router/modem) must be controlled by the Raspberry Pi using GPIO pins and a MOSFET or transistor switch.
The system must upload data reliably to the cloud (e.g., Google Sheets).
The Raspberry Pi must control modem power using a GPIO-activated MOSFET/transistor.
The GPIO control system must be capable of switching at least the required current for the modem (via an external power source if needed).
the power control program must be able to toggle modem power on a schedule or when certain sensor events occur.
The system must be self-contained with no exposed wiring.
The solar panel mounting bracket must withstand wind, rain, and movement.
All electronics must be securely enclosed to prevent weather or insect damage.
The Raspberry Pi must run a Python program to collect and upload sensor data
Google Sheets authentication must be completed using a valid OAuth token stored securely on the Pi.
The system must operate automatically without requiring constant user intervention.
Future design must support automated token retrieval to avoid manual login steps.
Data uploads should occur only when the modem is powered, using scheduled intervals to save energy.
The power system must prevent overvoltage or undervoltage to the Raspberry Pi.
The design must avoid any risk of overheating inside the hive.
The solar panel and electronics should use recycled or sustainable materials where possible.
The system must restart safely after a power failure.
Investigation questions(information that needs to be known before continuation)
Current beehive
How often should the hive transmit data, and how much bandwidth is required(less than 4g is needed, every day at any specified time)
Should the system store data locally when offline and upload in batches(uploaded and stored locally)
Can the system compress or summarize data to minimize transmission energy(No)
What is the average daily power consumption of all sensors, processing devices, and communication modules(5.1v)
Can the hive operate primarily on solar power or long-lasting batteries(unknown- likely yes)
How can communication be optimized to reduce energy usage(No)
What is the acceptable frequency for battery replacements or maintenance visits (only once)
Can the design prevent buildup of wax or propolis over critical components (Yes there is a protective casing)
What is the expected lifespan of the system under outdoor conditions (Unknown = - lickley around 1 year)
How will data be stored, visualized, and interpreted by beekeepers (stored on Google Sheets)
How is data uploaded (Gcloud auth token in Google Sheets - requires renewal)
How to make addisons
How will offline periods be handled in the data model(N/A)
Are there regulations regarding wireless transmitters or batteries inside beehives(N/A)
How will firmware updates be delivered (not needed)
Should the system be designed to integrate additional sensors later(N/A)
Step 1
Downloaded code form raspberry pi
Refreshed auth token by compilating auth process
enables ssh on raspberry pi
researched gpio pins
SSH failed (fixed)
Lag when sending files
token failure(fixed)
create program to control power to mosfet transistor therby allowing the
During class, I focused on setting up the Raspberry Pi. This included enabling and connecting SSH, as well as exploring a solution to the primary issue I am investigating.
Problem: The Wi-Fi router doesn't need to be on at all times.
Solution: control power to turn router using the GPIO pins
Implementation: using a Python library for the Raspberry Pi by the GPOI pins would turn off and on to control a MOSFET transistor, thereby controlling power to the modem.
Additionally
In order to ensure that the beehive can send its data to Google Sheets, authentication is required. To do this, Google uses a token that is generated during sign-ins. To acquire the token, the user needs to sign in manually. During my time, I retrieved the token and added it to the project to allow the program to function. However, in the future, I would like to automate this process.
TODO ADD original code
Step 2
created circuit to turn on LED using transistor
added GPIO control to beehive monitor program
switched from mosfet to npn
High resistance to LED(fixed)
Cricut failure(fixed)
transfer improved bee monitor program to raspberry pi
Add modem
Today the main focus was getting the program to turn on an LED using a transistor. The primary purpose of the program and transistors is to turn the modem on to provide WIFI so the sensor data can get stored in the cloud. The LED was a Standin for the modem and USB which will eventually be added. Since the program functioned effectively swapping out the LED for the modem and adding a more powerful power source to power the modem will only require removing 2 wires.
Building circut
Current code
from __future__ import print_function
import os.path
from gpiozero import LED
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
import serial
import time
from threading import Thread
from datetime import datetime, timedelta, timezone
from gpiozero import LED
led = LED(17)
# If modifying these scopes, delete the file token.json.
SCOPES = ['https://www.googleapis.com/auth/spreadsheets']
# The ID and range of a sample spreadsheet.
SPREADSHEET_ID = '1rQKAtqz7H91SehYB299GUa9-oCZx9_zJYDOXuvk3dM0'
RANGE_NAME = 'raw!A2:E'
sensordata=[]
def main():
#####Start of Authentication
#### start router
led.on()
time.sleep(120)
"""Shows basic usage of the Sheets API.
Prints values from a sample spreadsheet.
"""
creds = None
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.json'):
creds = Credentials.from_authorized_user_file('token.json', SCOPES)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
# Save the credentials for the next run
with open('token.json', 'w') as token:
token.write(creds.to_json())
######end of Authentication
######Attempt to connect to the sensor board
try:
ser = serial.Serial('/dev/ttyACM0', 9600)
time.sleep(2)
except(FileNotFoundError):
print("Fatal error, sensorboard not connected")
time.sleep(2)
######Attempt to get some sensor values
#create a thread that can be reading all the data coming in from the arduino continously
def ser_read():
while True:
global sensordata
line = ser.readline()
data = line.decode('utf-8').rstrip()
sensordata = data.split(":")
#start the reading thread to be running in the background
x = Thread(target=ser_read)
x.start()
while True:
#wait for the VOC sensor to register
if len(sensordata) != 3:
print("Waiting for all sesnors, "+str(len(sensordata))+" of 3 found")
time.sleep(10)
continue
if sensordata[0] == '' or int(sensordata[0]) < 2:
print ("waiting for VOC: its currently: " + sensordata[0])
#return control to the main while loop and reread the serial data
time.sleep(10)
continue
voc = float(sensordata[0])
temp = float(sensordata[1])
weight = float(sensordata[2])
print("VOC:"+str(voc)+" Temp:"+str(temp)+" Weight:"+str(weight))
#create a timestamp for this data
now = datetime.now()
#print(now)
# dd/mm/YY H:M:S
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
#Try connect to the sheet and append the new sensor data with the timestamp
try:
service = build('sheets', 'v4', credentials=creds)
values = [
[
voc,temp,weight,dt_string
],
# Additional rows ...
]
body = {
'values': values
}
result = service.spreadsheets().values().append(
spreadsheetId=SPREADSHEET_ID, range=RANGE_NAME,
valueInputOption='USER_ENTERED',insertDataOption='INSERT_ROWS', body=body).execute()
#print(result)
#print(f"{result.get('updatedRows')} Rows updated.")
except HttpError as err:
print(err)
#sleep for some time before we poll data again
led.off()
time.sleep(24*60*60)
#development sleep
#time.sleep(1)
if __name__ == '__main__':
while True:
try:
main()
except Exception as error:
print("An error has occured, Trying again in 1 minute", error)
time.sleep(60)
continue
Step 4
transferred file to Raspberry Pi
soldered USB to circut
Add modem
connect power supply
test with something other than a mouse
Today, the main focus was on preparing the circuit to work with a modem and USB. To do this, we stripped the wires from a USB and connected the ground to the transistor and the main to the Raspberry Pi, 5 volts(to use a dedicated power source later on). Now, with the current circuit, the LED has been replaced by the USB. With the use of a test program, the expected behavior of the USB is to power on during a 3-second cycle. We tested this with a mouse; however, it failed. Currently, I believe the primary issue is with the mouse itself rather than the circuit or code, since it was initially functioning well with an LED. During the next step, I will use a different testing device such as an LED with a USB connection.
Step 5
tested with usb plug light(replaced mouse as testing device)
Added an extra transistor to increase the voltage to the test device
circut stayed on
END RESULT
LIght activated on test device indicating that the ciruct funtcioned as intended
Inadequate power source to the transistor(fixed)
wrong circuit config for ground(fixed)
low current to device(fixed)
attach to beehive
add new power source
switch top mosfet
After running the program alongside the new circuit the usb port we used as our test device functioned as expected with the light on the top of the device turning on periodically. The circuit achieves this by utilizing 2 transistors. The first transistor is activated by the 3.3v from gpio pin 17. When this Transistor is turned on by the pin current from a 5v power source travels through the transistor into ground. If the transistor is off then the 5v powers the next transistor connecting the circuit to the USB to ground allowing current to flow through the USB Turing on the light.
This has an interesting side effect being that the default state of the output is on rather than off. This means for integration with the modem the pi would need to keep the pin on at all times. The easiest way to rectify this would be with a mosfet as it uses voltage to current as its regulator
Step 6
Fixed
Added mosfet
fixed circuit
END RESULT
When the, program runs, it turns on the router without the inverted logic of the previous circuit
lack of grounds in Arduino
Connect to correct wifi
Step 7
Fixed SSH
Program updated sheets
attached to the Bee beehive
Connected wifi
Attempted to fix the router
connected to Design studio wifi
END RESULT
The program updated the beehive properly, while the circuit was able to turn the router on.
SSH failure
broken router
Token auth failure
Failure to update on restart
Add solar pannel for power
add new router
During this step, I attempted to add the router to the circuit, which would allow the beehive to function in any space. After several tests, I found the router to be defective. In order to proceed with tests, I connected the Pi to the local wifi and generated the needed SSH keys to utilize. After solving several errors with the program, such as missing packages and a Google Auth token failure. After fixing these issues, the program functioned as intended and successfully uploaded the needed data to the Google Sheet when the pi either restarts or at 12 o'clock every day.
Step 8
Built plastic frames to hold a solar panel
cleaned solar panel
added bottom panel to hold panel up
END RESULT
The solar pannel now powers the ardino and router.
NONE
NONE
In order to provide power to the circuit, the beehive requires a solar panel; however, the panel is prone to falling over without any support, meaning it would be risky to leave it in an area with disturbances such as rain and wind. To solve this, I added a recycled plastic bracket, which will work to prevent the panel from slipping.
Added Battery
The original Raspberry Pi had its SD card corrupted meaning we had to replace it with a newser raspberrit pi 4 which is less susepcatble to data corrpution
io
Found at
https://www.jsmodels.co.uk/home/Adjustable-DC-DC-Voltage-Regulator-LED-Driver-p184512318
We switched the main auth flow program to utilize a GCloud service account and an auth token. Therby, preventing token renewal, new code was deployed it successfully posted the necessary data to the Google sheet.
Evaluation and Reflection
The final iteration successfully utilizes an independent wifi network, allowing data posting from any location with cell service. All sensors also function effectively. The code still requires occasional maintenance as several minor issues have occurred since the evaluation of the product; however, each is easily fixed, although this affects the hive's overall reliability and needs to be rectified in future iterations. Despite this, the hive can still post accurate data.
SPECS/GOALS:
These design specifications are the primary goals for the restoration, with their successful implementation indicating the successful restoration of the beehive
The beehive must be powered primarily by a solar panel.(MEET)
The regulator must support manual switching to direct additional power to the modem when needed. (MEET)
The power system must minimize energy waste and allow for at least 1 week of autonomous operation (MEET)
The charge controller must reliably supply adequate voltage to prevent SD card corruption or Pi shutdowns.(MEET)
2. Connectivity
The beehive must be capable of connecting to the internet outside the school network.(MEET)
The system must include a modem or router that can be powered on only when required to upload data.(MEET)
Connectivity hardware (router/modem) must be controlled by the Raspberry Pi using GPIO pins and a MOSFET or transistor switch.(MEET)
The system must upload data reliably to the cloud (e.g., Google Sheets).(Partial MEET)
The Raspberry Pi must control modem power using a GPIO-activated MOSFET/transistor.(Unseassry)
The GPIO control system must be capable of switching at least the required current for the modem (via an external power source if needed).(Unseassry)
the power control program must be able to toggle modem power on a schedule or when certain sensor events occur.(Unseassry)
The system must be self-contained with no exposed wiring.(Partial - battery remains exposed)
The solar panel mounting bracket must withstand wind, rain, and movement. (MEET)
All electronics must be securely enclosed to prevent weather or insect damage.(MEET)
The Raspberry Pi must run a Python program to collect and upload sensor data (MEET)
Google Sheets authentication must be completed using a valid OAuth token stored securely on the Pi.(MEET)
The system must operate automatically without requiring constant user intervention.(MEET)
Future design must support automated token retrieval to avoid manual login steps.(MEET)
Data uploads should occur only when the modem is powered, using scheduled intervals to save energy.(MEET)
The power system must prevent overvoltage or undervoltage to the Raspberry Pi. (MEET)
The design must avoid any risk of overheating inside the hive.(MEET)
The solar panel and electronics should use recycled or sustainable materials where possible.(MEET)
The system must restart safely after a power failure.(MEET)
PERSONAL REFLECTION:
Throughout this continuation project, I developed my CAD and circuitry skills significantly beyond what I could have achieved starting from scratch. Working with Fusion 360 evolved from basic part modeling into sophisticated constraint-based design, as I worked with tools such as sketches and fillets. My understanding of the design cycel also improved as I was forced to perform each part in a less structured manner. However, I discovered something important about how I work best: I don't particularly enjoy operating without the full design cycle. Working within the constraints of someone else's architecture felt restrictive in ways I hadn't anticipated. I found myself constantly adapting my ideas to fit existing mounting points, accommodating sensor interfaces I wouldn't have chosen, and working around design decisions that seemed suboptimal but were too embedded to change. The creative satisfaction I typically get from engineering. The fact that much of the work was also "Busy work" was also unsatisfying as I was mostly waiting for parts and solving a large quantity of small, minor errors rather than overarching problems. What this experience taught me is that while I can successfully work within continuation projects and deliver results I prefer to work with the complete design cycle which I will be doing with my beehive sensory package.