Note: * is a required field,
please fill it in during the registration stage↓
* 1. Introduction to project functions
STM32 terminal controller, the original intention of the design is to make an indoor and outdoor sensor control detection and control product with Bluetooth BLE and LORA transmission functions.
This project is based on the STM32F103C8T6 model that is often used by DIY enthusiasts. Through LORA or BLE, the real-time display of the remote master control is realized. The biggest feature of this system is that it has a remote control and backup power supply system.
Supports the national technology N32G430C8L7 solution chip.
*2. Project attributes
This project is completely original and open to the public for the first time. The code, self-made code, PCB and schematic diagram are completely open source. Data resale is prohibited, otherwise the consequences are at your own risk. This project took 2 months before and after, and two versions of PCB proofing were made, following the GPL3.0 agreement. Please also support open source and jointly maintain the domestic open source environment.
* 3. Open source agreement
GPL3.0 open source agreement Schematic diagram, PCB, code are completely open source, but individuals are not allowed to make, sell or resell data. If you need to use it, please indicate the source. First of all, I would like to thank Mr. Du Yang for his "30 Steps to Getting Started with STM32". The detailed tutorial materials helped me get started with STM32CubeIDE. The code is here for reference. I hope everyone will pay tribute to the spirit of open source. Secondly, I would like to thank the various open source projects in the LiChuang open source platform, which provided me with innovative ideas and theoretical support. Finally, I would like to thank LiChuang EDA for providing this rare and valuable opportunity. I am also very grateful for everything LiChuang EDA has done for open source construction. I believe that under the leadership of LiChuang open source platform, the domestic open source environment will get better and better. Let's cheer together!
*4. Hardware part
• Product name: IoT terminal device based on STM32 • Main functions: 1. The temperature and humidity values of the environment can be read, and the electrical appliances can be turned on/off through the relay at the set temperature; 2. The device can be connected through the mobile phone Bluetooth BLE, and after the connection, the temperature and humidity values, brightness, voltage value, connection status, control LED, system restart, relay switch and other functions can be displayed; 3. Wireless serial port multi-machine communication can be carried out through LORA module spread spectrum modulation (model: A39C-T400A22D1A), and the actual measured extremely complex transmission distance can reach up to 1000 meters (official promotion unobstructed 5000 meters). By using the master-slave mode, automatic relay, and transmission method of this module. Ultra-low power consumption is achieved, which can be widely used in various environments and easily realize low-frequency wireless data transmission. Please note: This project uses 9600 baud rate in USART2, and 115200 in other cases; 4. When the system fails, the buzzer alarms and uploads the alarm event to the user, and the relay automatically powers off when abnormal; 5. The slave contains HLK-5G human body sensor, which can judge the current presence of people in real time; 6. The slave contains BH1750 light sensor, which can accurately and in real time judge the current ambient brightness; 7. The slave contains 0.96-inch OLED screen, which makes debugging more convenient and data more intuitive; 8. The slave contains CH340N serial port chip, which can realize communication and debugging with PC; 9. Both the slave and the receiver use charging and discharging integrated circuits. When the battery power is detected to be lower than the limit voltage, the MCU is forced to enter the standby state to reduce power consumption; 10. Use dual ADC detection to realize external power supply and battery power supply detection. Reserve MQ-X sensor interface (normal operation when external power supply 5V input); 11. The receiver is equipped with a 1.44TFT display screen to display the received temperature, humidity, light, voltage and other data in real time.
V1.0 version photos:

V1.1 version photos:
(1) Slave - front

(2) Slave - back

(3) Slave - working status

(4) Slave - working status

(5) Receiver - working status

(6) Master-slave - working status

Due to time constraints, the receiving end voltage display has not yet been made; there is a decimal point that has not been added to the space on the OLED for ADC sampling (it will be completed one by one in the future):
*5. Software part
The slave (sensor end) code is edited using STM32CubeIDE 1.8.0; the receiving end code is edited using Keil5 MDK. The following are some codes on the STM32Cube side:
while (1) { HAL_NVIC_DisableIRQ(DMA1_Channel1_IRQn);//Disable DMA interrupt DHT11_ReadData(DHT11_BUF);//Read DHT11 sensor data (the parameter is the array pointer for storing data) HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);//Enable DMA interrupt
bh1750_lux = Get_BH1750_Value();
if(USART2_RX_STA&0x8000){//Judge the interrupt reception flag (Bluetooth module BT, using USART2)
if((USART2_RX_STA&0x7FFF) == 1) //Judge the number of received data: 1 (mobile phone control program) { switch (USART2_RX_BUF[0]){//Judge the content of received data case 0x41: RELAY_1(1);////Relay control program (0 relay open, 1 relay closed) BT_printf("Relay ON");//Return data content and display it on the mobile phone APP break; case 0x44: RELAY_1(0);////Relay control program (0 relay open, 1 relay closed) BT_printf("Relay OFF");//Return data content and display it on the mobile phone APP break; case 0x42: LED_2(1);//LED2 control BT_printf("LED1 ON");//Return data content and display it on the mobile phone APP break; case 0x45: LED_2(0);//LED2 control BT_printf("LED1 OFF");//Return data content and display it on the mobile phone APP break; case OFF");//Return data content and display it on the mobile phone APP break; case 0x43: BUZZER_SOLO1();//Buzzer outputs a single-tone alarm sound BT_printf("BEEP");//Return data content and display it on the mobile phone APP break; case 0x46: BT_printf("CPU Reset");//Return data content and display it on the mobile phone APP break; case 0x46: BT_printf("CPU Reset");//Return data content and display it on the mobile phone APP HAL_Delay(1000);//Delay NVIC_SystemReset();//System software reset function break; default: //Redundant statement break; } } USART2_RX_STA=0;//Flag cleared to 0, ready for next reception }
if(dmaadc[0]<3200){ BT_printf("Enter shutdown state!
"); HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON,PWR_STOPENTRY_WFI); SystemClock_Config(); BT_printf("Exit stop state!
"); }
*6. BOM list
The BOM can refer to the schematic diagram, which is basically consistent with the component number of the mall .
The following figures are the BOM tables of the slave and receiver respectively.

If you are interested in the LORA module used in this project, please click the AS15-USB-T3 serial port module adapter board project, which contains a purchase link.
*7. Competition LOGO verification
* 8. Demonstrate your project and record it into a video and upload it.
Please click: https://www.bilibili.com/video/BV1PW4y1U7hx/Bluetooth
control demonstration video: https://www.bilibili.com/video/BV11N4y1V7FH/