Creating a UI on a microcontroller: Part 9

I finally got this library knocked into shape enough that I could start porting my application to it. Doing so showed up even more shortcomings but I've now fixed this and we're back into feature creep.

The application pretends to be a 'computer terminal' and needs to deliver movie style retro computer interactions. Once of these is looking at files stored on the SD card attached to the microcontroller. Which will sync across multiple 'nodes' running the same code.

I've spent a chunk of time this week improving how large chunks of text (or small files) display and have added support for basic Markdown formatting. You've limited capabilities in a dumb terminal but I think it does well enough at stopping it being a wall of uniform text.

Here's a quick video demo of the user interface in action. It can be driven entirely with keyboard but also the mouse works and you can click the buttons, scrollbar on the text window and so on.



Creating a UI on a microcontroller: Part 8

This week I'm back working on my 'rod for my own back' project, ie. making a library to display a useful user interface over the UART of a generic microcontroller.

This week I've started on actually using it for its intended purpose, faking up a retro mainframe computer on ESP8266/ESP32. Trying to refactor my original code for this application to use the library has shown up a few of things.

First I was definitely right to pull out all the code and turn it into a generic library. Secondly it was missing a few features I need but thirdly and most annoyingly it still has lots of bugs.

In particular I had created lots of bugs with redrawing changing items or things that appear, disappear or change frequently. The main application is too complicated to troubleshoot with so I wrote this trivial alarm clock. You set the time and alarm with the +/- under each digit and when they match it turns red, rings the bell and a cancel button appears.

Trivial as this application is, it's really helped with the troubleshooting and I've added a load more functions, one of which changes the title bar of the terminal emulator, if allowed. It's all boilerplate, not fancy algorithms, but I still get a real sense of satisfaction in controlling an AVR Arduino with the mouse and keyboard on the computer it's plugged in to.

Here's a little video of it in action.



Nordic Semiconductor Power Profiler II - dead useful

 I have been playing with the Nordic Power Profiler again today. I'm doing some SD card benchmarks. Not for any real reason but I'm curious.

As well as the speed, I was interested in the power use. Here you can see writes (on the left) using more peak power than the reads (on the right). However, unexpectedly the writes use less overall power. I assume this is because the code I'm using leaves the card in a different state between reads. The writing does a file.flush(); inbetween each test, so I will investigate if this is what's at play.

This is exactly what I bought this thing for.

Also it's a bit like having a tiny bench PSU connected to your computer with USB. I have used it to replace a 3.7v LiPo battery, direct 3.3v supply to a microcontroller and 5v supply to a development board instead of USB.

I continue to be very pleased with it. Only grumble so far is the 'digital channel'  display only shows when looking at 3s or less of samples. If you're using pins on a microcontroller as a low speed 'status' indicator rather than for busier signals this is not helpful.

Espressif ESP32-S2-Saola-1R development boards

On account of wanting to assess the power use of the ESP32-S2, not long ago I bought a WROOM module programmer on Tindie, mostly because there's a dearth of the single core ESP32-S2 in the wild. Most Espressif powered boards either use the dual core ESP32 or are still using the ESP8266.

Like most manufacturers, Espressif have their own development boards, but they're not widely sold. The ESP32-S2 variant, the Saola-1, is actually very affordably priced, only ~£5 and on release I considered buying some but the postage from any of the stockists was double the board cost.

Given I was ordering something else already that took me over the free delivery threshold, I tacked a couple of these onto my order. Now I have some boards that are easier to work with than the module programmer, which is nice but not really breadboard friendly.

These official development boards are well made and 'just work'. They're reminiscent of the original NodeMCU, slightly too long for a mini-breadboard and with nice sturdy tactile buttons connected to the reset and GPIO0 for programming. Not that you'll need them, auto-reset/program works like you'd expect.

There's a lack of clutter, beyond a single WS2812 RGB LED, connected to GPIO18.

You can buy them in both WROOM and WROVER variants and with/without a PCB antenna. I picked up the WROVER as I want to experiment with using the 2MB of PSRAM. My plan is to use this for storing bigger data structures than most microcontrollers can deal with, mostly as a big cache of messages sent over my mesh network so that they can be 'retained' for a fixed time if a node is temporarily unreachable.

Nordic Semiconductor Power Profiler II

Given I've been doing a lot of work recently that involves assessing power consumption, I saw a timely video from Adafruit looking at the Nordic Semiconductor Power Profiler II.

I've been sticking cheap INA219 modules into my various stripboard prototypes and exporting data every minute over MQTT. These are great for broad, macro scale measurements over a long-ish period.

What they can't however do is measure down to the resolution needed to assess how efficient deep sleep is and whether changes to code reduce the time spent transmitting or waiting to receive data over WiFi. The former is very power hungry and must be minimised to save battery. The latter might be tuneable to help.

Professional equipment to do this is really quite expensive. The newly released Power Profiler II kit from Nordic is in the hobbyist friendly price range of ~£100. Mildly extravagant and you could perhaps roll your own but this price point is not ridiculous given the time you'd spend building the tool if you want it to work well. Which is why I've treated myself to my first new tool of 2020.

I've got one of my old macro spreadsheets to analyse for the ESP32-S2 WROOM module, but after that I'll be using the Power Profiler to delve deeper into how much power my prototypes are using and if there's anything I can do to improve this.