示例#1
0
    server.starttls()
    server.login(sender, password)
    server.sendmail(sender, recipient, msg+body)
    server.quit()

logging.basicConfig(level=logging.INFO)

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

c1 = load([])

readings = []

conn = ControlMyPi('*****@*****.**', 'password', 'moisture', 'Moisture monitor', p, on_msg)

delta = datetime.timedelta(minutes=30)
next_time = datetime.datetime.now()

delta_email = datetime.timedelta(days=1)
next_email_time = datetime.datetime.now()

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}
示例#2
0
def switch_led(state):
    if led_state[GPIO_NUM] != state:
        GPIO.output(GPIO_NUM, not state)  #Low to glow!
        conn.update_status({'state': 'on' if state else 'off'})
        led_state[GPIO_NUM] = state


def on_control_message(conn, key, value):
    if key == 'on_button':
        switch_led(True)
    elif key == 'off_button':
        switch_led(False)


def main_loop():
    switch_led(True)
    while True:
        time.sleep(3)  #Yield for a while but keep main thread running


conn = ControlMyPi(JABBER_ID, JABBER_PASSWORD, SHORT_ID, FRIENDLY_NAME,
                   PANEL_FORM, on_control_message)
if conn.start_control():
    try:
        main_loop()
    finally:
        conn.stop_control()
else:
    print("FAILED TO CONNECT")
        conn.update_status({'echo':'Pi echoes back: '+value})
    else:
        print key, value

def main_loop():
    # Block here. When you exit this function the connection to controlmypi.com will be closed
    raw_input("Press Enter to finish\n")

# Setup logging - change the log level here to debug faults
logging.basicConfig(level=logging.ERROR, format='%(levelname)-8s %(message)s')

jid = raw_input("Jabber ID: ")
password = getpass.getpass("Jabber password: "******"Control panel ID: ")
name = raw_input("Control panel name: ")

panel_form = [
             [ ['L','Echo box:'] ],
             [ ['E','echobox','send'],['S','echo','-'] ]
             ]

conn = ControlMyPi(jid, password, id, name, panel_form, on_control_message, 'hid', on_registered)
print "Connecting to ControlMyPi..."
if conn.start_control():
    try:
        main_loop()
    finally:
        conn.stop_control()
else:
    print("FAILED TO CONNECT")
示例#4
0
    
# Start the GPS
gps = GPS()

# Create the Accelerometer object. Change to acc=None if you don't have an accelerometer.
acc = Accelerometer()

# Control My Pi
def on_control_message(conn, key, value):
    if key == 'start_button':    
        rec.start()
    elif key == 'stop_button':
        rec.stop()

conn = ControlMyPi(JABBER_ID, JABBER_PASSWORD, SHORT_ID, FRIENDLY_NAME, PANEL_FORM, on_control_message)

# 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:
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()
示例#6
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()
示例#7
0
    else:
        print key, value


def main_loop():
    # Block here. When you exit this function the connection to controlmypi.com will be closed
    raw_input("Press Enter to finish\n")


# Setup logging - change the log level here to debug faults
logging.basicConfig(level=logging.ERROR, format='%(levelname)-8s %(message)s')

jid = raw_input("Jabber ID: ")
password = getpass.getpass("Jabber password: "******"Control panel ID: ")
name = raw_input("Control panel name: ")

panel_form = [[['L', 'Echo box:']],
              [['E', 'echobox', 'send'], ['S', 'echo', '-']]]

conn = ControlMyPi(jid, password, id, name, panel_form, on_control_message,
                   'hid', on_registered)
print "Connecting to ControlMyPi..."
if conn.start_control():
    try:
        main_loop()
    finally:
        conn.stop_control()
else:
    print("FAILED TO CONNECT")
示例#8
0
    server.sendmail(sender, recipient, msg + body)
    server.quit()


logging.basicConfig(level=logging.INFO)

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

c1 = load([])

readings = []

conn = ControlMyPi('*****@*****.**', 'password', 'moisture', 'Moisture monitor',
                   p, on_msg)

delta = datetime.timedelta(minutes=30)
next_time = datetime.datetime.now()

delta_email = datetime.timedelta(days=1)
next_email_time = datetime.datetime.now()

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}
示例#9
0
# Start the GPS
gps = GPS()

# Create the Accelerometer object. Change to acc=None if you don't have an accelerometer.
acc = Accelerometer()


# Control My Pi
def on_control_message(conn, key, value):
    if key == 'start_button':
        rec.start()
    elif key == 'stop_button':
        rec.stop()


conn = ControlMyPi(JABBER_ID, JABBER_PASSWORD, SHORT_ID, FRIENDLY_NAME,
                   PANEL_FORM, on_control_message)

# 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)
示例#10
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()
示例#11
0
passMail = 'visualizar'
updateControlMyPi = True
updateEmailSender = False

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

c1 = load([])

readings = []



if updateControlMyPi:
	conn = ControlMyPi(idMail, passMail, 'moisbanc', 'Sensor de Humedad Bancal', p, on_msg)

delta = datetime.timedelta(minutes=120)
next_time = datetime.datetime.now()

delta_email = datetime.timedelta(days=1)
next_email_time = datetime.datetime.now()

if conn.start_control():
    try:
        while True:
            dt = datetime.datetime.now()
            m = mcp3008.read_pct(3)
            readings.append(m)
            to_update = {'moist':m}
            if(debugMode):
示例#12
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()