GithubHelp home page GithubHelp logo

enviro's Introduction

Enviro MicroPython firmware

About Enviro

Our Enviro range of boards offer a wide array of environmental sensing and data logging functionality. They are designed to be setup in location for months at a time and take regular measurements.

On top of their individual features the boards all share a common set of functions:

  • on-board Pico W with RP2040 MCU and WiFi functionality
  • accurate real-time clock (RTC) to maintain the time between boots
  • a collection of wake event triggers (user button, RTC, external trigger)
  • battery power input suitable for 1.8-5.5V input (ideal for 2x or 3x alkaline/NiMH cells or a single cell LiPo)
  • reset button for frictionless debugging
  • user button to trigger wake events or enter provisioning mode
  • activity and warn LEDs to show current status
  • Qw/ST connector to allow you to customise your sensor suite

These common features mean that the modules can run off very little power for long periods of time. During sleep (when the RTC remains active) the boards only consume a few microamps of power meaning they can last for months on a small battery pack. The modules wake up at regular intervals (or on a fixed schedule) to take a reading, store it, and go back to sleep.

As well as logging data locally Enviro boards can also use the Pico W's wireless functionality to upload the data they capture to a supported endpoint. Wireless communications take a lot of power so this should be done as infrequently as possible.

Powering Enviro boards

Enviro boards are designed to run for months on a set of batteries so that you can install them wherever they can gather the best data - perhaps on that high shelf in the corner of the kitchen that you can't quite reach, under a Stevenson screen in the back garden, or tucked in the shed.

You can use 3xAA or 3xAAA (either alkaline or NiMH), a single cell LiPo battery, or a USB cable to power Enviro boards.

Supported products

Supported endpoints

Documentation

enviro's People

Contributors

andypiper avatar ctrl-i avatar dave-ct avatar gadgetoid avatar helgibbons avatar jwillikers avatar lowfatcode avatar nils-s avatar rmp avatar sjefferson99 avatar zodiusinfuser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

enviro's Issues

HTTP endpoints: readings deleted on non-200 status code

Hi!

The documentation says that readings will only be deleted if an HTTP endpoint replies with a 200 status code.

My Python's a bit rusty, should line 34 be indented? Looks like readings are deleted no matter what status code is returned :-o

if result.status_code != 200:
logging.error(f" - failed to upload '{cache_file}' ({result.status_code} {result.reason})", cache_file)
else:
logging.info(f" - uploaded {cache_file}")
os.remove(f"uploads/{cache_file}")

(keep up the good work, loving my Enviro!)

EDIT: aha, looks like this pull request fixes things, including possibly a second issue I was investigating (requests fail after sending 3 readings): #15

Unable to publish to MQTT

I have updated the firmware in Enviro-Weather to 0.0.8 and I am unable to publish to an MQTT broker. After investigation it appears that the issue is related to the keepalive setting defaulting to 0.

WiFi password with double quote

Hi, I noticed that WiFi passwords with double quotes aren't properly escaped when entered during the provisioning process. I checked the value in config.py and noticed it was truncated at the first double quote.

VOC

My main motivation in getting the enviro indoor was to monitor VOC, but the provided software doesn't seem to do this. Any chance this will be in a near update?

Wind speed sensor not registering low readings.

I currently go with long periods of the wind speed sensor registering zero for the wind speed (~400 readings with a speed, out of over 5000).

I've currently upped the sensor reading time to 1000ms from 500, and this seems to have improved things considerably, but it may require tweaking up further to record lower wind speeds.

Looking at the equation for working out wind speed, if we only measure for 500ms, and have to get 2 ticks, wind speeds below 0.96 meters per second (2.1 mph) will never be measured.

2 ticks in 500ms
average_tick_ms = (ticks[-1] - ticks[0]) / (len(ticks) - 1)
average_tick_ms = 500/1 = 500

rotation_hz = (1000 / average_tick_ms) / 2
rotation_hz = (1000/500)/2 = 2/2 = 1

radius = 7.0
circumference = radius * 2.0 * math.pi
factor = 0.0218  # scaling factor for wind speed in m/s
wind_m_s = rotation_hz * circumference * factor
wind_m_s = 1 * (7*2*pi) * 0.0218 = 0.96 (to 2 decimals)

If we redo this for 1 second (1000ms) we get down to a speed of 0.48 m/s (just over 1mph)

If we go to 2 seconds we get down to 0.24 m/s (about half a mile an hour)

