pimoroni / enviro

MIT License
101 stars 79 forks source link

Enviro Indoor not waking up on USB power #224

Closed mfru closed 1 month ago

mfru commented 1 month ago

Hi, I am quite new to microcontrollers and Enviro, so apologies if I am asking obvious things.

I set up an Enviro Indoor while plugged into my workstation and wanted to test if it automatically takes readings and uploads them to Adafruit IO according to schedule before setting it up with a battery pack.

However, it will not take a reading on its own, rather it only does so when I press the RESET button. POKE does nothing, neither blinking the LED nor producing log output.

In the log you will notice that each time the wake reason says rtc_alarm which is not true. I pressed the RESET button at these times which woke the device up and produced one reading, setting a new alarm and going back to waiting for the alarm to happen. But the alarm never fires.

I am using Thonny to connect to the device.

Did I misconfigure something?

This is my config:

# enviro config file

# you may edit this file by hand but if you enter provisioning mode
# then the file will be automatically overwritten with new details

provisioned = True

# enter a nickname for this board
nickname = 'enviro-indoor'

# network access details
wifi_ssid = '<REDACTED>'
wifi_password = '<REDACTED>'
wifi_country = 'AT' # default config had GB 

# how often to wake up and take a reading (in minutes)
reading_frequency = 2

# how often to trigger a resync of the onboard RTC (in hours)
resync_frequency = 168

# where to upload to ("http", "mqtt", "adafruit_io", "influxdb")
destination = 'adafruit_io'

# how often to upload data (number of cached readings)
upload_frequency = 5

# web hook settings
custom_http_url = ''
custom_http_username = ''
custom_http_password = ''

# mqtt broker settings
mqtt_broker_address = ''
mqtt_broker_username = ''
mqtt_broker_password = ''
# mqtt broker if using local SSL
mqtt_broker_ca_file = None

# adafruit ui settings
adafruit_io_username = '<REDACTED>'
adafruit_io_key = '<REDACTED>'

# influxdb settings
influxdb_org = ''
influxdb_url = ''
influxdb_token = ''
influxdb_bucket = ''

# grow specific settings
auto_water = False
moisture_target_a = 50
moisture_target_b = 50
moisture_target_c = 50

# compensate for usb power
usb_power_temperature_offset = 4.5

and the corresponding logs:

