Scott Hladun
Published

Entertainment Water Feature

Every backyard needs that little something special. I've created a water fountain that reacts to music and can be controlled wirelessly.

IntermediateShowcase (no instructions)10 hours2,075

Things used in this project

Hardware components

Omega2 Plus
Onion Corporation Omega2 Plus
×1
4-CHANNEL RELAY CONTROLLER FOR I2C
ControlEverything.com 4-CHANNEL RELAY CONTROLLER FOR I2C
×1
12v water pump
×2
Adafruit NeoPixel Strip
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1

Software apps and online services

Blynk
Blynk
Ubidots
Ubidots

Story

Read more

Schematics

Water Feature Schematic

Code

main.py

Python
import os
import json
import oneWire
import temperatureSensor
import ubidots
import blynk
import pumps
import music
# import config
dirName = os.path.dirname(os.path.abspath(__file__))
# read the config file relative to the script location
with open( '/'.join([dirName, 'config.json']) ) as f:
    config = json.load(f)

token = config["token"]
deviceName = config["deviceName"]
oneWireGpio = 19

def __main__():
    # initialize oled
    #oledHelper.init(dirName)
    
    device = ubidots.UbidotsDevice(token, deviceName)

    if not oneWire.setupOneWire(str(oneWireGpio)):
        print "Kernel module could not be inserted. Please reboot and try again."
        return -1

    # get the address of the temperature sensor
    # 	it should be the only device connected in this experiment    
    sensorAddress = oneWire.scanOneAddress()

    # instantiate the temperature sensor object
    sensor = temperatureSensor.TemperatureSensor("oneWire", { "address": sensorAddress, "gpio": oneWireGpio })
    if not sensor.ready:
        print "Sensor was not set up correctly. Please make sure that your sensor is firmly connected to the GPIO specified above and try again."
        return -1

    # check and print the temperature
    temperature = sensor.readValue()
    dataPoint = {
        "temperature": temperature
    }
    device.pushDataPoint(dataPoint)
    
    # write to oled screen
    #oledHelper.writeMeasurements(temperature)

if __name__ == '__main__':
    __main__()

Credits

Scott Hladun

Scott Hladun

0 projects • 4 followers

Comments