# longgang/stm32_mqtt_onenet_esp8266_freertos-main architecture

> Architecture diagram of the GitHub repository longgang/stm32_mqtt_onenet_esp8266_freertos-main, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main
- Repository: https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main

## Overview

This is STM32F103 firmware for an indoor security system. The documented workflow monitors smoke, temperature/humidity, light, and occupancy; evaluates security/alarm conditions; and presents readings locally and to an ESP8266-connected host. The README also describes owner-controlled arming and audible/LED alarms. Firmware entry-point and driver call paths were not sampled, so relationships beyond the documented capabilities are shown as unverified; the graph does not assert a specific task or message flow.

Main entry points: [`HARDWARE/scr/control.c`](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/control.c) (Security control), [`USER/main.c`](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/USER/main.c) (Firmware entry), [`HARDWARE/scr/adc.c`](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/adc.c) (Smoke sensing), [`HARDWARE/scr/lcd.c`](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/lcd.c) (LCD status)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sensing["Sensors"]
  node_occupancy["Occupancy sensing<br/>[control.c]"]
  node_smoke["Smoke sensing<br/>[adc.c]"]
  node_climate["Temperature and humidity<br/>[dht11.c]"]
  node_light["Light sensing<br/>[bh1750.c]"]
end

subgraph group_security["Security and alarms"]
  node_security_logic["Security control<br/>[control.c]"]
  node_alarm["LED and buzzer<br/>[led.c]"]
  node_beeper["Buzzer driver<br/>[BEEP.c]"]
end

subgraph group_interfaces["Displays and network"]
  node_lcd["LCD status<br/>[lcd.c]"]
  node_wifi["ESP8266 link<br/>[wifi.c]"]
  node_mqtt["MQTT reporting<br/>[mqtt.c]"]
end

subgraph group_runtime["Firmware runtime"]
  node_main["Firmware entry<br/>[main.c]"]
  node_rtos_tasks["Task scheduler<br/>[tasks.c]"]
  node_rtos_queues["Queues and sync<br/>[queue.c]"]
  node_rtos_timers["Software timers<br/>[timers.c]"]
  node_adc_hal["ADC peripheral<br/>[stm32f10x_adc.c]"]
  node_timer_hal["Timer peripheral<br/>[stm32f10x_tim.c]"]
end

node_owner(("Homeowner"))
node_host(("Host interface"))

node_occupancy -.->|"informs"| node_security_logic
node_smoke -.->|"informs"| node_security_logic
node_light -.->|"informs"| node_security_logic
node_climate -.->|"displayed on"| node_lcd
node_smoke -.->|"displayed on"| node_lcd
node_light -.->|"displayed on"| node_lcd
node_occupancy -.->|"displayed on"| node_lcd
node_security_logic -.->|"triggers"| node_alarm
node_security_logic -.->|"triggers"| node_beeper
node_security_logic -.->|"reports status"| node_mqtt
node_mqtt -.->|"uses link"| node_wifi
node_wifi -.->|"sends updates"| node_host
node_owner -.->|"controls arming"| node_host
node_owner -.->|"arms system"| node_security_logic
node_main -.->|"starts runtime"| node_rtos_tasks
node_main -.->|"uses"| node_occupancy
node_main -.->|"uses"| node_smoke
node_main -.->|"uses"| node_climate
node_main -.->|"uses"| node_light
node_smoke -.->|"reads ADC"| node_adc_hal
node_rtos_tasks -.->|"coordinates via"| node_rtos_queues
node_rtos_tasks -.->|"uses timers"| node_rtos_timers

click node_occupancy "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/control.c"
click node_smoke "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/adc.c"
click node_climate "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/dht11.c"
click node_light "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/bh1750.c"
click node_security_logic "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/control.c"
click node_alarm "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/led.c"
click node_beeper "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/BEEP/BEEP.c"
click node_lcd "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/lcd.c"
click node_wifi "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/wifi.c"
click node_mqtt "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/mqtt.c"
click node_main "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/USER/main.c"
click node_rtos_tasks "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/FreeRTOS/tasks.c"
click node_rtos_queues "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/FreeRTOS/queue.c"
click node_rtos_timers "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/FreeRTOS/timers.c"
click node_adc_hal "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/STLIB/src/stm32f10x_adc.c"
click node_timer_hal "https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/STLIB/src/stm32f10x_tim.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_occupancy,node_smoke,node_climate,node_light toneBlue
class node_security_logic,node_alarm,node_beeper toneAmber
class node_lcd,node_wifi,node_mqtt toneMint
class node_main,node_rtos_tasks,node_rtos_queues,node_rtos_timers,node_adc_hal,node_timer_hal toneRose
class node_owner,node_host toneIndigo
```

## Components

### Sensors

- [Occupancy sensing](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/control.c): `HARDWARE/scr/control.c`
- [Smoke sensing](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/adc.c): `HARDWARE/scr/adc.c`
- [Temperature and humidity](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/dht11.c): `HARDWARE/scr/dht11.c`
- [Light sensing](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/bh1750.c): `HARDWARE/scr/bh1750.c`

### Security and alarms

- [Security control](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/control.c): `HARDWARE/scr/control.c`
- [LED and buzzer](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/led.c): `HARDWARE/scr/led.c`
- [Buzzer driver](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/BEEP/BEEP.c): `HARDWARE/BEEP/BEEP.c`

### Displays and network

- [LCD status](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/lcd.c): `HARDWARE/scr/lcd.c`
- [ESP8266 link](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/wifi.c): `HARDWARE/scr/wifi.c`
- [MQTT reporting](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/HARDWARE/scr/mqtt.c): `HARDWARE/scr/mqtt.c`

### Firmware runtime

- [Firmware entry](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/USER/main.c): `USER/main.c`
- [Task scheduler](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/FreeRTOS/tasks.c): `FreeRTOS/tasks.c`
- [Queues and sync](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/FreeRTOS/queue.c): `FreeRTOS/queue.c`
- [Software timers](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/FreeRTOS/timers.c): `FreeRTOS/timers.c`
- [ADC peripheral](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/STLIB/src/stm32f10x_adc.c): `STLIB/src/stm32f10x_adc.c`
- [Timer peripheral](https://github.com/longgang/stm32_mqtt_onenet_esp8266_freertos-main/blob/main/STLIB/src/stm32f10x_tim.c): `STLIB/src/stm32f10x_tim.c`

### Other components

- **Homeowner**
- **Host interface**

## Connections

- Occupancy sensing → Security control: informs
- Smoke sensing → Security control: informs
- Light sensing → Security control: informs
- Temperature and humidity → LCD status: displayed on
- Smoke sensing → LCD status: displayed on
- Light sensing → LCD status: displayed on
- Occupancy sensing → LCD status: displayed on
- Security control → LED and buzzer: triggers
- Security control → Buzzer driver: triggers
- Security control → MQTT reporting: reports status
- MQTT reporting → ESP8266 link: uses link
- ESP8266 link → Host interface: sends updates
- Homeowner → Host interface: controls arming
- Homeowner → Security control: arms system
- Firmware entry → Task scheduler: starts runtime
- Firmware entry → Occupancy sensing: uses
- Firmware entry → Smoke sensing: uses
- Firmware entry → Temperature and humidity: uses
- Firmware entry → Light sensing: uses
- Smoke sensing → ADC peripheral: reads ADC
- Task scheduler → Queues and sync: coordinates via
- Task scheduler → Software timers: uses timers
