Since I visited the weather station last week, the speed at which i’ve been working on the project has definitely slowed. Except it hasn’t! I’ve been working on the software side. Now that I know all my sensors work with a Pi, i’ve been thinking about next steps. Currently i’m using WeeWX, and I love that software. The graphing is awesome, and so is the open-ness of it. So many plugins are available. However, given i’m trying to create a setup that uses very little data, WeeWX at the edge isn’t really ideal. Uploading all those graphs and relying on the edge device will really tax it and use up data. So really I need the Edge device to be absolutely as simple as possible, with WeeWX somewhere else.
So I started looking at MQTT options for WeeWX. Obviously i’m using MQTT since it’s the protocol of IoT. It’s incredibly reliable, and lightweight. I know there are options that send MQTT from WeeWX, but not the other way around. Until I found this! https://github.com/bellrichm/WeeWX-MQTTSubscribe which after a bit of setup works perfectly! I was able to create a Python script that creates random obs and send them to an MQTT topic in AWS IoT Core, which WeeWX hosted on EC2 would then receive. There are still some bugs to work out in regards to architecture, but I like what I see so far. So my plan will be to run WeeWX either in Docker via Fargate, or on a cheap EC2 instance (probably T4g using the Graviton2 instances) using something like EC2 Savings Plans or Reserved Instances. Should cost me about $5-7 a month. I’ll have a second post that goes into the WeeWX setup once I make up my mind on exact setups.
Speaking of making up my mind. I’ve done a lot of thinking regarding what will power this station. I’ve been talking a lot about Raspberry Pi, but I’ve started to think about other options. Recently, Raspberry Pi unveiled the “Pico”. a $4 ($2 at my local MicroCenter!) which is a Raspberry Pi produced Microcontroller. I started to think about revisiting the idea of using a MicroController. After all, I just said the Edge device should be as simple as possible. So I did some looking and reading, and I think I have my answer: The ESP32.
Not my first ESP rodeo
So full disclosure: This is not the first time i’ve used an ESP32. In fact, I have 3 on my workbench I bought months ago. When I started working on IoT with AWS I bought a couple to start learning about Microcontrollers. However this didn’t last long, as everything was in C/C++. I have never known C or even the essentials. And so my motivation to learn was there, but I always ended up getting really frustrated, and since I had no idea how C/C++ worked, troubleshooting was so hard. I went with the Pi for this project because it was familiar. It was Linux, it runs Python, etc. But then I learned about something life changing; MicroPython.
You can run Python on a Microcontroller! I started looking into MicroPython and did a few getting started guides. I was able to accomplish more in 20 minutes with MicroPython than I did in hours with C/C++ and the Arduino IDE. I was able to get the anemometer/wind speed working immediately with very little work so that was a great start. I’m thinking this may be the way to go.
It also is way better from a hardware perspective. It has 12 ADC built in pins. So that will reduce the number of external ADCs I have to include. It also sips power. The Pi Zero sips power too, but the ESP32 is on a whole other level. So it will last even longer on a battery/solar panel. The only downside is while it does include Wifi, I am using a wired connection. So I have ordered an ethernet breakout board that should work, and so i’ll update when I get that and see if it works.
One of the disadvantages of switching to an ESP32 vs a Pi is a change of management. With a Pi I can just SSH in and Bob’s your uncle. but with an ESP32, that’s not an option. However, I did learn that the CradlePoint apparently supports Serial redirection with the USB Port! You can actually SSH to the Cradlepoint unit and then connect to the serial port. However this requires a FTDI serial connection, and by default most ESP32 boards i’m finding use a CP201x from Silicon labs. I did buy a couple FTDI breakouts and am gonna see if that works. If it does i’ll be able to connect up just like I do from a laptop, but over the internet.
So I know this post was kinda rambly, but I really just wanted to get my thoughts down regarding the Pi vs Microcontroller setup. Having the ability to run Python on the ESP32 means there’s no reason to not use it. The Pi is an amazing device but when the device literally has one job: read input from about 20 sensors, less is more.