With wind speeds these differences are important, we should be able to distinguish between calm and light air (0 m/s and 1 m/s, see https://www.metoffice.gov.uk/weather/guides/coast-and-sea/beaufort-scale ).

This isn't really possible at a reading time of 500ms, but is once you start to go over 1000ms

I've currently set mine to 1500ms, and am getting good low readings now.

Poke button (to take reading) does not work under USB power

Using enviro indoor board, when running on battery, pressing the Poke button wakes up and triggers a reading.

However, this does not work when under USB power. On USB power, when pressing poke, there is no activity LED and no readings are uploaded (verified on Adafruit IO)

If your mqtt broker goes down, the board gets stuck in connecting forever

If your mqtt config is either not right (e.g bad hostname), or your broker goes down, the board's activity light remains on forever (I'm presuming it's stuck). The only way to resolve the latter issue is to power it off and back on again once your broker is back up (or figure out the config is wrong for yourself).

Provisioning sometimes crashing after step 4

Provisioning sometimes stalls after entering MQTT/Adafruit IO details, requiring a refresh of the page. Just tried provisioning while connected to Thonny and it looks to be throwing this value error when it happens...

2022-08-11 18:07:22 [info     /   90944] > GET /images/logo-weather.svg (200 OK) [243ms]
2022-08-11 18:07:22 [info     /  101248] > GET /images/pirate-logo.svg (200 OK) [302ms]
2022-08-11 18:07:22 [info     /   95632] > GET /images/guide-qr-code.svg (200 OK) [378ms]
2022-08-11 18:07:23 [info     /   88112] > GET /generate_204 (301 Moved Permanently) [195ms]
Task exception wasn't retrieved
future: <Task> coro= <generator object '_handle_request' at 20019fc0>
Traceback (most recent call last):
  File "uasyncio/core.py", line 1, in run_until_complete
  File "phew/phew/server.py", line 250, in _handle_request
  File "phew/phew/server.py", line 34, in _parse_query_string
ValueError: need more than 1 values to unpack
2022-08-11 18:08:05 [info     /   99136] > GET /generate_204 (301 Moved Permanently) [275ms]
2022-08-11 18:08:06 [debug    /   94128] > parsed template: enviro/html/header.html (took 9 ms)
2022-08-11 18:08:06 [debug    /   88704] > parsed template: enviro/html/header-mini.html (took 12 ms)
2022-08-11 18:08:06 [debug    /   85872] > parsed template: enviro/html/footer.html (took 80 ms)
2022-08-11 18:08:06 [debug    /   83168] > parsed template: enviro/html/provision-step-4-destination.html (took 467 ms)

MQTT broken in latest versions of the firmware

Having updated the firmware to a latest release (yes I know it's not final yet) on my Enviro Urban board I found that it stopped sending to my MQTT broker.

After some digging I found in enviro/destinations/mqtt.py you have

    mqtt_client.publish(f"enviro/{nickname}", reading, retain=True)

This fails as reading is not a json object.

By changing it to the following

    mqtt_client.publish(f"enviro/{nickname}", ujson.dumps(reading), retain=True)

and adding import ujson to the top of the script fixes it so that the reading is sent correctly to the broker.

Side note for anyone else trying to debug MQTT: Because you have the try block written with:

  except:
    pass

hid the error so the log just said it failed. Changing it to:

  except Exception as e:
      print(e)

at least allowed the error to be visible and enabled me to find this.

Warning LED not working

When given incorrect wifi details, the code in main.py that's meant to flash the warning LED instead throws an Attribute Error:

image

Further rain issues (now in 0.0.8)

I've been playing with the rain detection, with "manually" generated rainfall, and have identified another issue with the code as it stands.

When the system is put into sleep having woken from a rain event, no wake timer is set (I suspect), and so the board doesn't start logging again for normal logging afterwards. If the 'Poke' button is pressed, this does restart logging. I think that this can be seen in 2022-09-05b log.txt.

The initial wake also recorded the 3 quick tips, but the later 2 only recorded a single tip each, despite there being more than one (this may be due to how close together the tips were though). This can be seen in 2022-09-05 rain.txt.

Hope this makes sense!

Grow sensors do not report correctly

Hi,

I've observed two instances of the grow sensors reporting incorrect values:

In this screenshot I had watered only the pot with sensor 1 in it:
image
As you can see, sensor 1 stopped reading values, and sensors 2 and 3 showed an increase when there was none.

In this example I watered just pot with sensor 3 in it:
image
As you can see sensor 2 also showed an increase.

I'm wondering if this is to do with the combined loop over all sensors when measuring the times.

Edit:
Example one, subsequently updated to report like this:
Screenshot_20220812-230006~2

Request: please add a LICENSE

It would be great to understand what LICENSE applies to this code, thanks.

(additionally, GitHub topics, description etc would all help the MicroPython community to identify / locate this repo in Explore)

Enviro Urban wifi connection is failed

Hi Everyone,

I just flashed the new firmware "enviro-v0.0.8.uf2" to my Enviro Urban and the wifi connection has some issues.

When I connected it to my pc and used Thonny to run main.py, it had never successfully connected to my wifi.
When I used an external battery to power it, it connected to the wifi, sent data successfully, then the light turned red. I checked the log and I saw the connection to my wifi failed again. However, it just connected successfully 20 seconds before that.

Also, my Enviro Urban is new, it just came today. With the older firmware that come with the board, I dont see this behavior. So I guess the new firmware causes it.

This is the log:

2000-01-01 00:00:02 [debug    / 115kB] > performing startup
2000-01-01 00:00:02 [info     / 127kB]   - wake reason: external_trigger
2000-01-01 00:00:02 [debug    / 125kB]   - turn on activity led
2000-01-01 00:00:02 [info     / 123kB] > clock not set, synchronise from ntp server
2000-01-01 00:00:02 [info     / 121kB] > connecting to wifi network '1102'
2000-01-01 00:00:04 [debug    / 115kB]   - connecting
2000-01-01 00:00:07 [debug    / 102kB]   - connecting
2000-01-01 00:00:09 [info     /  94kB]   - ip address:  192.168.0.44
2022-09-10 01:13:31 [info     /  91kB]   - rtc synched
2022-09-10 01:13:31 [debug    /  88kB]   - starting sensor
2022-09-10 01:13:31 [debug    / 126kB]   - wait 5 seconds for airflow
2022-09-10 01:13:36 [debug    / 107kB]   - taking pms5003i reading
2022-09-10 01:13:36 [info     / 117kB] > 2 cache files need uploading
2022-09-10 01:13:37 [info     / 115kB] > already connected to wifi
2022-09-10 01:13:37 [info     / 104kB]   - uploaded 2022-09-10T01:13:36Z.json to http
2022-09-10 01:13:38 [info     /  96kB]   - uploaded 2040-09-10T00:42:47Z.json to http
2022-09-10 01:13:38 [info     /  93kB] > going to sleep
2022-09-10 01:13:38 [debug    /  91kB]   - clearing and disabling timer and alarm
2022-09-10 01:13:38 [info     /  89kB]   - setting alarm to wake at 01:15am
2022-09-10 01:13:38 [info     / 110kB]   - shutting down
2022-09-10 01:13:46 [debug    / 115kB] > performing startup
2022-09-10 01:13:46 [info     / 127kB]   - wake reason: external_trigger
2022-09-10 01:13:46 [debug    / 125kB]   - turn on activity led
2022-09-10 01:13:46 [debug    / 122kB]   - starting sensor
2022-09-10 01:13:46 [debug    / 120kB]   - wait 5 seconds for airflow
2022-09-10 01:13:51 [debug    / 101kB]   - taking pms5003i reading
2022-09-10 01:13:52 [info     / 105kB] > 1 cache files need uploading
2022-09-10 01:13:52 [info     / 102kB] > connecting to wifi network '1102'
2022-09-10 01:13:54 [debug    /  96kB]   - connecting
2022-09-10 01:13:57 [debug    /  82kB]   - connecting
2022-09-10 01:14:24 [error    /  84kB] ! failed to connect to wireless network 1102
2022-09-10 01:14:24 [error    /  82kB] ! reading upload failed
2022-09-10 01:14:24 [info     / 128kB] > going to sleep
2022-09-10 01:14:24 [debug    / 125kB]   - clearing and disabling timer and alarm
2022-09-10 01:14:24 [info     / 123kB]   - setting alarm to wake at 01:15am
2022-09-10 01:14:24 [info     / 121kB]   - shutting down
2022-09-10 01:14:33 [debug    / 115kB] > performing startup
2022-09-10 01:14:33 [info     / 127kB]   - wake reason: external_trigger
2022-09-10 01:14:33 [debug    / 125kB]   - turn on activity led
2022-09-10 01:14:33 [debug    / 122kB]   - starting sensor
2022-09-10 01:14:33 [debug    / 120kB]   - wait 5 seconds for airflow
2022-09-10 01:14:38 [debug    / 101kB]   - taking pms5003i reading
2022-09-10 01:14:39 [info     / 104kB] > 2 cache files need uploading
2022-09-10 01:14:39 [info     / 102kB] > connecting to wifi network '1102'
2022-09-10 01:14:41 [debug    /  96kB]   - connecting
2022-09-10 01:14:44 [info     /  82kB]   - ip address:  192.168.0.44
2022-09-10 01:14:44 [info     / 117kB]   - uploaded 2022-09-10T01:13:52Z.json to http
2022-09-10 01:14:45 [info     / 109kB]   - uploaded 2022-09-10T01:14:39Z.json to http
2022-09-10 01:14:45 [info     / 107kB] > going to sleep
2022-09-10 01:14:45 [debug    / 105kB]   - clearing and disabling timer and alarm
2022-09-10 01:14:45 [info     / 103kB]   - setting alarm to wake at 01:15am
2022-09-10 01:14:45 [info     / 100kB]   - shutting down
2022-09-10 01:15:02 [debug    / 115kB] > performing startup
2022-09-10 01:15:02 [info     / 127kB]   - wake reason: external_trigger
2022-09-10 01:15:02 [debug    / 125kB]   - turn on activity led
2022-09-10 01:15:02 [debug    / 122kB]   - starting sensor
2022-09-10 01:15:02 [debug    / 120kB]   - wait 5 seconds for airflow
2022-09-10 01:15:07 [debug    / 101kB]   - taking pms5003i reading
2022-09-10 01:15:08 [info     / 105kB] > 1 cache files need uploading
2022-09-10 01:15:08 [info     / 103kB] > connecting to wifi network '1102'
2022-09-10 01:15:10 [debug    /  96kB]   - connecting
2022-09-10 01:15:13 [debug    /  82kB]   - connecting
2022-09-10 01:15:40 [error    /  84kB] ! failed to connect to wireless network 1102
2022-09-10 01:15:40 [error    /  82kB] ! reading upload failed
2022-09-10 01:15:40 [info     / 128kB] > going to sleep
2022-09-10 01:15:40 [debug    / 126kB]   - clearing and disabling timer and alarm
2022-09-10 01:15:40 [info     / 124kB]   - setting alarm to wake at 01:20am
2022-09-10 01:15:40 [info     / 121kB]   - shutting down

documentation/getting-started.md describes MQTT and InfluxDB destinations identically

documentation/getting-started.md describes both MQTT and InfluxDB destinations as:

The most commonly used messaging protocol for the Internet of Things (IoT).

InfluxDB should probably be described differently - perhaps as 'The Time Series Data Platform where developers build IoT, analytics, and cloud applications.' (to match with the description shown during provisioning step 4)

API for extra sensor data/values

Currently each board type defines a list of sensors it includes but there is no provision to submit extra values (such as sensors connected to the Qw/ST port) alongside these.

I propose adding an optional callback function that can be implemented to add extra values.

Something like this in your main.py:

def additional_readings():
  breakout_scd41.start()
    while breakout_scd41.ready() is False:
        time.sleep(5)
  scd41_co2, scd41_temperature, scd41_relative_humidity = breakout_scd41.measure()
  breakout_scd41.stop()

  return {
    "scd41_co2": scd41_co2,
    "scd41_temperature": scd41_temperature,
    "scd41_humidity": scd41_relative_humidity
  }

Inspired by #33

Provisioning issues

Reported by user:

"when it works you get the blue progress bar, when it doesn't there is no progress bar, the screen does not change, the button greys out and it just sits there and eventually times out. If you power cycle the device and start the process again, you can see your previous answers in the web form (so it has written to the config file) and you can go through to the next page. But often/usually it will have the same time out after you hit the button on that page. Again you reboot and when you go through again it allows you to go one page further. However on the final "we're done" page with both boards it has apart from one occasion each, it has never "finished" and the work around I got was to go into the config file and edit it manually to change provisioning complete to "1" (I spotted this once on a successful configuration, so tried it and it worked."

User has experienced this issue repeatedly on multiple Enviro boards but I have not been able to recreate or heard of any other reports of this problem. They have used both Android and iOS devices to recreate the issue.

Suspect issue relates to some nuance of their setup - wireless interference perhaps?

rain sensor - no values

I've got a working enviro weather for wind speed, direction, temp etc. apart from rain. At present I'm simply logging the payload over http but can see the data just fine:
image

Also, when the bucket tips it is waking the device and triggering an upload - I can see the activity LED and a log entry appear a moment later., however (as above) the payload that is sent always says ... "rain": 0....

I can see in the code where that is set, but what I'm not clear is what to do about it. For example, should/could I add the 'wake reason' to the payload? Then I can use the reason code to increment a rain total concept. I think I would then need to add a scenario to the function 'def get_wake_reason():' in board.py.

To my mind, this seems easier than adding to the pico the concept of rain today, and worrying about timezones, the 09:00UTC met definition etc..

If I'm on the right path, happy to write, test and create a PR....

Wake reasons not showing in the logs correctly

Looking at lines 211-232 in enviro/init.py, I think that the log file should show the reasons why the system has woken from sleep.

Looking at my log file I can see that most of these are returning 'unknown'.
I know that most of the logs should show 'rtc_alarm' as the cause, but that those at 2022-09-05 18:16:37 and 2022-09-05 19:06:13 should be 'button' as I know those were caused by me hitting the 'poke' button.
I also suspect that at 2022-09-05 18:01:23, 2022-09-05 18:01:26, 2022-09-05 18:01:31, 2022-09-05 18:18:58 & 2022-09-05 18:32:50 should have a wake reason line with 'rain_sensor' against them.

Suggestion: add the board model to the data outputs

Following on from my last hugely successful issue, I'm in the process of building my own homebridge plugin using mqtt (other mqtt plugins seem to be more work configuring than just building my own would be). In order for this plugin to be useful and more flexible to other people using any of the other enviro boards, it would be nice if the mqtt json blob included the device model, as that would allow me to correctly process the json into a type relevant to which board is producing the message. Some other stuff I'd like to add:

  • serial number or mac address
  • pump state (on or off as a boolean)

I'm happy to submit a PR for this (if you think this is a good idea?), as I can see there's a model() function, but I'm unsure about style and where's best to put this since I can see that function contacts hardware, and you may want to cache that in config or in the reading cache as opposed to calling it on the fly whilst you're trying to upload to wifi. mac/serial number I'd also need an advisory on as to where to look. Thoughts?

homekit support

Hi there,

I've spoken to Paul about implementing HomeKit support - I was just wondering if there's any prior art to this already? The main thing I'm pondering is micro python support and how micro python affects being able to use the "standard" HomeKit python libs. I can't find any micro python libs that just work out of the box, from a brief google.

Blank WiFi networks in setup

Nameless networks (which I believe are coming directly out of WiFi scan verbatim) are showing up in the UI and are a little... odd!

Excuse the enormous image.

image

EnviroGrow: solid red LED when using JST-PH power connector

My EnviroGrow works when powering from USB.

But now that I've got a connector for the JST-PH socket (why isn't a wire provided in the kit????) and I've connected power that way, it does not seem to boot at all. Rather, if I have my voltage reguklator set anywhere above 1.8v, up to 4.4v, all I get is a solid red on the warning LED. No 'Activity' LED and nothing written to log.txt.

Unlike the other post with red LED who was apparently lacking board firmware, all the programs are present and all works if change back to USB power.

Suggestions?

RTC stopped?

This is a bit of an odd one. It looks to me like the RTC has stopped, and thus the wake command wasn't issued.

The 1:15 UTC reading was taken fine, but it didn't wake up, and so no more readings were sent. I woke and io.adafruit.com was showing no readings for ~6 hours, so I went outside and poked things (at what the log shows as the first 2022-09-08 01:17:08 entry, but was in fact closer to 07:56 GMT).

In fact looking at the log, you can see that the RTC is reporting that the initial time for each of the last 3 readings is 01:17:08.

The board is reporting the battery remaining as 3.534, and I can see from prior readings that it's been logged lower than that and fine.

I'm going to wipe the log so it grabs time again, and see what happens

2022-09-08 01:15:02 [debug    / 114kB] > performing startup
2022-09-08 01:15:02 [info     / 123kB]   - wake reason: unknown
2022-09-08 01:15:02 [debug    / 121kB]   - turn on activity led
2022-09-08 01:15:02 [info     / 120kB]   - config loaded
2022-09-08 01:15:02 [info     / 118kB]   - clock already set
2022-09-08 01:15:02 [info     / 115kB]   - disk space OK
2022-09-08 01:15:02 [info     / 112kB]   - wind speed started
2022-09-08 01:15:02 [info     / 110kB]   - wind speed state recorded
2022-09-08 01:15:03 [info     / 106kB]   - wind speed sensor tick
2022-09-08 01:15:03 [info     / 103kB]   - Not enough wind ticks captured
2022-09-08 01:15:04 [info     /  95kB]   - wind direction captured
2022-09-08 01:15:04 [info     /  93kB]   - sensor readings OK
2022-09-08 01:15:04 [info     / 123kB]   - cached OK
2022-09-08 01:15:04 [info     / 121kB] > 1 cache files need uploading
2022-09-08 01:15:04 [info     / 118kB] > connecting to wifi network 'Celestia'
2022-09-08 01:15:06 [debug    / 112kB]   - connecting
2022-09-08 01:15:09 [debug    /  98kB]   - connecting
2022-09-08 01:15:12 [info     /  88kB]   - ip address:  192.168.1.208
2022-09-08 01:15:13 [info     / 110kB]   - uploaded 2022-09-08T01:15:04Z.json to adafruit_io
2022-09-08 01:15:13 [info     / 107kB] > going to sleep
2022-09-08 01:15:13 [debug    / 105kB]   - clearing and disabling timer and alarm
2022-09-08 01:15:13 [info     / 103kB]   - setting alarm to wake at 01:20am
2022-09-08 01:15:13 [info     / 101kB]   - shutting down
2022-09-08 01:17:08 [debug    / 114kB] > performing startup
2022-09-08 01:17:08 [info     / 123kB]   - wake reason: unknown
2022-09-08 01:17:08 [debug    / 121kB]   - turn on activity led
2022-09-08 01:17:08 [info     / 120kB]   - config loaded
2022-09-08 01:17:08 [info     / 118kB]   - clock already set
2022-09-08 01:17:08 [info     / 115kB]   - disk space OK
2022-09-08 01:17:08 [info     / 112kB]   - wind speed started
2022-09-08 01:17:08 [info     / 110kB]   - wind speed state recorded
2022-09-08 01:17:09 [info     / 105kB]   - Not enough wind ticks captured
2022-09-08 01:17:10 [info     /  96kB]   - wind direction captured
2022-09-08 01:17:10 [info     /  94kB]   - sensor readings OK
2022-09-08 01:17:10 [info     /  91kB]   - cached OK
2022-09-08 01:17:10 [info     / 108kB] > 1 cache files need uploading
2022-09-08 01:17:10 [info     / 105kB] > connecting to wifi network 'Celestia'
2022-09-08 01:17:12 [debug    /  99kB]   - connecting
2022-09-08 01:17:15 [debug    /  86kB]   - connecting
2022-09-08 01:17:17 [info     / 122kB]   - ip address:  192.168.1.208
2022-09-08 01:17:18 [info     / 104kB]   - uploaded 2022-09-08T01:17:10Z.json to adafruit_io
2022-09-08 01:17:18 [info     / 102kB] > going to sleep
2022-09-08 01:17:18 [debug    / 100kB]   - clearing and disabling timer and alarm
2022-09-08 01:17:18 [info     /  97kB]   - setting alarm to wake at 01:20am
2022-09-08 01:17:19 [info     /  95kB]   - shutting down
2022-09-08 01:17:08 [debug    / 114kB] > performing startup
2022-09-08 01:17:08 [info     / 123kB]   - wake reason: unknown
2022-09-08 01:17:08 [debug    / 121kB]   - turn on activity led
2022-09-08 01:17:08 [info     / 120kB]   - config loaded
2022-09-08 01:17:08 [info     / 117kB]   - clock already set
2022-09-08 01:17:08 [info     / 115kB]   - disk space OK
2022-09-08 01:17:08 [info     / 112kB]   - wind speed started
2022-09-08 01:17:09 [info     / 110kB]   - wind speed state recorded
2022-09-08 01:17:10 [info     / 104kB]   - Not enough wind ticks captured
2022-09-08 01:17:10 [info     /  96kB]   - wind direction captured
2022-09-08 01:17:10 [info     /  94kB]   - sensor readings OK
2022-09-08 01:17:10 [info     /  91kB]   - cached OK
2022-09-08 01:17:10 [info     / 122kB] > 1 cache files need uploading
2022-09-08 01:17:10 [info     / 120kB] > connecting to wifi network 'Celestia'
2022-09-08 01:17:12 [debug    / 114kB]   - connecting
2022-09-08 01:17:15 [debug    / 100kB]   - connecting
2022-09-08 01:17:21 [info     /  78kB]   - ip address:  192.168.1.208
2022-09-08 01:17:22 [info     / 107kB]   - uploaded 2022-09-08T01:17:10Z.json to adafruit_io
2022-09-08 01:17:22 [info     / 104kB] > going to sleep
2022-09-08 01:17:22 [debug    / 102kB]   - clearing and disabling timer and alarm
2022-09-08 01:17:22 [info     / 100kB]   - setting alarm to wake at 01:20am
2022-09-08 01:17:22 [info     /  98kB]   - shutting down
2022-09-08 01:17:08 [debug    / 114kB] > performing startup
2022-09-08 01:17:08 [info     / 123kB]   - wake reason: unknown
2022-09-08 01:17:08 [debug    / 121kB]   - turn on activity led
2022-09-08 01:17:08 [info     / 120kB]   - config loaded
2022-09-08 01:17:08 [info     / 118kB]   - clock already set
2022-09-08 01:17:08 [info     / 115kB]   - disk space OK
2022-09-08 01:17:08 [info     / 112kB]   - wind speed started
2022-09-08 01:17:08 [info     / 110kB]   - wind speed state recorded
2022-09-08 01:17:09 [info     / 105kB]   - Not enough wind ticks captured
2022-09-08 01:17:10 [info     /  97kB]   - wind direction captured
2022-09-08 01:17:10 [info     /  95kB]   - sensor readings OK
2022-09-08 01:17:10 [info     /  91kB]   - cached OK
2022-09-08 01:17:10 [info     / 122kB] > 1 cache files need uploading
2022-09-08 01:17:10 [info     / 120kB] > connecting to wifi network 'Celestia'
2022-09-08 01:17:12 [debug    / 114kB]   - connecting
2022-09-08 01:17:15 [debug    / 100kB]   - connecting
2022-09-08 01:17:17 [info     /  91kB]   - ip address:  192.168.1.208
2022-09-08 01:17:19 [info     / 109kB]   - uploaded 2022-09-08T01:17:10Z.json to adafruit_io
2022-09-08 01:17:19 [info     / 107kB] > going to sleep
2022-09-08 01:17:19 [debug    / 105kB]   - clearing and disabling timer and alarm
2022-09-08 01:17:19 [info     / 102kB]   - setting alarm to wake at 01:20am
2022-09-08 01:17:19 [info     / 100kB]   - shutting down
2022-09-08 01:17:19 [debug    /  98kB]   - on usb power (so can't shutdown) halt and reset instead

Demo code doesn't turn the pumps from the Enviro Grow kit on / off. Written custom code to resolve issue.

The published Enviro Grow scripts doesn't have any code to control the three pumps. I've solved this by writing some custom code. Details as follows...

Created a new folder on the Pico called "custom". Created two new files within the custom folder: "pumps.py" and "water_plants.py".

pumps.py
`import time
from breakout_bme280 import BreakoutBME280
from breakout_ltr559 import BreakoutLTR559
from machine import Pin, PWM
from enviro.board import i2c

bme280 = BreakoutBME280(i2c, 0x77)
ltr559 = BreakoutLTR559(i2c)

#Water pump GPIO settings
Pump_A = Pin(12, Pin.OUT)
Pump_B = Pin(11, Pin.OUT)
Pump_C = Pin(10, Pin.OUT)

def Pump_1(run):
Pump_A.value(1) # Turns pump on
print ('Pump A on')
time.sleep(run)
Pump_A.value(0) # Turns pump off
print ('Pump A off')

def Pump_2(run):
Pump_B.value(1) # Turns pump on
print ('Pump B on')
time.sleep(run)
Pump_B.value(0) # Turns pump off
print ('Pump B off')

def Pump_3(run):
Pump_C.value(1) # Turns pump on
print ('Pump C on')
time.sleep(run)
Pump_C.value(0) # Turns pump off
print ('Pump C off')

#Testing
#Pump_1(run)
#Pump_2(run)
#Pump_3(run)
`

water_plants.py
`import time
import custom
from custom import pumps
import enviro
from enviro.boards import grow

#Pump running time (seconds)
#run = 2 #For testing
run = 10 #For testing

#Dry sensor value
dry = 70

#Initiate sensor values for testing
#sensor1 = 0
#sensor2 = 0
#sensor3 = 0

#sensor2 = 100 # For testing. To stop pump 2 from running
#sensor3 = 100 # For testing. To stop pump 2 from running

#Initial sensor sensors
sensor_a = round(grow.moisture_readings(2000)[0],2)
sensor_b = round(grow.moisture_readings(2000)[1],2)
sensor_c = round(grow.moisture_readings(2000)[2],2)

#Checking to see if there is a sensor attached
if sensor_a == 0:
sensor_a_state = 'off'
else:
sensor_a_state = 'on'

if sensor_b == 0:
sensor_b_state = 'off'
else:
sensor_b_state = 'on'

if sensor_c == 0:
sensor_c_state = 'off'
else:
sensor_c_state = 'on'

print ('Sensor A state = ', sensor_a_state, '. Reading: ', sensor_a)
print ('Sensor B state = ', sensor_b_state, '. Reading: ', sensor_b)
print ('Sensor B state = ', sensor_c_state, '. Reading: ', sensor_c)

while (sensor_a_state == 'on' and sensor_a <= dry) or (sensor_b_state == 'on' and sensor_b <= dry) or (sensor_c_state == 'on' and sensor_c <= dry):

if sensor_a_state == 'on' and sensor_a <= dry:
    pumps.Pump_1(run)
    time.sleep(5)

if sensor_b_state == 'on' and sensor_b <= dry:
    pumps.Pump_2(run)
    time.sleep(5)

if sensor_c_state == 'on' and sensor_c <= dry:
    pumps.Pump_3(run)
    time.sleep(5)

#sensor = enviro.get_sensor_sensors()
sensor_a = round(grow.moisture_readings(2000)[0],2)
sensor_b = round(grow.moisture_readings(2000)[1],2)
sensor_c = round(grow.moisture_readings(2000)[2],2)


print ('Sensor A: ', sensor_a, ', ', sensor_a_state)
print ('Sensor B: ', sensor_b, ', ', sensor_b_state)
print ('Sensor C: ', sensor_c, ', ', sensor_c_state)

# For testing
#sensor_a = sensor_a+1
#sensor_b = sensor_b+1
#sensor_c = sensor_c+1

print ('All plants are well watered')
`

I also amended the main.py file as follows:
import custom from custom import water_plants

Inserted just above the enviro.sleep line.
# water the plants custom.water_plants

I hope this helps.

Flashing an update .uf2 will erase "config.py" and any logs/pending uploads

Since the filesystem .uf2 and full firmware .uf2 both completely erase and replace the filesystem on-device, theyi will also blow away the user config file.

We can fix this - I think - by changing the Pimoroni PicoW Enviro MicroPython build's _boot.py (see: https://github.com/micropython/micropython/blob/master/ports/rp2/modules/_boot.py) to set up two filesystems.

The "main" filesystem will be first, mounted at "/" and the "config" filesystem would come after, mounted at "/config".

This would let us ship filesystem and firmware .uf2 files that don't rewrite the "config" partition, so user data is preserved.

It would also potentially allow an online or offline tool to create a config .uf2 which could be flashed to a board in lieu of running through the captive portal setup.

In order to do this, however, we need to be able to get discrete "Flash()" instances with specific offsets/sizes. Right now rp2.Flash() returns a singleton block device instance that covers the entire filesystem region- https://github.com/micropython/micropython/blob/master/ports/rp2/rp2_flash.c

Allow for more verbose logging

When I've been trying to troubleshoot issues, I've not found the log files to be all that helpful. It would be nice to have an option for more verbose logging to try and better work out where things are going wrong when they are.

WIFI passwords cannot contain equals signs

When provisioning a Pico Grow from new or via a reset the WIFI password section will fail if an equals sign is used. Shell reports the following and the provisioning process halts.

Task exception wasn’t retrieved
future: coro= <generator object ‘_handle_request’ at 20015990>
Traceback (most recent call last):
File “uasyncio/core.py”, line 1, in run_until_complete
File “phew/phew/server.py”, line 254, in _handle_request
File “phew/phew/server.py”, line 142, in call_handler
File “enviro/provisioning.py”, line 71, in provision_step_3_logging
File “enviro/helpers.py”, line 182, in get_config
File “enviro/helpers.py”, line 169, in get_values_from_file
File “”, line 1
SyntaxError: invalid syntax

There is the potential for other characters to cause the same issue but I could only find issue with equals.

picow-enviro firmware not listed

The update firmware documentation shows two versions of the picow firmware one for the envoro series, but that one is not listed on the current releases page.

NameError: name 'warn_led' isn't defined in line 55

When I run the Main.py in Thonny I get this error:
2000-01-01 01:01:26 [debug / 98096] > performing startup
2000-01-01 01:01:26 [debug / 96400] - hold vsys_en high
2000-01-01 01:01:26 [info / 126400] - wake reason: unknown
2000-01-01 01:01:26 [debug / 124672] - turn on activity led
2000-01-01 01:01:26 [info / 120624] > clock not set, synchronise from ntp server
2000-01-01 01:01:26 [info / 105712] > connecting to wifi network 'Vermeer'
2000-01-01 01:01:30 [error / 127328] ! failed to connect to wireless network Vermeer
2000-01-01 01:01:30 [error / 125376] ! failed to synchronise clock
Traceback (most recent call last):
File "", line 55, in
NameError: name 'warn_led' isn't defined

Could use some help in resolving

Temperature calibation

I've just provisioned 2 of the enviro indoor sensors and one of them is reading a good 4-5C above what I believe the room to actually be, is there a way of calibating the sensor or, alternatively, a way of always deducting/adding a value to true it up?

Feature request - Measure battery level on Enviro Weather

Not sure if it is feasible directly or with an additional bit of circuitry, but please could we get measuring the battery (LiPo connected via the onboard JST-PH) level and reporting back with the rest of the data?

It is probably not needed to be at the same rate as the rest of the data so could be done daily, for example, or configurable on a separate interval.

Pin error in model() function

Hi,

there is a pin error in the def model() function in the enviro/enviro/board.py file.

the function returns weather for the enviro weather pico board but just to be sure of the code

elif 35 in i2c_devices: # 35 = ltr-599 on grow & weather
    # the wind vane pin is pulled high with a 10k resistor on the weather
    # board - we can detect this and disambiguate using it
    pump1_pin = Pin(10, Pin.IN, Pin.PULL_UP)                                     # here pin10 is for rainmeter
    result = "grow" if pump1_pin.value() == False else "weather"

Shouldn't it be this?

pump1_pin = Pin(26, Pin.IN, Pin.PULL_UP)   # For windwane:     wind_direction_pin = Analog(26)

adafruit_io logging causing halt (in 0.0.8)

adafruit_io upload appears to be causing my grow to halt with a red flashing light. Suspect for some reason it's not handling throttling at the adafruit end (it did before) and returning False, which means that

    if not enviro.upload_readings():
      enviro.halt("! reading upload failed")

in main.py is causing a halt. Could be wrong though!

Enviro Weather Rain Function - count logic needs edit

The current script counts the number of ticks in the last hour. Therefore if the board takes a reading every 15min (as defined by config.py), the rain readings would be duplicated or overstated in the upload files. I think the script should pull in the reading frequency variable from config.py and use that in the formula. Better yet, the board should only record the number of ticks between readings - even is a reading is manually initiated by using the "poke" button.

def rainfall():

As a minimum, line 136 should if now - ts < config.reading_frequency ...
I'll see if I can work on some test code and publish it via a fork if I get it to work.

the goal is if pouring 250ml of water from a jug over the rain sensor, the reading should reflect 250ml in the subsequent upload file and only in that file. Any subsequent file should have a "0" rain volume.

How to access local recordings on enviro indoor?

When enviro uf2 firmware is loaded, the board is not detected in Thonny 4.0.0 (in Ubuntu) and therefore I can not access the recordings files on the board.

By experimenting, if I nuked the flash and then load the pimoroni-picow-v1.19.6-micropython.uf2 it is detected in Thonny and I can access files. But as soon as the enivro files are loaded and USB is removed and reconnected, the board is not detected and therefore there is no access to the files in Thonny.

Are others able to access local recordings by connecting their board to USB on the computer after going through the environ provision process?

Adafruit IO Data Uploads - Red LED error light activated (Enviro Weather and Enviro Grow)

I suspect that the script for uploading data to Adafruit IO causes the red LED on the board to be activated.
https://github.com/pimoroni/enviro/blob/main/enviro/destinations/adafruit_io.py

I found in my testing of v0.0.8 that the board errored out once the number of upload files reached it's trigger point (as defined in config.py). I am not certain, but I winder if this is because the current script doesn't have any sleep conditions for when the service suspends the feeds due to the submission limit being reached. Once this error occurs, I can't access the board via Thonny (Thonny message states "Couldn't find the device automatically..." The only way I've been able to regain access to the board is to install a fresh version of the firmware - thereby wiping out the stored upload files.

v0.0.8 hard crashes in Thonny

When running main.py through Thonny to debug I'm now encountering frequent hard crashes, requiring a board reset or unplug/replug of the USB cable. Here's an example from just now - on this occasion it keeled over just after waking up, but I've seen it crash at different points in the program.

I'm seeing this on multiple boards, USB cables, PCs, Thonny versions, endpoints.

main.py output:

> >>> %Run -c $EDITOR_CONTENT
       ___            ___            ___          ___          ___            ___       
      /  /\          /__/\          /__/\        /  /\        /  /\          /  /\      
     /  /:/_         \  \:\         \  \:\      /  /:/       /  /::\        /  /::\     
    /  /:/ /\         \  \:\         \  \:\    /  /:/       /  /:/\:\      /  /:/\:\    
   /  /:/ /:/_    _____\__\:\    ___  \  \:\  /__/::\      /  /:/~/:/     /  /:/  \:\   
  /__/:/ /:/ /\  /__/::::::::\  /___\  \__\:\ \__\/\:\__  /__/:/ /:/___  /__/:/ \__\:\  
  \  \:\/:/ /:/  \  \:\~~~__\/  \  \:\ |  |:|    \  \:\/\ \  \:\/:::::/  \  \:\ /  /:/  
   \  \::/ /:/    \  \:\         \  \:\|  |:|     \__\::/  \  \::/~~~`    \  \:\  /:/   
    \  \:\/:/      \  \:\         \  \:\__|:|     /  /:/    \  \:\         \  \:\/:/    
     \  \::/        \  \:\         \  \::::/     /__/:/      \  \:\         \  \::/     
      \__\/          \__\/          `~~~~~`      \__\/        \__\/          \__\/      

    -  --  ---- -----=--==--===  hey enviro, let's go!  ===--==--=----- ----  --  -     

2022-09-07 10:51:47 [debug    / 122kB] > performing startup
2022-09-07 10:51:47 [info     / 121kB]   - wake reason: external_trigger

and from log.txt:

> 2022-09-07 10:51:47 [debug    / 122kB] > performing startup

Ability to synchronise readings from multiple Enviro modules

Currently scheduling is always relative (e.g. "every five minutes"). This makes it tricky to setup multiple Enviro boards that collect data at the same time.

Options:

  • should "every five minutes" actually be locked to clock time? I.e. at 5 minutes past, 10 minutes past, etc? This would be a simple change that doesn't add new configuration options and logically seems sensible too.
  • should the user be able to specify fixed times when readings occur? So if they say "hourly" should it be possible to specify that it's always taken at 15 minutes past the hour?

We definitely want to avoid making the configuration overly complex with too many options. It's harder for the user to reason about.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.