2024-05-08 12:49:30 [info     / 144kB] > performing startup
2024-05-08 12:49:30 [debug    / 142kB]   - running Enviro 0.0.10, MicroPython v1.22.2, enviro v1.22.2 on 2024-03-06
2024-05-08 12:49:30 [info     / 137kB]   - wake reason: rtc_alarm
2024-05-08 12:49:30 [debug    / 135kB]   - turn on activity led
2024-05-08 12:49:30 [info     / 133kB] > 1 cache file(s) still to upload
2024-05-08 12:49:30 [info     / 130kB] > connecting to wifi network '<REDACTED>'
2024-05-08 12:49:31 [info     / 126kB] > MAC: 28:cd:c1:08:c5:ce
2024-05-08 12:49:31 [info     / 124kB] > active: 0, status: 0 (Link is down)
2024-05-08 12:49:31 [info     / 122kB] > Ready for connection!
2024-05-08 12:49:31 [info     / 120kB] > Connecting to SSID <REDACTED> (password: <REDACTED>)...
2024-05-08 12:49:31 [info     / 115kB] > active: 1, status: 1 (Connected to wifi)
2024-05-08 12:49:32 [info     / 111kB] > active: 1, status: 1 (Connected to wifi)
2024-05-08 12:49:32 [info     / 142kB] > active: 1, status: 1 (Connected to wifi)
2024-05-08 12:49:33 [info     / 123kB] > active: 1, status: 1 (Connected to wifi)
2024-05-08 12:49:34 [info     / 119kB] > active: 1, status: 2 (Connected to wifi, but no IP address)
2024-05-08 12:49:34 [info     / 115kB] > active: 1, status: 3 (Connect to wifi with an IP address)
2024-05-08 12:49:34 [info     / 113kB] > Connected successfully!
2024-05-08 12:49:35 [info     / 110kB] > IP: 192.168.0.227, Subnet: 255.255.255.0, Gateway: 192.168.0.1, DNS: 192.168.0.1
2024-05-08 12:49:35 [info     / 108kB] > Elapsed: 4267ms
2024-05-08 12:49:35 [info     / 140kB] > uploading cached readings to Adafruit.io: <REDACTED>
2024-05-08 12:49:36 [info     / 119kB]   - uploaded 2024-05-08T12_39_14Z.json
2024-05-08 12:49:36 [info     / 117kB] > Disconnecting wireless after upload
2024-05-08 12:49:36 [info     / 115kB] > going to sleep
2024-05-08 12:49:36 [debug    / 113kB]   - clearing and disabling previous alarm
2024-05-08 12:49:36 [info     / 111kB]   - setting alarm to wake at 12:50pm
2024-05-08 12:49:36 [info     / 108kB]   - shutting down
2024-05-08 12:49:36 [debug    / 106kB]   - on usb power (so can't shutdown). Halt and wait for alarm or user reset instead
2024-05-08 12:58:15 [info     / 144kB] > performing startup
2024-05-08 12:58:15 [debug    / 142kB]   - running Enviro 0.0.10, MicroPython v1.22.2, enviro v1.22.2 on 2024-03-06
2024-05-08 12:58:15 [info     / 137kB]   - wake reason: rtc_alarm
2024-05-08 12:58:15 [debug    / 135kB]   - turn on activity led
2024-05-08 12:58:15 [debug    / 130kB] > 96 blocks free out of 212
2024-05-08 12:58:15 [debug    / 128kB] > taking new reading
2024-05-08 12:58:15 [info     / 124kB]   - seconds since last reading: 1142
2024-05-08 12:58:16 [debug    / 118kB] > caching reading for upload
2024-05-08 12:58:16 [info     / 113kB] > 1 cache file(s) not being uploaded. Waiting until there are 5 file(s)
2024-05-08 12:58:16 [info     / 111kB] > going to sleep
2024-05-08 12:58:16 [debug    / 143kB]   - clearing and disabling previous alarm
2024-05-08 12:58:16 [info     / 140kB]   - setting alarm to wake at 13:00pm
2024-05-08 12:58:16 [info     / 138kB]   - shutting down
2024-05-08 12:58:16 [debug    / 136kB]   - on usb power (so can't shutdown). Halt and wait for alarm or user reset instead
2024-05-08 13:10:32 [info     / 144kB] > performing startup
2024-05-08 13:10:32 [debug    / 142kB]   - running Enviro 0.0.10, MicroPython v1.22.2, enviro v1.22.2 on 2024-03-06
2024-05-08 13:10:32 [info     / 137kB]   - wake reason: rtc_alarm
2024-05-08 13:10:32 [debug    / 135kB]   - turn on activity led
2024-05-08 13:10:32 [debug    / 130kB] > 96 blocks free out of 212
2024-05-08 13:10:32 [debug    / 128kB] > taking new reading
2024-05-08 13:10:32 [info     / 124kB]   - seconds since last reading: 737
2024-05-08 13:10:33 [debug    / 118kB] > caching reading for upload
2024-05-08 13:10:33 [info     / 113kB] > 2 cache file(s) not being uploaded. Waiting until there are 5 file(s)
2024-05-08 13:10:33 [info     / 111kB] > going to sleep
2024-05-08 13:10:33 [debug    / 142kB]   - clearing and disabling previous alarm
2024-05-08 13:10:33 [info     / 140kB]   - setting alarm to wake at 13:12pm
2024-05-08 13:10:33 [info     / 138kB]   - shutting down
2024-05-08 13:10:33 [debug    / 136kB]   - on usb power (so can't shutdown). Halt and wait for alarm or user reset instead
mfru commented 1 month ago

It was the configuration of Thonny.

By default it seems all checkboxes for the interpreter are checked, which includes "Interrupt working program on connect".

By unchecking it Thonny does not, well, interrupt the running device anymore and it happily takes readings and does uploads.