I took a little hiatus on this project as I got my Ham Radio License (AC3HG). During that time, I had the base station receiving data, storing it to InfluxDB and and displaying it on Graphana:
During this time, I fixed a few bugs, but for the most part, as the Weather Station sat outside during the winter, it was pleasantly stable.
I'm now starting to work on a dedicated base station for the weather station, and I've selected an East Rising 7" Capacitive Touchscreen from buydispay.com as the display. These are some notes as I worked to get the screen functioning.
These screens draw a decent amount of current; on the order of 250 - 300 mA. This is way more current than the on board 3.3V regulator on an ESP32 development module can supply. You need to power the display from another power supply. Don't as me how long it took me banging my head against a wall before I figured this out.
I'm using the Adafruit RA8875 Library to drive the display. The problem is, this library was created for an Atmel based Arduino, and not the ESP32, and this caused some problems.
When writing fonts, especially when you are enlarging fonts to 2 and 3 times their normal size, it takes a bit of time for the display to render the fonts. If you send the text too quickly, the display driver will skip characters; for example, sending tft.textWrite("12345") will only display "135". The Adafruit library just has a delay(1) to give the display driver time to render the character, but this isn't enough for the ESP32 to render reliably. The RA8875 display driver has a WAIT pin that the Adafruit library does not implement, which is driven low when the driver is busy, and raised high when it is ready (see below). I had to implement reading the value on that pin in code to get the text rendering to work well.
The library also defaults to 4 MHz speed for SPI. If there is a #define variable called ARDUINO_ARCH_ARC32 (intended to indicate the Arduino 101 board), the SPI frequency will be set to 12 MHz, so a work around is simply to add
build_flags = -D ARDUINO_ARCH_ARC32=1
in platformio.ini, so SPI is running at higher speed. A big problem, though, is there is a bug in the library when doing a bulk data transfer in the drawPixels, the speed is set to 4 MHz regardless of the board architecture. This is used when you want to draw a background image, where you will be writing to all 800 x 480 pixels, and without the fast SPI, it takes several seconds to transfer the data to the display. I just had to recode that function call. According to the RA8875 documentation, I should be able to set the SPI speed to 20 MHz, but the data transfer isn't very reliable at that speed. This is probably because of the rat's nest of wires on the breadboard right now, so I just sent a bunch of gerber files to China to get a PCB for further development.
Speaking of the background image, storing a full 800 x 480 pixels, at 2 bytes for color data each pixel, takes 768K. Storing that in flash drove me up to using 91% of my flash space, without really much code. To free up space, I changed the ESP32's partition table. By default, the flash space in the ESP32 is divided up into 2 1.3M partitions for the application, and 1.5M for the SPIFFS partition. There are 2 application partitions for over the air flash update, where an application running in app0 loads an OTA update into app1, and then reboots into app1. Then when that application is running in app1, and loads an OTA update, it goes into app0. As OTA updates are sent to the ESP32, the ESP32 switches between booting from app0 and app1. The SPIFFS partition is a where various static content can be stored, usually for a web interface. Since I'm not using that feature, I can select the min_spiffs partition table, which gives 1.96 M to the apps, and only 196 k to SPIFFS. In platformio, the partition table can be selected with
board_build.partitions = min_spiffs.csv
in platformio.ini. Hopefully this will give me enough space for this project.