VE1DX
Published © GPL3+

Use an STM32F103C8T6 ("Blue Pill") with the Arduino IDE!

This project demonstrates how to program a "blue pill" STM32 directly with the Arduino IDE without a Serial FTDI to flash the bootloader.

IntermediateFull instructions provided3,470
Use an STM32F103C8T6 ("Blue Pill") with the Arduino IDE!

Things used in this project

Hardware components

MapleTree Mini - STM32duino STM32F103RB Compatible with Leaf Maple
MapleTree Mini - STM32duino STM32F103RB Compatible with Leaf Maple
I used an STM32F103C8T6 obtained from Amazon
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
Resistor 221 ohm
Resistor 221 ohm
×1
5 mm LED: Red
5 mm LED: Red
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Schematics

STM32 "blue pill" Breadboard layout

Code

STM32 "blue pill" board to read a DHT22 temperature and humidity sensor

Arduino
/*
 * Use STM32 "blue pill" board to read a DHT22 temperature and humidity sensor
 * (and wink a LED.)
 * 
 * Paul M Dunphy VE1DX
 * April 2020
 * 
 */

#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);
}

Credits

VE1DX

VE1DX

2 projects • 6 followers

Comments