Sunday, March 5, 2023

ESP32-based Octopus Tracker Unit Rate Display

This project is based on the ESP32 and demonstrates how the chip can be used to connect to the internet, fetch useful data and display it.

octopus Tracker is a tariff which tracks the day-ahead wholesale prices of electricity and gas. This gets around the problem of energy being bought in advance at very high prices in 2022, making it by far the cheapest non-time of use tariff available in early 2023, but this comes at the expense of the tariff prices changing every day, so it's useful to have these prices conveniently displayed.

The project uses the esp-idf-json library and is based on the json-http-client2 example.

The code connects to wifi, then fetches the JSON data which contains the unit rates. The date and time in the HTTP response header is used to get the current date and time and set the ESP32's built-in RTC, which isn't displayed to the user, but used to refresh the prices every hour and determine what the current date is in order to display the correct prices from the JSON data.

The data is updated hourly because the day's unit rates are occasionally not available from the start of the day, and the correct unit rates won't be available for several hours in such a case.

Link to the source code on GitHub

Hardware design

Two three-digit 7-segment displays are used to display the prices. Each display already has three common anodes for the digits and has the matching segments of each digit connected together internally, and the segment pins of each display have been connected together to produce a display which is electrically a 6-digit multiplexed display. The anodes are switched with some general purpose PNP transistors because the peak current exceeds the current limit of a single ESP32 pin, and the segments are connected to ESP32 pins via resistors to limit the current.

A photodiode has been added to dim the display in conditions of low ambient light. An LDR would also be suitable. The voltage generated by the voltage divider is read using an ADC input and used to select one of four brightness levels. Filtering and hysteresis are used to avoid the brighness flickering in certain lighting conditions.

As an ESP32 WROOM 'dev kit' has been used for this project, the UART and 3.3V voltage regulator are built into the dev kit, so these components didn't have to be included in the circuit. Power to the project is supplied via a USB cable which is plugged into a convenient USB power supply.

Schematic

Schematic

Hardware

The prototype has been carefully built on the copper side of some stripboard, taking care to ensure that no leads are sticking through to the component side on which only the 7-segment displays and photodiode are mounted. The perfectly smooth surface of the component side has been used to apply some labels.

Hardware front
Hardware back

Adding an aspect radio switch to CRT TVs

This post is about a simple modification that can be done to many CRT TVs to add an aspect ratio switch. The main uses for this nowadays wo...