diff --git a/README.md b/README.md
index 240d354..05d62dc 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# ArduinoUniqueID
-This Library gets the Unique ID / Manufacture Serial Number from the Atmel AVR, SAM, SAMD, and ESP Microcontroller.
+This Library gets the Unique ID / Manufacture Serial Number from the Atmel AVR, SAM, SAMD, STM32, and ESP Microcontroller.
# Atmel AVR Microcontroller
@@ -61,6 +61,17 @@ The uniqueness of the serial number is guaranteed only when using all 128 bits.
* Atmel SAMD21 ARM Cortex-M0 - 16 bytes
+# STM32 Microcontroller
+
+STM32 32-bit Arm Cortex MCUs has a unique 96-bit serial number which is a concatenation of three 32-bit words, the address is different depending on the microcontroller.
+
+The [Arduino Core STM32](https://github.com/stm32duino/Arduino_Core_STM32) has the variable UID_BASE whos contain the first 32-bit word of the serial number.
+
+## Tested Microcontroller
+
+* STM32F103C8 (BluePill Board) - 12 bytes
+* STM32L073RZ (Nucleo L073RZ) - 12 bytes
+
# Espressif ESP Microcontroller
ESP microcontroller has basically two versions, ESP8266 and ESP32, each one has a specific function to request the chip id.
diff --git a/library.properties b/library.properties
index 3395766..42baa94 100644
--- a/library.properties
+++ b/library.properties
@@ -1,10 +1,10 @@
name=ArduinoUniqueID
-version=1.0.7
+version=1.0.8
author=Luiz Henrique Cassettari
maintainer=Luiz Henrique Cassettari
-sentence=Arduino Library to gets the Manufacture Serial Number from the Atmel AVR, SAM, SAMD, and ESP Microcontroller.
-paragraph=The ArduinoUniqueID Library use the buildin feature to select the manufacture serial number from the microcontroler. Suported microcontroler: Atmega328pb, Atmega328p, Atmega2560, Attiny85, SAM3X8E, SAMD21, ESP8266 & ESP32.
+sentence=Arduino Library to gets the Manufacture Serial Number from the Atmel AVR, SAM, SAMD, STM32, and ESP Microcontroller.
+paragraph=The ArduinoUniqueID Library use the buildin feature to select the manufacture serial number from the microcontroler. Suported microcontroler: Atmega328pb, Atmega328p, Atmega2560, Attiny85, SAM3X8E, SAMD21, STM32, ESP8266 & ESP32.
category=Other
url=https://github.com/ricaun/ArduinoUniqueID
-architectures=avr, esp8266, esp32, sam, samd
+architectures=avr, esp8266, esp32, sam, samd, stm32
includes=ArduinoUniqueID.h
diff --git a/src/ArduinoUniqueID.cpp b/src/ArduinoUniqueID.cpp
index 9598196..376bea0 100644
--- a/src/ArduinoUniqueID.cpp
+++ b/src/ArduinoUniqueID.cpp
@@ -88,6 +88,18 @@ ArduinoUniqueID::ArduinoUniqueID()
id[i*4+3] = (uint8_t)(pdwUniqueID[i] >> 0);
}
+#elif defined(ARDUINO_ARCH_STM32)
+ uint32_t pdwUniqueID[3];
+ pdwUniqueID[2] = *(uint32_t *)(UID_BASE + 0);
+ pdwUniqueID[1] = *(uint32_t *)(UID_BASE + 4);
+ pdwUniqueID[0] = *(uint32_t *)(UID_BASE + 8);
+ for (int i = 0; i < 3; i++)
+ {
+ id[i*4+3] = (uint8_t)(pdwUniqueID[i] >> 24);
+ id[i*4+2] = (uint8_t)(pdwUniqueID[i] >> 16);
+ id[i*4+1] = (uint8_t)(pdwUniqueID[i] >> 8);
+ id[i*4+0] = (uint8_t)(pdwUniqueID[i] >> 0);
+ }
#endif
}
diff --git a/src/ArduinoUniqueID.h b/src/ArduinoUniqueID.h
index f63cc57..6f484c8 100644
--- a/src/ArduinoUniqueID.h
+++ b/src/ArduinoUniqueID.h
@@ -15,8 +15,9 @@
#elif defined(ARDUINO_ARCH_ESP32)
#elif defined(ARDUINO_ARCH_SAM)
#elif defined(ARDUINO_ARCH_SAMD)
+#elif defined(ARDUINO_ARCH_STM32)
#else
-#error "ArduinoUniqueID only works on AVR, SAM, SAMD and ESP Architecture"
+#error "ArduinoUniqueID only works on AVR, SAM, SAMD, STM32 and ESP Architecture"
#endif
#if defined(ARDUINO_ARCH_AVR)
@@ -41,6 +42,9 @@
#elif defined(ARDUINO_ARCH_SAMD)
#define UniqueIDsize 16
#define UniqueIDbuffer 16
+#elif defined(ARDUINO_ARCH_STM32)
+#define UniqueIDsize 12
+#define UniqueIDbuffer 12
#endif
#define UniqueID8 (_UniqueID.id + UniqueIDbuffer - 8)