Published © CC BY-NC-SA

Monty - the Maker Faire Measuring Monster

We love going to Maker Faires, but 2020 has decided otherwise. So instead, we are building a suitable substitute called Monty, who will capt

IntermediateFull instructions provided15 hours253
Monty - the Maker Faire Measuring Monster

Things used in this project

Hardware components

Raspberry Pi 4 Model B
Raspberry Pi 4 Model B
×1
PIR Motion Sensor (generic)
PIR Motion Sensor (generic)
×1
Evaluation Board, ADS1015 12-Bit ADC
Evaluation Board, ADS1015 12-Bit ADC
×1
Sounds Sensor
×1
NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1
Bird Cage
×1
Fake Fur
×1
Red Paint
×1
Plastic ornament balls
×2
Round furniture pads
×3
White spray paint
×1

Software apps and online services

ThingSpeak API
ThingSpeak API

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Glue
Multitool, Screwdriver
Multitool, Screwdriver
Needle and thread
Cleaning supplies

Story

Read more

Schematics

Poster

Wiring Diagram

Code

MontyClean.py

Python
# Generic Imports
import time
import requests
import board
import busio
import threading
import json
from random import randrange

# Setup motion sensor
from gpiozero import MotionSensor
pir = MotionSensor(4)

# Initialize I2C bus and sensor.
i2c = busio.I2C(board.SCL, board.SDA)

# Analog Digital Converter setup
import adafruit_ads1x15.ads1015 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
ads = ADS.ADS1015(i2c)
chan = AnalogIn(ads, ADS.P0)

#NeoPixel Setup
import neopixel
pixels = neopixel.NeoPixel(board.D18,30)
red = (252, 3, 3)
orange = (252, 177, 3)
yellow = (252, 248, 3)
green = (3, 252, 53)
blue = (0, 213, 255)
indigo = (115, 3, 252)
violet = (242, 0, 255)
rainbow = [red, orange, yellow, green, blue, indigo, violet]
nocolour = (0,0,0)

def readSensors():
    
    readings = {}

    noise = chan.value
    readings['noise'] = noise

    movement = pir.value
    readings['movement'] = movement

    epoch = int(time.time())
    readings['epoch'] = epoch

    return readings

def saveToJSON(readings):
    
    try:
        filePath ='/home/pi/mm/data.json'
        input_file_data = open(filePath)
        readingsFile = json.load(input_file_data)
        
    except:
        readingsFile = []

    readingsFile.append(readings)
    
    with open(filePath, 'w') as outfile:
            json.dump(readingsFile, outfile) 

            
def sendData(readings):
    
    url = 'Your super Secret URL, '.format(eventId,readings['epoch'],readings['noise'],readings['movement'])
    response = requests.request("GET", url)

# Tracking variables
secondsPassed = 0
eventId = 0

while True:

    secondsPassed += 1
    time.sleep(0.999)

    colour = randrange(len(rainbow))
    pixels.fill(rainbow[colour])

    readings = readSensors()
    saveToJSON(readings)

    if secondsPassed == 60:

        secondsPassed = 0
        sendDataThread = threading.Thread(target=sendData(readings))
        sendDataThread.start()




    

Credits

Comments