JS Chong
Published

Bee Integration into Commercial Urban Farms

EEP Project T2-3

BeginnerFull instructions provided124
Bee Integration into Commercial Urban Farms

Things used in this project

Story

Read more

Custom parts and enclosures

Lighting Enclosure

Schematics

Lighting

We used 2 LED, a bread board, and an Arduino UNO as our lighting

Block Diagram for M5Stack Tracking Bees' Movement

Block Diagram for M5Stack Monitoring Bee Health

Block Diagram for M5Stack Receiving Bee Health Data

Circuit Diagram for M5Stack Tracking Bees' Movement

Circuit Diagram for M5Stack Monitoring Bee Health

Circuit Diagram for M5Stack Receiving Bee Health Data

Flowchart for "Tracking Bee Movements" Code

Flowchart for "Bee Health Monitoring" Code

Flowchart for "Remote Monitoring" Code

Design Implementation for "Tracking Bee Movements"

Design Implementation for "Bee Health Monitoring"

Design Implementation for "Remote Monitoring"

2D Board

Code

Bee Health Monitoring

MicroPython
This code uses the environment sensor (ENV II) to track the humidity and temperature of the beehive. It will then transmit this same data wirelessly to any receivers in real-time.
from m5stack import *
from m5ui import *
from uiflow import *
from flow import ezdata
import wifiCfg
import unit

setScreenColor(0x222222)
env2_0 = unit.get(unit.ENV2, unit.PORTA)


status = None
temp = None
hum = None

wifiCfg.autoConnect(lcdShow=False)

label0 = M5TextBox(7, 22, "Temperature(°C):", lcd.FONT_UNICODE, 0xffffff, rotate=0)
label1 = M5TextBox(230, 22, "Text", lcd.FONT_UNICODE, 0xFFFFFF, rotate=0)
label2 = M5TextBox(64, 60, "Humidity(%):", lcd.FONT_UNICODE, 0xFFFFFF, rotate=0)
label3 = M5TextBox(230, 60, "Text", lcd.FONT_UNICODE, 0xFFFFFF, rotate=0)
label4 = M5TextBox(80, 99, "Text", lcd.FONT_Default, 0xffffff, rotate=0)
label5 = M5TextBox(102, 122, "Text", lcd.FONT_Default, 0xffffff, rotate=0)




while True:
  label1.setText(str(env2_0.temperature))
  label3.setText(str(env2_0.humidity))
  if (env2_0.temperature) > 35.5:
    label4.setText('Hive Temperate Too HIGH')
    label4.setColor(0xff0000)
    rgb.setColorFrom(6 , 10 ,0xff0000)
    temp = True
  elif (env2_0.temperature) < 34.5:
    label4.setText('Hive Temperate Too LOW')
    label4.setColor(0xff0000)
    rgb.setColorFrom(6 , 10 ,0xff0000)
    temp = True
  else:
    label4.setText('Hive Temperate OK')
    label4.setColor(0x33cc00)
    rgb.setColorFrom(6 , 10 ,0x33cc00)
    temp = False
  if (env2_0.humidity) > 60:
    label5.setText('Humidity Too HIGH')
    label5.setColor(0xff0000)
    rgb.setColorFrom(1 , 5 ,0xff0000)
    hum = True
  elif (env2_0.humidity) < 50:
    label5.setText('Humidity Too LOW')
    label5.setColor(0xff0000)
    rgb.setColorFrom(1 , 5 ,0xff0000)
    hum = True
  else:
    label5.setText('Humidity OK')
    label5.setColor(0x33cc00)
    rgb.setColorFrom(1 , 5 ,0x33cc00)
    hum = False
  if hum == True and temp == True:
    status = 'danger'
  elif hum == False and temp == False:
    status = 'ok'
  else:
    status = 'warning'
  ezdata.setData('R3jYwSPOVonYjxJvnWp8wnHeheBZv9HG', 'transfer', status)
  wait_ms(2)

Remote Monitoring

