Weather station on OLED
A DHT11 measures temperature and humidity; an OLED screen shows them with a bar.
What you need
- TinkerPie V1 board (or the free online simulator)
- USB-C data cable
- Temperature + humidity DHT11
- OLED display 128 × 64 (SSD1306)
Wiring
DHT11: DATA → S1. OLED 128 × 64 → any SENSOR port.
Step by step
- Open Weather station on OLED in TinkerPie Studio. It opens as blocks.
- Wire it: DHT11: DATA → S1. OLED 128 × 64 → any SENSOR port.
- Press Run to try it in the simulator. Use the sliders and buttons under the board picture to test it.
- Connect TinkerPie with a USB-C cable in Chrome or Edge, press Connect, then Download. Or, with Studio started from the TinkerPie launcher on your computer, open the Arduino C++ tab and press Build & Flash.
- Change something: a colour, a number, a sound. Then run it again.
The code
This is the program the blocks make. The same program runs in the simulator and on the board.
JavaScript
var temp, humidity;
basic.forever(function () {
temp = sensors.dhtTemperature(Pin.S1, DhtType.DHT11);
humidity = sensors.dhtHumidity(Pin.S1, DhtType.DHT11);
oled.showText(['Temp: ',temp,' C'].join(''), 2);
oled.showText(['Humidity: ',humidity,' %'].join(''), 3);
oled.bar(humidity, 100, 5);
basic.pause(2000);
});
oled.clear();
oled.showText('Weather station', 0);Arduino C++ (TinkerPie library)
// Weather station on OLED
// Arduino C++ made by TinkerPie Studio from the blocks. Board: TinkerPie V1 (ESP32-S3).
// Arduino IDE: install the TinkerPie library (Studio menu > Arduino library), then Tools > Board > ESP32S3 Dev Module,
// USB CDC On Boot: Enabled, Flash Size: 16MB, Partition Scheme: 16M Flash (3MB APP/9.9MB FATFS), PSRAM: OPI PSRAM.
#include <TinkerPie.h>
using namespace tinkerpie;
double temp = 0;
double humidity = 0;
void setup() {
tinkerpie::begin();
basic::forever([]() {
temp = sensors::dhtTemperature(Pin::S1, DhtType::DHT11);
humidity = sensors::dhtHumidity(Pin::S1, DhtType::DHT11);
oled::showText(tp::str("Temp: ") + tp::str(temp) + tp::str(" C"), 2);
oled::showText(tp::str("Humidity: ") + tp::str(humidity) + tp::str(" %"), 3);
oled::bar(humidity, 100, 5);
basic::pause(2000);
});
oled::clear();
oled::showText("Weather station", 0);
}
void loop() {
tinkerpie::loop(); // runs the forever blocks and handles events
}More projects like this
Thirsty plant alarmA soil moisture sensor tells TinkerPie when the plant needs water: a sad face and a beep.Sensor projectsUltrasonic rulerMeasures how far your hand is, in centimetres, with an HC-SR04 sonar.Sensor projectsSmart dustbin lidWave over the bin: a servo opens the lid for two seconds, then closes it.Sensor projectsIntruder alarmA PIR motion sensor sees someone moving: red flashes and a siren.Sensor projectsRoom climate on an LCDAn AHT20 sensor and a 16 × 2 LCD. The matrix smiles when the room is comfortable.Sensor projectsFire alarmA flame sensor sees fire: red and orange flashing with a two-tone siren.Sensor projects