Notifications
Clear all

DHT22 with STM32F1o3C8T6 "blue pill"

1 Posts
1 Users
0 Likes
4,238 Views
VE1DX
(@ve1dx)
Member
Joined: 5 years ago
Posts: 143
Topic starter  
STM DHT22
Blue Pill schematic
/*
* Use STM32 "blue pill" board to read a DHT22 temperature and humidity sensor
* (and wink a LED.)
*/

#include <DHT.h> // Adafruit Unified Sensor version 1.3.8

#define DHTPIN PA1 // Physical pin 11

#define DHTTYPE DHT22

int LEDpin = PA8; // Physical pin 29

DHT dht(DHTPIN, DHTTYPE); // Initilize object dht for class DHT
// with DHT pin with STM32 and DHT type as DHT22

void setup()
{
pinMode(LEDpin, OUTPUT);
Serial.begin(9600);
dht.begin(); // Initialize DHT22 to read Temperature and humidity values.
delay(3000); // Wait 3 seconds for it to stabilize
}


void loop()
{

int i;

for (int i = 1; i <= 8; i++) // Wink LED before reading for no good reason
// other than to wait between readings
{
digitalWrite(LEDpin, HIGH);
delay(250);
digitalWrite(LEDpin, LOW);
delay(250);
}

float h = dht.readHumidity(); // Get Humidity value
float t = dht.readTemperature(); // Get Temperature value

Serial.print(t,1); // Print to serial monitor screen
Serial.print(" ");
Serial.print(h,1);
Serial.println();

digitalWrite(LEDpin, LOW);
delay(1000);
}

Mostly to learn KiCAD.  Wow!  A steep learning curve, but this is a super powerful program.  Still not very good at it, but it is worth the effort. Inspired by @robo-pi video.

Paul VE1DX


   
Quote