Single Sensor Node (ESP32-S2-Mini or RPi Pico-W)

The project is based on an ESP32-S2-Mini and can be deployed to sense temperature, humidity and air pressure in any geographical location. All it needs is access to a WiFi Access Point and a (local or remote) MQTT broker.

Today I've been converting the Micro-Python script I wrote for the ESP32-S2-Mini to work on a RPi Pico-W.
One of my friends wanted to try it out but only had a Pico-W.

I've called it 'Single Sensor Node' as it sits in my greenhouse and reports Temp/Humidity/Pressure and the voltage of the battery that powers it. I suppose I should have called it a 'Twin Sensor Node' as it has a BME280 sensor, OLED panel and an Analog Input.

If you would like to read about it, I've published it on my 'Share my projects' website here...

https://teamwork-int.com/share_my_projects/

If you visit the above link you'll need to click on the folder labelled... C_single_sensor_node

SSN_generic_RDS_v05.py is the latest version of the Python script - works with ESP32-S2 and Pico-W

7 Likes

Dave,
thanks for sharing this.

I was thinking about some edge cases in my environment and considering Zeros/ESPs. After a quick scan of your documentation I feel there is a clear path for me now :smile:

Cool !

1 Like

What's your feeling about the relative ease of use for beginners to setup and code Dave?

  • ESP with Tasmota
  • ESP with Arduino
  • Pico with Micro python

I think micro python may be available for the ESP too, as are various other IDEs and Node-red-mcu.

I think ESP Home may be the easiest.

I have been tinkering with Micropython I really like REPL interfaces, but one thing I am not really able to grasp with arduino/esphome or micropython is to have a ballswitch that wakes the devices up - starts a (watchdog) with a timeout, lets say 15 seconds, if within that timeframe no trigger from the same ballswitch was received, go back to sleep, else remain awake (ie, reset the watchdog timer every time a trigger was received) - I want to build my own remote control using MQTT/ESPNow.

This looks like a fun project, really nicely documented touching many aspects.

That's a difficult question to answer as the route I've gone down has been more by luck than judgement.
I also know there are other people on the forum that have gone down a different path and naturally consider their path the best. Please note - I don't want to get into a 'my mouse trap is better than yours war'.

I started-off many years ago using Wemos D1 Mini microcontrollers flashed with ESPeasy. There is a rules-engine inside ESPeasy which opens up doing some "clever" stuff inside the microcontroller. You can also do OTA updates to the firmware.

I know other people, like @TotallyInformation, have produced home automation systems with ESPhome.

I started helping my grandsons 2+ years ago when they were studying for their GCSEs in Computer Science and sort of naturally fell in to using Micro-Python as the pseudo-code for their answers on their course work. I bought a Micro-Python coding book as a Christmas present for one of the boys and in it, it mentioned flashing Micro-Python on to an ESP8266 devices like the Wemos D1 Mini.

A year ago I stumbled across the ESP32-S2-Mini, same outer footprint as the Wemos D1 but loads more flash memory and PSRAM. Also cheaper than the Wemos, so must be a good choice. It is very easy to flash Micro-Python onto it and using Thonny (as an IDE) makes a nice combination. The other thing I like about this combo is you import just the libraries you neeed, rather than having to pick a piece of firmware that includes lots of peripherals you don't need. Hope that makes sense.

All the projects I've tacked with @zenofmud over the last year have been based on using Micro-Python and Thonny and for myself - all with ESP32-S2-Minis. In fact I have revamped some of my old projects that used Wemos D1 Minis to now use ESP32-S2-Minis (so I have spare Wemos D1s if anyone wants them?).

My grandsons, who have just started their Computer Science A-Level, have shot up the Micro-Python learning curve and have had great fun using the ESP32-S2-Mini to try out their ideas.

This week, prompted by a friend of mine who has some RPi-Pico-Ws, I adapted one of my Micro-Python scripts to handle a RPi-Pico-W as well as ESP32-S2. The script reads an external 'config' file that defines the 'device_type' and then allocates the pin-mapping accordingly (so the script is generic as possible).

I've also experimented developing a method of performing OTA updates for a Micro-Python script - very much a 'work in progress' at the moment.

Although I have various Arduino devices I haven't done much with them recently - lack of bandwidth.

I also have a number of S20 and S26 mains switches around the house (controlling external lights) which are flashed with Tasmota. Also a couple of PZEM-003T energy sensors, again flashed with Tasmota.

In summary and based purely on my own personal experience...
I like the ESP32-S2-Mini, Micro-Python and Thonny-IDE combination as it gives me pretty good productivity and creativity for very little outlay.

EDIT:
One thing that happened just before Christmas was I picked up one of my old Wemos D1 Minis and couldn't "talk to it" as I'd changed my WiFi passwords on my home network and couldn't remember what I'd use at the time I flashed the device. With devices flashed with Micro-Python you just plug them in to a USB port and "look inside" the device - SIMPLE.

