Snippets

Matthew Jadud Dweet the Jade Plant micro:bit

Created by Matthew Jadud
import serial
import dweepy
import time

# Dweet out the data from the micro:bit
with serial.Serial('/dev/cu.usbmodem145422', 115200, timeout=1) as ser:

    while True:
        line = ser.readline()
        if len(line) > 0:
            reading = int(line)
            print(reading)
            result = dweepy.dweet_for('jade-plant-microbit', {'moisture': reading})
            print result
        time.sleep(5)

# For a setup script:
# virtualenv venv
# source venv/bin/activate
# pip install requests
# pip install pyserial
# pip install dweepy

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.