Displays
Retro weather computer
A tiny old-style computer whose green screen prints the temperature, humidity and air pressure of the room.
- Medium
- about 50 min
- ESP32-S3
- 6 parts
- 11 wires
- 68 lines of code
ESP32 packs are built on real parts: the simulator runs Arduino Uno circuits only.
Idea
Two different buses meet on one board: the sensor talks I2C on two wires, the screen talks SPI on five. Most real devices mix them the same way.
What you learn
Reading an I2C sensor, drawing text on an SPI screen, and updating only the part that changed.
How it works
input
BME280
decides
ESP32-S3
output
TFT 1.54 in
Powered with 5 V through the board's USB-C port.
A reference design. The sketch is compiled with the real ESP32 toolchain, and its pins are checked against the wiring table automatically. It has not yet been built and tested on real parts by us, so wire it on the bench and run the checks before you build it into a case. Real modules vary: follow the labels printed on yours, not their position in the picture.
Parts
0 of 6 ready
No prices here: they change by shop and by week. Buy each part by its name and the note beside it.
You also need
A computer with Arduino IDE 2 installed (free)
3D wiring
One jumper per step, with the USB cable unplugged. Several wires may share 3V3, 5V or GND: the expansion board or breadboard gives each its own pin.
Step 0 of 11
Lay out the parts
Seat the board on its expansion board or breadboard and lay the modules out round it. Nothing is connected yet.
All connections
retro-weather.ino
// Retro weather computer
// An old green-screen terminal that prints the room's temperature, humidity
// and air pressure.
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <Adafruit_BME280.h>
const int PIN_BME_SDA = 8;
const int PIN_BME_SCL = 9;
const int PIN_TFT_SCL = 12;
const int PIN_TFT_SDA = 11;
const int PIN_TFT_RES = 14;
const int PIN_TFT_DC = 13;
const int PIN_TFT_CS = 10;
const uint16_t PHOSPHOR = 0x07E0; // terminal green
Adafruit_ST7789 tft(PIN_TFT_CS, PIN_TFT_DC, PIN_TFT_RES);
Adafruit_BME280 bme;
bool sensorOk = false;
void line(int row, const char* label, float value, const char* unit) {
int y = 60 + row * 44;
tft.fillRect(0, y, 240, 40, ST77XX_BLACK);
tft.setTextSize(2);
tft.setCursor(10, y);
tft.print(label);
tft.setTextSize(3);
tft.setCursor(10, y + 18);
tft.print(value, 1);
tft.setTextSize(2);
tft.print(" ");
tft.print(unit);
}
void setup() {
Wire.begin(PIN_BME_SDA, PIN_BME_SCL);
SPI.begin(PIN_TFT_SCL, -1, PIN_TFT_SDA, PIN_TFT_CS);
tft.init(240, 240);
tft.setRotation(2);
tft.fillScreen(ST77XX_BLACK);
tft.setTextColor(PHOSPHOR);
tft.setTextSize(2);
tft.setCursor(10, 10);
tft.print("WEATHER-80 READY");
tft.drawFastHLine(0, 36, 240, PHOSPHOR);
sensorOk = bme.begin(0x76, &Wire) || bme.begin(0x77, &Wire);
if (!sensorOk) {
tft.setCursor(10, 100);
tft.print("?SENSOR NOT FOUND");
}
}
void loop() {
if (sensorOk) {
line(0, "TEMP", bme.readTemperature(), "C");
line(1, "HUMIDITY", bme.readHumidity(), "%");
line(2, "PRESSURE", bme.readPressure() / 100.0f, "hPa");
}
// a blinking cursor, like the real thing
static bool cursor = false;
cursor = !cursor;
tft.fillRect(10, 215, 14, 18, cursor ? PHOSPHOR : ST77XX_BLACK);
delay(1000);
}
Libraries
- Adafruit GFX Library: install it from Sketch > Include Library > Manage Libraries.
- Adafruit ST7735 and ST7789 Library: install it from Sketch > Include Library > Manage Libraries.
- Adafruit BME280 Library: install it from Sketch > Include Library > Manage Libraries.
Uploading
First time with an ESP32: in Arduino IDE open Boards Manager, search “esp32” and install “esp32 by Espressif Systems”.
- Open the sketch in Arduino IDE.
- Plug the board in with the USB-C cable.
- Tools > Board > ESP32S3 Dev Module, then Tools > Port and choose the board's port.
- Press Upload (the arrow). Wait for “Done uploading”.