1 Like

Has Micro-Python improved at all recently? What put me off was that there didn't really seem to be an "owner" and it didn't seem to be getting any solid development or support. There were also several competing versions it seemed.

I used to use ESPeasy and Tasmota but I found that they both would occasionally crash and leave the device offline. That wasn't really acceptable.

I've never had ESPHome crash except when I did something silly with it. The 5 things I particularly like about it are:

  • Massive range of supported sensors and controls.
  • Easily templated so that I can simply include standard YAML files for standard sensors and controls. Each of my platform types has its own master config but the majority of the detail is all from included standard files.
  • You can still go down into the weeds of C++ if you need to without any effort.
  • After the first firmware upload over USB, you can do everything else remotely. You don't need to move the device to update it.
  • It works on tons of different platforms from bare ESP8266/ESP32 through to M5 devices.

And, as I say, it never seems to crash the device. As most of the firmwares, it has a web interface (optional) but I rarely use it because once set up, everything input and output is via MQTT or physical controls if you like.

The slight downside is that it is a bit challenging to initially set up your development environment. But as long as you can get your head around using a Python virtual environment, it isn't too hard and the documentation is OK.


At the end of the day, it really depends, as always, on your needs. For simplicity, ESPEasy is probably top, maybe followed by Tasmota. If you have several different device platforms to support or if you need a wider range of supported sensors and controls, ESPHome is likely to be best. And if you are a Python-ista, you've got Micro-Python.

1 Like

?? Once esphome is installed, I just use the text editor and the terminal on my mac as dev environment, can't be simpler, that's it (command prompt and notepad on Windows)

I have been using ESPHome several years and so far I see no reason to change, it meets all my requirements. I agree on the above, so simple to use. So many devices for various needs supported (some special cases are missing like support for ESP32-CAM). A while ago I needed to make a wifi connected ESP32 unit with a daylight sensor. Just had to put the .yaml file together and upload, voilĂ 

2 Likes

Quick Update
I've placed 'SSN_generic_RDS_v05.py' (in the C_single_sensor_node folder) on the following link...

https://teamwork-int.com/share_my_projects/

This version should make the Micro-Python script totally generic, so you shouldn't need to alter anything.
There is a 'node_defaults.py' file in the /settings folder where you can alter any defaults to suit your needs.

I'll modify and update the 'install notes' shortly.

1 Like

Quick Update
If anyone is interested, I've updated the 'Install Guide' with additional illustrations and operational details.

It can be found in the C_single_sensor_node folder at...

https://teamwork-int.com/share_my_projects/

Hey Dave. A little off topic but wondering why you don't save your project's in GitHub? There are a lot of benefits to be had (not least commented commits, version history, user feedback and improvements (via issues) rollback-ability, ...).

Simple answer - I never got round to sorting out how to do it.
I bet you'll tell me... "well Dave it's dead-easy".

well Dave it's not easy, but it is worth it.

Happy to advise but my first advice would be use the graphical tools in vscode while you are learning git. The git integration is (imo) very streamlined and (somewhat) simplified. Really takes the edge off while getting up and running.

Final words: It really is worth the effort & it is less effort than you think (and a bloody godsend when you mess up and need to revert something)

If you are using Windows, I also recommend getting the GitHub for Windows app as it makes getting started a lot easier.

When using VSCode, also get GitLens, that is the best extension. The GitLens authors also make a full app called GitKraken that might be useful if not using VSCode.

There are two "competing" micro-pythons
Micropython - the original project - constant updates - well maintained-I attend online monthly Meetups about it

and
CircuitPython -Adafruits in-house variant of the above- also well maintained

These are both very active projects :slight_smile:

2 Likes

@jbudd It depends on what you mean by coding?

I have tried a few of the other options, but settled on Tasmota, I use it on Smart Bulbs, sockets and Blinds as well as a number of DIY devices for control and monitoring.

Lots of things can be done locally using a simple rules system, which I have used a few times for some special requirement. But it also supports full berry scripting if required. I haven't used it myself as I create the logic in NR.

You can flash the firmware to an ESP directly from your browser. The tool detects what type of ESP it is and uses the appropriate build. Generally I just use the Tasmota base firmware as it covers most of my needs. However there are several special builds for particular use cases -
IR transceivers, driving displays, incorporating many sensor types and ESP32 Cam for example.
There are also many more community special builds.

I have only built my own firmware a couple of times when I need to add an unusual selection of features.

This made quite easy via a prebuilt gitpod environment for online compiling via browser.

My suggestion would be to try a simple project with each and make up your own mind, before committing too much time to any one in particular :wink:

You might do some research into the lifespan of humidity sensors.
The cheap ones generally only last a year. The more expensive can last 8-10 years.
The price difference wasn't an issue for me.

Sounds like a great project :slight_smile: