Moving to dotenv.
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
import machine
|
import machine
|
||||||
import network
|
import network
|
||||||
import wifi_config
|
|
||||||
import time
|
import time
|
||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
'''
|
load_dotenv()
|
||||||
|
|
||||||
|
"""
|
||||||
pico_funcs: Helper functions for things the pico can do.
|
pico_funcs: Helper functions for things the pico can do.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
def read_cpu_temp():
|
def read_cpu_temp():
|
||||||
"""
|
"""
|
||||||
@@ -22,12 +26,13 @@ def read_cpu_temp():
|
|||||||
cpu_temp_sensor = machine.ADC(4)
|
cpu_temp_sensor = machine.ADC(4)
|
||||||
reading = cpu_temp_sensor.read_u16() * cpu_temp_conversion_factor
|
reading = cpu_temp_sensor.read_u16() * cpu_temp_conversion_factor
|
||||||
temperature_c = 27 - (reading - 0.706) / 0.001721
|
temperature_c = 27 - (reading - 0.706) / 0.001721
|
||||||
temperature_f = temperature_c * 9/5. + 32.0
|
temperature_f = temperature_c * 9 / 5.0 + 32.0
|
||||||
return temperature_f
|
return temperature_f
|
||||||
|
|
||||||
|
|
||||||
def wlan_up(wlan):
|
def wlan_up(wlan):
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
wlan.connect(wifi_config.HOME_WIFI_SSID, wifi_config.HOME_WIFI_PWD)
|
wlan.connect(os.getenv("HOME_WIFI_SSID"), os.getenv("HOME_WIFI_PWD"))
|
||||||
|
|
||||||
# Wait for connect or fail
|
# Wait for connect or fail
|
||||||
max_wait = 10
|
max_wait = 10
|
||||||
@@ -43,6 +48,7 @@ def wlan_up(wlan):
|
|||||||
ifconfig = wlan.ifconfig()
|
ifconfig = wlan.ifconfig()
|
||||||
return ifconfig
|
return ifconfig
|
||||||
|
|
||||||
|
|
||||||
def led_error_code(led, error_code: int):
|
def led_error_code(led, error_code: int):
|
||||||
"""Blink LED for a given error code (int). error code == number of times to blink"""
|
"""Blink LED for a given error code (int). error code == number of times to blink"""
|
||||||
|
|
||||||
@@ -66,3 +72,4 @@ def led_error_code(led, error_code: int):
|
|||||||
blink_counter += 1
|
blink_counter += 1
|
||||||
# Make sure to turn off LED when this subroutine finished
|
# Make sure to turn off LED when this subroutine finished
|
||||||
led.value(False)
|
led.value(False)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user