Ejemplo n.º 1
0
if conn.start_control():
    try:
        while True:
            dt = datetime.datetime.now()
            m = mcp3008.read_pct(5)
            readings.append(m)
            update_lcd(m)
            to_update = {'moist':m}
            
            # Update the chart?
            if dt > next_time:
                # Take the average from the readings list to smooth the graph a little
                avg = int(round(sum(readings)/len(readings)))             
                readings = []   
                c1 = append_chart_point(c1, [dt.strftime('%H:%M'), avg])
                save(c1)
                next_time = dt + delta
                to_update['chart1'] = c1
            conn.update_status(to_update)
            
            #Send an email?
            if dt > next_email_time:
                next_email_time = dt + delta_email
                if m < 40:
                    send_gmail('Your Name', '*****@*****.**', 'password', '*****@*****.**', 'Moisture sensor level', 'The level is now: %s' % m)
            
            sleep(30)
    finally:
        conn.stop_control()
Ejemplo n.º 2
0
# Recording
rec = Recorder(gps, conn)

def on_rec_button():
    if rec.recording == 's':
        rec.start()
    else:
        rec.stop()    

# Start the TextStar LCD. Change to lcd=None if you don't have a TextStar LCD.
lcd = TextStar(on_rec_button)
        
if conn.start_control():
    try:
        conn.update_status( {'recording_state':'Stopped'} )
        # Start main loop
        old_time_stamp = 'old'
        CMP_UPDATE_DELAY = 50
        cmp_update = 0
        
        while True:
            #Read the 3 axis accelerometer
            if acc:
                xyz = acc.read_accelerometer()
            else:
                xyz = None
                
            #Read GPS
            gps.read()
                    
Ejemplo n.º 3
0
from time import sleep
import mcp3008
from controlmypi import ControlMyPi
import logging


def on_msg(conn, key, value):
    pass


logging.basicConfig(level=logging.INFO)

p = [
    [['G', 'moist', 'level', 0, 0, 1023]],
]

conn = ControlMyPi('*****@*****.**', 'password3649', 'moisture',
                   'Moisture monitor', p, on_msg)
if conn.start_control():
    try:
        while True:
            m = mcp3008.readadc(5)
            conn.update_status({'moist': m})
            sleep(30)
    finally:
        conn.stop_control()
Ejemplo n.º 4
0
import datetime

def on_msg(conn, key, value):
    pass

def append_chart_point(chart, point):
    if len(chart) >= 10:
        del chart[0]
    chart.append(point)
    return chart

logging.basicConfig(level=logging.INFO)

p = [ 
    [ ['G','moist','% level',0,0,100], ['LC','chart1','Time','Value',0,100] ], 
    ]

c1 = []

conn = ControlMyPi('*****@*****.**', 'password', 'moistcmp2', 'Moisture monitor 2', p, on_msg)
if conn.start_control():
    try:
        while True:
            dt = datetime.datetime.now().strftime('%H:%M:%S')
            m = mcp3008.read_pct(5)                
            c1 = append_chart_point(c1, [dt, m])
            conn.update_status({'moist':m,'chart1':c1})
            sleep(30)
    finally:
        conn.stop_control()
Ejemplo n.º 5
0
if conn.start_control():
    try:
        while True:
            dt = datetime.datetime.now()
            m = mcp3008.read_pct(5)
            readings.append(m)
            update_lcd(m)
            to_update = {'moist': m}

            # Update the chart?
            if dt > next_time:
                # Take the average from the readings list to smooth the graph a little
                avg = int(round(sum(readings) / len(readings)))
                readings = []
                c1 = append_chart_point(c1, [dt.strftime('%H:%M'), avg])
                save(c1)
                next_time = dt + delta
                to_update['chart1'] = c1
            conn.update_status(to_update)

            #Send an email?
            if dt > next_email_time:
                next_email_time = dt + delta_email
                if m < 40:
                    send_gmail('Your Name', '*****@*****.**', 'password',
                               '*****@*****.**', 'Moisture sensor level',
                               'The level is now: %s' % m)

            sleep(30)
    finally:
        conn.stop_control()
Ejemplo n.º 6
0
rec = Recorder(gps, conn)


def on_rec_button():
    if rec.recording == 's':
        rec.start()
    else:
        rec.stop()


# Start the TextStar LCD. Change to lcd=None if you don't have a TextStar LCD.
lcd = TextStar(on_rec_button)

if conn.start_control():
    try:
        conn.update_status({'recording_state': 'Stopped'})
        # Start main loop
        old_time_stamp = 'old'
        CMP_UPDATE_DELAY = 50
        cmp_update = 0

        while True:
            #Read the 3 axis accelerometer
            if acc:
                xyz = acc.read_accelerometer()
            else:
                xyz = None

            #Read GPS
            gps.read()
Ejemplo n.º 7
0

def append_chart_point(chart, point):
    if len(chart) >= 10:
        del chart[0]
    chart.append(point)
    return chart


logging.basicConfig(level=logging.INFO)

p = [
    [['G', 'moist', '% level', 0, 0, 100],
     ['LC', 'chart1', 'Time', 'Value', 0, 100]],
]

c1 = []

conn = ControlMyPi('*****@*****.**', 'password', 'moistcmp2',
                   'Moisture monitor 2', p, on_msg)
if conn.start_control():
    try:
        while True:
            dt = datetime.datetime.now().strftime('%H:%M:%S')
            m = mcp3008.read_pct(5)
            c1 = append_chart_point(c1, [dt, m])
            conn.update_status({'moist': m, 'chart1': c1})
            sleep(30)
    finally:
        conn.stop_control()
Ejemplo n.º 8
0
from time import sleep
import mcp3008
from controlmypi import ControlMyPi
import logging

def on_msg(conn, key, value):
    pass

logging.basicConfig(level=logging.INFO)

p = [ 
    [ ['G','moist','level',0,0,1023] ], 
    ]

conn = ControlMyPi('*****@*****.**', 'password', 'moisture', 'Moisture monitor', p, on_msg)
if conn.start_control():
    try:
        while True:
            m = mcp3008.readadc(5)
            conn.update_status({'moist':m})
            sleep(30)
    finally:
        conn.stop_control()