BRUH sensor using microphython

Starting this thread to post updates on this project and get feedback - ideas. I know @rpitera was interested

Taking the BRUH sensor with NodeMCU but coding using micropython and Zerynth - intro on

So far have my hardware hooked up, and working through some of the examples on:
https://docs.zerynth.com/latest/official/core.zerynth.stdlib/examples/examples.html this list is useful for inspiration

Started with the LED, and setup a mini webserver. I have to say it is pretty straightforward using the Zerynth app and micropython.

Features of this fork of the multisensor - please add any suggestions:

  1. Micropython
  2. Mini web server to display sensor data
  3. Suggestions… e.g. other supported sensors

1 Like

This looks cool!

OK making some progress on this, all in micropython below :slight_smile:
Have temperature, humidity and motion being published over MQTT, with visual indication via the built in LED. Next stage is to add sound and light level sensors, then 3D print a case. Any suggestions welcome.
NOTE: I would like to clarify that this project is in no way associated with BRUH other than taking inspiration from his work. Unfortunately I am unable to edit the title of this thread.

import pycom
import time
from machine import Pin
from dth import DTH

# The callback if motion on PIR
def pin_handler(arg):
    print("Motion detected")
    mqtt.publish("wipy/Motion", "Motion detected")
    pycom.rgbled(0x7f0000) # red
    time.sleep_ms(500)
    pycom.rgbled(0x7f7f00) # yellow

pycom.heartbeat(False)
pycom.rgbled(0x000008) # blue

pir = Pin('G4',mode=Pin.IN,pull=Pin.PULL_UP)
pir.callback(Pin.IRQ_RISING, pin_handler)    # Only detect on rising

th = DTH(Pin('P3', mode=Pin.OPEN_DRAIN),0)
time.sleep(2)

while True:
    pycom.rgbled(0x000008) # blue
    time.sleep(1)
    result = th.read()
    if result.is_valid():
        pycom.rgbled(0x001000) # green
        gc.collect()   # perform garbage collection
        print(gc.mem_free())
        mqtt.publish("wipy/Memory", str(gc.mem_free()))

        print("Temperature: %d C" % result.temperature)
        mqtt.publish("wipy/Temperature", str(result.temperature))

        print("Humidity: %d %%" % result.humidity)
        mqtt.publish("wipy/Humidity", str(result.humidity))
    time.sleep(1)

1 Like