Update code.py
This commit is contained in:
parent
440b1ba294
commit
854ee39fa2
1 changed files with 25 additions and 20 deletions
|
|
@ -13,11 +13,13 @@ import socketpool
|
|||
import wifi
|
||||
import displayio
|
||||
import adafruit_ntp
|
||||
import adafruit_connection_manager
|
||||
from adafruit_display_text import bitmap_label, wrap_text_to_lines
|
||||
from adafruit_bitmap_font import bitmap_font
|
||||
from adafruit_azureiot import IoTCentralDevice
|
||||
import adafruit_bme680
|
||||
from adafruit_lc709203f import LC709203F, PackSize
|
||||
import adafruit_max1704x
|
||||
#from adafruit_lc709203f import LC709203F, PackSize
|
||||
|
||||
|
||||
# Get wifi details and more from a secrets.py file
|
||||
|
|
@ -33,7 +35,8 @@ wifi.radio.connect(secrets["ssid"], secrets["password"])
|
|||
print("Connected to WiFi!")
|
||||
|
||||
# ntp clock - update tz_offset to your timezone
|
||||
pool = socketpool.SocketPool(wifi.radio)
|
||||
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
|
||||
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
|
||||
ntp = adafruit_ntp.NTP(pool, tz_offset=-4)
|
||||
rtc.RTC().datetime = ntp.datetime
|
||||
|
||||
|
|
@ -97,7 +100,7 @@ bme680.sea_level_pressure = 1013.25
|
|||
esp = None
|
||||
pool = socketpool.SocketPool(wifi.radio)
|
||||
device = IoTCentralDevice(
|
||||
pool, esp, secrets["id_scope"], secrets["device_id"], secrets["device_primary_key"]
|
||||
pool, ssl_context, secrets["id_scope"], secrets["device_id"], secrets["device_primary_key"]
|
||||
)
|
||||
|
||||
print("Connecting to Azure IoT Central...")
|
||||
|
|
@ -108,12 +111,13 @@ print("Connected to Azure IoT Central!")
|
|||
temperature_offset = -5
|
||||
|
||||
# Create sensor object, using the board's default I2C bus.
|
||||
battery_monitor = LC709203F(i2c)
|
||||
#battery_monitor = LC709203F(i2c)
|
||||
battery_monitor = adafruit_max1704x.MAX17048(board.I2C())
|
||||
|
||||
# Update to match the mAh of your battery for more accurate readings.
|
||||
# Can be MAH100, MAH200, MAH400, MAH500, MAH1000, MAH2000, MAH3000.
|
||||
# Choose the closest match. Include "PackSize." before it, as shown.
|
||||
battery_monitor.pack_size = PackSize.MAH2000
|
||||
#battery_monitor.pack_size = PackSize.MAH2000
|
||||
|
||||
temp = int((bme680.temperature * 9/5) + (32 + temperature_offset))
|
||||
humidity = int(bme680.relative_humidity)
|
||||
|
|
@ -225,3 +229,4 @@ while True:
|
|||
# delay
|
||||
time.sleep(1)
|
||||
print(azure_clock)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue