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.

Posted by Pete W on 2016-04-01T00:33:02-04:00

Categories: Complete, General Purpose, Intermediate, Internet of Things (IoT), SeeedStudio BeagleBone Green

The Problem:

My country (Perú) is known for its varied climate, and in these winter / summer weather is misleading, because in the morning sun out much but at night (early morning) starts to rain, some yes, some no.

And this is a problem when one tends laundry clothes to dry (usually do in outside the house), because one usually leaves the washing in the evening and during the night expected to finish drying, but when it rains it gets wet again. It might seem that it is easy to see the rain, but is not, because the rains are usually mild (so are the rains in my country) being inside the house you can not hear or feel the rain (except sometimes it rains strong).

Solution

Step One: Capturing Data

Connect the sensor to Analog Input Pin, in this case P9_39.

Testing data read for sensor

import Adafruit_BBIO.ADC as ADC

ADC.setup()

value = ADC.read_raw("P9_39")

print value


sensor for detect rain

We put the sensor inside a litle plastic cup, at rain, the water will be acumulated and value reading will change.

Step Two: Creating Store for Data

In this case, for easy collecting of data. I gonna use Ubidots Service

Creating Source Data and VariableNoneNoneNone

Don’t forget to copy the ID for Variable

For show the data collected, we will create a widget on dashboard

Creating widget on dashboardNoneNoneNoneNoneNoneNone

Step Three: Sending Data

Ubidots Free Service, is limited to 500,000 pushes for month, then for not raise that cantity we going to limit the data sending only when the data readed raise a fix value.

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)


You will need install the 
python library
.

Step Four: Configurating Trigger

We will to create un trigger event, for send a email when the value of sensor is less than 1,600 (when water will accumulate).

NoneNoneNoneNoneNoneNoneNoneNoneNoneNone

Step Five: Get Fun

Now you can monitoring more sensor, as temperature, (:

Comments are not currently available for this post.