MicroPython
Receives data on bee health from the above code "Bee Health Monitoring". This code will display the current health of the bees via an RBG module to allow for remote monitoring of the bees' health
from m5stack import *
from m5ui import *
from uiflow import *
from flow import ezdata
import wifiCfg
import unit

setScreenColor(0x222222)
rgb_0 = unit.get(unit.RGB, unit.PORTB)


reply = None

wifiCfg.autoConnect(lcdShow=False)

label0 = M5TextBox(58, 41, "Status: ", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(126, 40, "Loading...", lcd.FONT_Default, 0xFFFFFF, rotate=0)




while True:
  reply = ezdata.getData('R3jYwSPOVonYjxJvnWp8wnHeheBZv9HG', 'transfer')
  if reply == 'danger':
    label1.setText('Danger')
    label1.setColor(0xff0000)
    rgb_0.setColorAll(0xff0000)
  elif reply == 'warning':
    label1.setText('Warning')
    label1.setColor(0xffcc33)
    rgb_0.setColorAll(0xffcc00)
  elif reply == 'ok':
    label1.setText('Ok')
    label1.setColor(0x33cc00)
    rgb_0.setColorAll(0x33cc00)
  wait_ms(2)

Tracking Bee Movements

MicroPython
This code is responsible for tracking the movement of bees in and out of farming sections. Light sensors are used to determine if the direction bees are moving accurately. This code will also signal for the scented spray (Servo Motor is used in place) to be used to manipulate bee movements
from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
pbhub_0 = unit.get(unit.PBHUB, unit.PORTA)
servo_0 = unit.get(unit.SERVO, unit.PORTB)


NUM = None
NUM2 = None
NUM3 = None
NUM4 = None
CHECK = None
NUM6 = None
check2 = None
check3 = None
che = None



label0 = M5TextBox(215, 80, "Loading...", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(215, 164, "Loading...", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(30, 164, "Number of Bees Inside:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label5 = M5TextBox(69, 80, "Latest Movement:", lcd.FONT_Default, 0xFFFFFF, rotate=0)

from numbers import Number




NUM = 0
NUM2 = 0
NUM3 = 0
NUM4 = 0
CHECK = 0
NUM6 = 0
check2 = 0
check3 = 0
che = False
while True:
  che = False
  if 700 < (pbhub_0.analogRead(0)):
    NUM = 1
    if check3 == 0:
      check2 = 1
  else:
    NUM = 0
  if 700 < (pbhub_0.analogRead(1)):
    NUM2 = 1
    if check2 == 0:
      check3 = 1
  else:
    NUM2 = 0
  if NUM == 1 and NUM2 == 1:
    CHECK = 1
  if CHECK == 1:
    if NUM == 1 and NUM2 == 0:
      while 700 > (pbhub_0.analogRead(1)):
        if che == True:
          break
        if check3 == 1:
          while 700 > (pbhub_0.analogRead(0)):
            label0.setText('Go in')
            CHECK = 0
            NUM3 = 1
            che = True
            check3 = 0
            break
        else:
          while 700 > (pbhub_0.analogRead(0)):
            check2 = 0
            che = True
            break
    elif NUM == 0 and NUM2 == 1:
      while 700 > (pbhub_0.analogRead(0)):
        if che == True:
          break
        while 700 > (pbhub_0.analogRead(1)):
          if check2 == 1:
            label0.setText('Go out')
            CHECK = 0
            NUM4 = 1
            che = True
            check2 = 0
            break
          else:
            while 700 > (pbhub_0.analogRead(1)):
              check3 = 0
              che = True
              break
  if NUM3 == 1:
    NUM3 = 0
    NUM6 = (NUM6 if isinstance(NUM6, Number) else 0) + 1
    label2.setText(str(NUM6))
  elif NUM4 == 1:
    NUM4 = 0
    NUM6 = (NUM6 if isinstance(NUM6, Number) else 0) + -1
    label2.setText(str(NUM6))
  if NUM6 >= 10:
    servo_0.write_angle(90)
  else:
    servo_0.write_angle(0)
  wait_ms(2)

Credits

JS Chong

JS Chong

1 project • 1 follower

Comments