diff --git a/enviro/__init__.py b/enviro/__init__.py index a67ad26..2e99b74 100644 --- a/enviro/__init__.py +++ b/enviro/__init__.py @@ -105,24 +105,6 @@ def stop_activity_led(): # read the state of vbus to know if we were woken up by USB vbus_present = Pin("WL_GPIO2", Pin.IN).value() -#BUG Temporarily disabling battery reading, as it seems to cause issues when connected to Thonny -""" -# read battery voltage - we have to toggle the wifi chip select -# pin to take the reading - this is probably not ideal but doesn't -# seem to cause issues. there is no obvious way to shut down the -# wifi for a while properly to do this (wlan.disonnect() and -# wlan.active(False) both seem to mess things up big style..) -old_state = Pin(WIFI_CS_PIN).value() -Pin(WIFI_CS_PIN, Pin.OUT, value=True) -sample_count = 10 -battery_voltage = 0 -for i in range(0, sample_count): - battery_voltage += (ADC(29).read_u16() * 3.3 / 65535) * 3 -battery_voltage /= sample_count -battery_voltage = round(battery_voltage, 3) -Pin(WIFI_CS_PIN).value(old_state) -""" - # set up the button, external trigger, and rtc alarm pins rtc_alarm_pin = Pin(RTC_ALARM_PIN, Pin.IN, Pin.PULL_DOWN) # BUG This should only be set up for Enviro Camera @@ -355,7 +337,7 @@ def get_sensor_readings(): readings = get_board().get_sensor_readings(seconds_since_last) - if config.enable_battery_voltage: + if hasattr(config, 'enable_battery_voltage') and config.enable_battery_voltage: readings["voltage"] = get_battery_voltage()