I have -too many, err- some extra ESP32 boards so I thought it would be fun to make a small weather display for the SEO weather. The obvious choice is to use MozCast. This is Moz’s unique interpretation of how Google’s search results change. This doesn’t reflect what Google does in its algorithms, but it’s a number for the weather, so why not.
It’s hopefully obvious that this does not represent a recommendation of any particular SEO tool. To be honest, I’m not a fan of any SEO weather reports, in particular because of the way the data is collected. The folks from Moz have been smart & friendly in the past, so I hope they’re OK with this hack. (I’m happy to send someone from Moz one of these, if you drop me a note.)
tl;dr: The code is here.
It doesn’t take a lot to make one of these. The hardware I used is an “ESP32” development board with integrated display, that uses a USB-C port for power & programming. I used the Arduino programming environment to write the code, using a few libraries that you can add with the UI.
I used a “Lilypad TTGO with T-Display”. (ESP32 is the name of the main module that includes the CPU, memory, wifi, etc.) There are other ESP32 boards with built-in display, which will probably work (but you’ll have to adjust the code).
Here’s a sample device from Aliexpress. They’re currently $10-25. Chips are a bit more expensive than they used to be, so YMMV. You can often get these locally if you prefer. You don’t need any other hardware, the rest is free software. Yay.
The code is Arduino C++, and uses libraries for the display and for the wifi access point (to connect to your wifi).
The code sets up a wifi access point, where you can connect to your local wifi to gain access to the internet. The internet connection is only used to fetch the MozCast data. There’s no analytics or tracking in the code on my side (and I’m pretty sure none of the libraries do that either).
Once there’s a wifi connection to the web, every X minutes it downloads the MozCast page, tries to pull out the current weather, and displays it.
It’s messy, but it works for me.
Libraries used (all in the Arduino UI):
- For the display: TFT_eSPI - github.com/Bodmer/TFT_eSPI
- For setting up wifi: ESP_DoubleResetDetector - github.com/khoih-prog/ESP_DoubleResetDetector
- Also wifi: ESP_WiFiManager - github.com/khoih-prog/ESP_WiFiManager
For the setup, see the code.
Fetching the data
The HTML page includes JSON data for the weather, which I used. The page is long, so I can’t just fetch it and pull out the information with an ESP32 device. Instead, I fetch the page in 128 byte sections, and search for the start of the data block across 2 consecutive blocks. Once the start is found, I collect 1kb of data. That’s more than what’s needed (the data is in the beginning of a JSON block). After getting that data, I extract the JSON entries with a simplified JSON parser.
The MozCast data seems to update once a day, though I didn’t track the details. Fetching the data every hour or so should be enough for freshness (since it’s unprectable from my POV when exactly the data will update).
The display shows the current temperature, the filename of the weather icon shown, the date, and the previous temperature. MozCast doesn’t specify a unit (C or F), and it’s arbitrary anyway. Additionally, it displays the server time from the HTTP response header in the bottom of the display.
Random comments …
- Moz is probably a trademark. Maybe MozCast is too? I didn’t see anything off-hand.
- Does not keep or reuse any cookies from the MozCast servers. Your requests may be logged with your public IP address though.
- I don’t think ESP_WiFiManager stores any cookies or keeps any analytics either, but it’s not under my control. It stores the wifi credentials in the device’s local flash memory.
- The time on the bottom is from the HTTP response headers and may vary depending on the server you get.
- The code is a messy mix of String() and chars - it works for me.
- If Moz changes their setup, this will stop working. I have no particular plans to keep it working, but I might.
- If Moz wants me to remove the code, I’ll remove it.
- I don’t have plans to implement other search-weather reports. Knock yourself out if you want to do it. The HTML parsing is messy, a JSON API would be easier.
- I have no affiliations with Moz. They’re not paying for this link.
- I don’t know how MozCast works, I’m guessing it’s 100% accurate (works as implemented).
Comments / questions
There's currently no commenting functionality here. If you'd like to comment, please use Twitter and @me there. Thanks!