Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Laurence Daxes
Published © MIT

Beagle Rain Detector

My country (Perú) is known for its varied climate, because in the morning sun out much but at night (early morning) starts to rain.

IntermediateFull instructions provided4 hours1,567
Beagle Rain Detector

Things used in this project

Story

Read more

Schematics

BeagleBone Rain Detector Schematics

I had do it in fritzing but I don't found the components :/

Code

Installing Ubidot Library

Python
For use the Python Ubidot API, on Embedded Linux
sudo apt-get update
sudo apt-get upgrade

sudo apt-get install python-setuptools
sudo easy_install pip
sudo pip install ubidots

Collect and Send Data

Python
Monitoring the sensor value, and sending to data service.
import Adafruit_BBIO.ADC as ADC
from ubidots import ApiClient

def send_data(val):
    #Create an "API" object
    api = ApiClient("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
    #Create a "Variable" object
    test_variable = api.get_variable("56f5fdb17625426671c22716")
    #Write the value to your variable in Ubidots
    test_variable.save_value({'value':val})

ADC.setup()
alertval = 1600
over = False
value = 0
while True:
    nvalue = ADC.read_raw("P9_39")
    if nvalue != value:
        value = nvalue
        print value
    if nvalue > alertval and over == False:
        print 'up alert value ',value
        over = True
        send_data(nvalue)
    if nvalue < alertval and over == True:
        print 'down alert value ',value
        over = False
        send_data(nvalue)

Credits

Laurence Daxes

Laurence Daxes

19 projects • 36 followers
Systems Engineer Bachellor, I Love technology, and IoT World https://youtube.com/c/DaxesHacks
Thanks to Seed Studio.

Comments