Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsThe 1.8 inch ST7735 TFT is cheap, bright and drawn over SPI. With a BMP280 for temperature and pressure, the ESP32 can draw large coloured numbers and a small graph of the last hour of pressure, which is how many weather stations show a falling or rising trend. Both modules need only a few wires. The sketch keeps a short history in memory and redraws the graph every minute.
Tick anything you already have and the total updates.
BMP280 temperature and pressure sensor
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB phone charger.
tft_dashboard.inoVerify & upload in Electrolark#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <Adafruit_BMP280.h>
#include <Wire.h>
#define TFT_CS 5
#define TFT_RST 4
#define TFT_DC 2
Adafruit_ST7735 tft(TFT_CS, TFT_DC, TFT_RST);
Adafruit_BMP280 bmp;
const int N = 100;
float hist[N];
int count = 0;
unsigned long lastSample = 0;
void drawGraph() {
tft.fillRect(0, 76, 160, 52, ST77XX_BLACK);
if (count < 2) return;
float lo = 2000, hi = 0;
for (int i = 0; i < count; i++) { lo = min(lo, hist[i]); hi = max(hi, hist[i]); }
if (hi - lo < 2) { hi += 1; lo -= 1; }
for (int i = 1; i < count; i++) {
int x0 = 30 + (i - 1) * 120 / N, x1 = 30 + i * 120 / N;
int y0 = 124 - (hist[i - 1] - lo) / (hi - lo) * 44;
int y1 = 124 - (hist[i] - lo) / (hi - lo) * 44;
tft.drawLine(x0, y0, x1, y1, ST77XX_CYAN);
}
}
void setup() {
Wire.begin(21, 22);
bmp.begin(0x76);
tft.initR(INITR_BLACKTAB);
tft.setRotation(1);
tft.fillScreen(ST77XX_BLACK);
}
void loop() {
float t = bmp.readTemperature(), p = bmp.readPressure() / 100.0;
tft.setTextSize(3);
tft.setTextColor(ST77XX_YELLOW, ST77XX_BLACK);
tft.setCursor(4, 6); tft.printf("%.1fC ", t);
tft.setTextSize(2);
tft.setTextColor(ST77XX_GREEN, ST77XX_BLACK);
tft.setCursor(4, 44); tft.printf("%.0f hPa ", p);
if (millis() - lastSample > 60000 || count == 0) {
lastSample = millis();
if (count == N) { memmove(hist, hist + 1, (N - 1) * sizeof(float)); count--; }
hist[count++] = p;
drawGraph();
}
delay(1000);
}
Check CS, DC and RST wiring and the 3.3 V supply; try the other INITR tab option.
Many modules use address 0x76, some 0x77. Change the begin call or run an I2C scanner.
Try INITR_GREENTAB or INITR_REDTAB in the setup.
No. It is the actual pressure where you are. Weather sites quote sea-level pressure, which is higher.
100 samples, one a minute, about 100 minutes.
Yes, an ILI9341 works with similar code and another library.
5 parts: ESP32-WROOM-32 38-Pin Development Board, 1.8″ ST7735 TFT LCD Module 128×160 SPI, BMP280-5V Temperature and Barometric Pressure Sensor Module, Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
No. This page has the complete, tested code (tft_dashboard.ino).
About ₹772 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Drawing text and graphs on a TFT with Adafruit GFX; Reading a BMP280 over I2C; Storing a rolling history in an array.
Ideas that reuse this build: Colour TFT weather dashboard. They are listed under Take it further on this page.
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Press to roll: the pips tumble and slow down before landing on a number.
Wait for the light, hit the button: how many milliseconds can you beat?
A bright 4-digit clock that keeps time through power cuts.
Learning project. Check every circuit and the datasheet of each part before you power it up.