Exemplo n.º 1
0
wifi_ssid = "raspiWLAN"
wifi_passwd = ''
broker_addr = "test.mosquitto.org"


def settimeout(duration):
    pass


def on_message(topic, msg):

    print("topic is: " + str(topic))
    print("msg is: " + str(msg))


### if __name__ == "__main__":

ufun.connect_to_wifi(wifi_ssid, wifi_passwd)

client = MQTTClient("dev_id", broker_addr, 1883)
client.set_callback(on_message)

if not client.connect():
    print("Connected to broker: " + broker_addr)
client.subscribe('lopy/lights')

print('Waiting messages...')
while 1:
    client.wait_msg()
Exemplo n.º 2
0
	r = dd.decode()
	response = r.split('\n')[0]
	if response == "HTTP/1.1 200 OK":
	    print("Got: "+response)
	else:
	    print("ERROR Got: "+response)


def get_sdata(lite_s):

    v = raw2Lux(lite_s.light())
    print("Light (raw2lux): " + str(v))
    
    return int(v)

ufun.connect_to_wifi(WIFI_SSID, "")


# Enabling PySense boards
py = Pysense()
# Digital Ambient Light Sensor
lite_s = LTR329ALS01(py)

#
# registering
#
rest_msg = "POST /registro.html HTTP/1.1\r\n"
rest_msg += 'Host: 192.168.4.1\r\n'
rest_msg += 'User-Agent: LoPy\r\n'
rest_msg += 'Content-Length: 19\r\n'
rest_msg += '\r\n'