from network import LoRa import socket import time import ubinascii import binascii import pycom from pysense import Pysense from mqtt import MQTTClient from network import WLAN import machine from LIS2HH12 import LIS2HH12 from SI7006A20 import SI7006A20 from LTR329ALS01 import LTR329ALS01 from MPL3115A2 import MPL3115A2,ALTITUDE,PRESSURE # Initialise LoRa in LORAWAN mode. # Please pick the region that matches where you are using the device: # Asia = LoRa.AS923 # Australia = LoRa.AU915 # Europe = LoRa.EU868 # United States = LoRa.US915 pycom.heartbeat(False) pycom.rgbled(0x0A0A08) # white py = Pysense() si = SI7006A20(py) li = LIS2HH12(py) lt = LTR329ALS01(py) def sub_cb(topic, msg): print(msg) wlan = WLAN(mode=WLAN.STA, , antenna=WLAN.INT_ANT) wlan.connect("IoT_Guest", auth=(WLAN.WPA2, "IoT_L@b_2020"), timeout=5000) while not wlan.isconnected(): machine.idle() print("Connected to WiFi\n") client = MQTTClient("device_id", "io.adafruit.com",user="your_username", password="your_api_key", port=1883) client.set_callback(sub_cb) client.connect() client.subscribe(topic="kulnierz/groups/antyWIMIR") while True: print("Sending ON") client.publish(topic="kulnierz/groups/antyWIMIR", msg=str()) time.sleep(1) print("Sending OFF") client.publish(topic="kulnierz/groups/antyWIMIR", msg="OFF") client.check_msg()
mypage
Adafruit Playground is a wonderful place to share what you find interesting. Have a cool project you are working on? Have a bit of code that you think others will find useful? Want to show off your electronics workbench? You have come to the right place.
Adafruit Playground is a safe place to share with the wonderful Adafruit community of makers and doers.
Click here to learn more about Adafruit Playground and how to get started.
This page (mypage) was last updated on March 08, 2024.
Text editor powered by tinymce.