Raspberry Pi Pico weather display (MicroPython)
Your first MicroPython project: temperature and humidity on an OLED.
Shop by category
Shop all componentsThe WeAct STM32G030F6 board is a thumb-sized Cortex-M0+ with 32 KB flash, a 12-bit ADC and hardware PWM. An MF58 10K 3950 NTC thermistor and a 10K resistor make a voltage divider; the ADC reading gives the resistance, and the Beta equation turns it into degrees. Above 35 C the fan starts, and it reaches full speed at 50 C through a MOSFET module. The board has no USB data, so you program it with an ST-Link over SWD.
Keep the 12 V wiring away from the glass thermistor body; it is fragile.
Tick anything you already have and the total updates.
MOSFET switch module for the fan
Follow the colours: red is power, dark grey is ground, blue is a signal.
12 V adapter for the fan; a buck converter makes 5 V for the board.
ntc_fan.inoconst int NTC_PIN = PA0, FAN_PIN = PA6;
const float R_FIXED = 10000, R0 = 10000, T0 = 298.15, BETA = 3950;
const float T_ON = 35, T_FULL = 50;
float readC() {
long sum = 0;
for (int i = 0; i < 16; i++) sum += analogRead(NTC_PIN);
float a = sum / 16.0; // 12-bit: 0..4095
float r = R_FIXED * a / (4095.0 - a); // NTC on top, resistor to GND
return 1.0 / (log(r / R0) / BETA + 1.0 / T0) - 273.15;
}
void setup() {
analogReadResolution(12);
pinMode(FAN_PIN, OUTPUT);
}
void loop() {
float t = readC();
int duty = 0;
if (t >= T_FULL) duty = 255;
else if (t > T_ON) duty = 90 + (t - T_ON) * (255 - 90) / (T_FULL - T_ON); // fans need a minimum to start
analogWrite(FAN_PIN, duty);
delay(500);
}
Check SWDIO/SWCLK are not swapped and that STM32CubeProgrammer is installed; hold reset while connecting if the chip was asleep.
The divider is the other way round: swap the NTC and the resistor, or invert the formula.
That is the PWM frequency; use analogWriteFrequency(25000) or run it on/off only.
An NTC is cheaper, faster and survives heat well; you trade some accuracy and need the Beta value.
Yes, send the PWM to its blue control wire at 25 kHz and keep 12 V on all the time.
No, the G030 has no USB peripheral; program it with an ST-Link or its UART bootloader.
9 parts: WeAct Studio STM32G030F6P6 Core Demo Board, HaiWang MF58 10K 3950 1% NTC Thermistor Temperature Sensor, Resistor Assortment Kit (30 Values), MOSFET Switch Module, Relay Replacement (D4184 / LR7843), Generic 12V 4010 Cooling Fan for 3D Printer Extruders, Step-Down Converter to 5V USB / 5V 3A, DC Power Adapter (5.5x2.1mm), Solderless Breadboard and Dupont Jumper Wires (40 pcs). Tools: ST-Link V2 Programmer for STM8 and STM32 MCUs. On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 2 hours. The build on this page has 7 steps.
No. This page has the complete, tested code (ntc_fan.ino).
About ₹663 for the parts at the prices on this page, plus tools if you do not have them. Quantity price breaks lower the cost when you build several.
Programming an STM32 over SWD with STM32duino; Reading an NTC with a divider and the Beta equation; Driving a 12 V fan with PWM and a MOSFET.
Keep the 12 V wiring away from the glass thermistor body; it is fragile.
Your first MicroPython project: temperature and humidity on an OLED.
A web page with ON and OFF buttons that switches a relay over Wi-Fi.
A warm ring light that fades up at dusk and down at dawn.
Turn a Pi and a touchscreen into a home command centre with a clock and to-do list.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.