Skip to content

CO2_Gateway

STM32F103 and W5500 based gateway converting RS-485 Modbus sensor data into TCP/IP for smart factory, greenhouse and building monitoring systems.

Aimee0

Published January 29, 2026

Original author: inmind666Original source (new tab)

CO2_Gateway

Components

Hardware components

WIZnet parts

Project description

CO2_Gateway

๐Ÿ“Œ Overview

 STM32F103 + WIZnet W5500 ์กฐํ•ฉ์œผ๋กœ RS-485(Modbus RTU) ์„ผ์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ด๋”๋„ท(TCP)์œผ๋กœ ์—ฐ๋™ํ•˜๋Š” โ€œํ˜„์žฅ ์„ผ์„œ โ†” ๋„คํŠธ์›Œํฌโ€ ๊ฒŒ์ดํŠธ์›จ์ด ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค. MCU ์„ค์ • ํŒŒ์ผ์—์„œ STM32F103C8T6 ๊ณ„์—ด ์‚ฌ์šฉ์ด ํ™•์ธ๋ฉ๋‹ˆ๋‹ค.

๐Ÿ“Œ Features

RS-485(Modbus RTU) ์งˆ์˜/์‘๋‹ต ๊ธฐ๋ฐ˜ ์„ผ์„œ๊ฐ’ ์ˆ˜์ง‘

  • CRC16 ๊ณ„์‚ฐ ํ›„ ํ”„๋ ˆ์ž„ ์†ก์‹ , ์ˆ˜์‹  ๋ฐ์ดํ„ฐ ๊ธฐ๋ฐ˜ ํŒŒ์‹ฑ ๊ตฌ์กฐ๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค.

W5500 ํ•˜๋“œ์›จ์–ด TCP/IP ์˜คํ”„๋กœ๋”ฉ ๊ธฐ๋ฐ˜ TCP Client ํ†ต์‹ 

  • MCU ๋ถ€ํ•˜๋ฅผ ๋‚ฎ์ถ”๊ณ , ์ž„๋ฒ ๋””๋“œ์—์„œ ๋น„๊ต์  ๋‹จ์ˆœํ•œ ์†Œ์ผ“ API๋กœ TCP ์—ฐ๊ฒฐ์„ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค.

๋ฉ€ํ‹ฐ ํƒœ์Šคํฌ(FreeRTOS) ํ˜•ํƒœ์˜ ๊ธฐ๋Šฅ ๋ถ„๋ฆฌ

  • ํ†ต์‹  ์ˆ˜์‹ , ๋””์Šคํ”Œ๋ ˆ์ด, ๋กœ์ปฌ ์˜จ๋„(DS18B20), RS-485 ์ˆ˜์ง‘์„ ํƒœ์Šคํฌ๋กœ ๋ถ„๋ฆฌํ•ด ํ™•์žฅ์— ์œ ๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

๋กœ์ปฌ ํ‘œ์‹œ(OLED) ๋ฐ ๋กœ์ปฌ ์˜จ๋„ ์„ผ์„œ(DS18B20) ํฌํ•จ

  • ๊ฒŒ์ดํŠธ์›จ์ด๊ฐ€ ๋‹จ์ˆœ ์ค‘๊ณ„๊ธฐ ์—ญํ• ์„ ๋„˜์–ด ํ˜„์žฅ ๋””๋ฒ„๊น…/์ƒํƒœ ํ™•์ธ์šฉ UI๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋Š” ํ˜•ํƒœ์ž…๋‹ˆ๋‹ค.

๊ณ ์ • IP/ํฌํŠธ ๊ธฐ๋ฐ˜์˜ ๊ฐ„๋‹จํ•œ ์„œ๋ฒ„ ์—ฐ๋™ ๋ผˆ๋Œ€

  • ์„œ๋ฒ„ IP/ํฌํŠธ๊ฐ€ ์ฝ”๋“œ์— ๊ณ ์ •๋œ ํ˜•ํƒœ๋กœ ์กด์žฌํ•ด, PoC(๊ฐœ๋… ๊ฒ€์ฆ) ๊ตฌํ˜„์ด ๋น ๋ฆ…๋‹ˆ๋‹ค.

๐Ÿ“Œ System Architecture

๊ตฌ์„ฑ ์š”์†Œ

  • MCU: STM32F103C8T6 
  • Ethernet: WIZnet W5500 (SPI ์—ฐ๊ฒฐ, CS/RST ํ•€ ์‚ฌ์šฉ)
  • Field I/F: RS-485(UART ๊ธฐ๋ฐ˜, Modbus RTU)
  • Local Sensor/UI: DS18B20(1-Wire), OLED

๋ฐ์ดํ„ฐ ํ๋ฆ„

  • RS-485 ์„ผ์„œ โ†’ (Modbus RTU ์‘๋‹ต) โ†’ STM32
  • STM32 โ†’ (W5500 ์†Œ์ผ“ send/recv) โ†’ TCP ์„œ๋ฒ„
  • TCP ์„œ๋ฒ„ โ†’ STM32๋กœ ๋ฐ์ดํ„ฐ ์†ก์‹  ์‹œ, ํ”„๋กœ์ ํŠธ๋Š” ๋ฌธ์ž์—ด ํŒŒ์‹ฑ(์˜ˆ: co2, temperature ํ˜•ํƒœ) ๊ตฌ์กฐ๋ฅผ ํฌํ•จ
  • STM32 โ†’ OLED์— ์˜จ๋„/์Šต๋„ ๋“ฑ ์ƒํƒœ ํ‘œ์‹œ

๐Ÿ“Œ Role and Application of the WIZnet's Chip

์‚ฌ์šฉ ์นฉ: WIZnet W5500 

๋„คํŠธ์›Œํฌ์—์„œ์˜ ์—ญํ• :

  • TCP Client ์†Œ์ผ“ ํ†ต์‹ (์„œ๋ฒ„ IP/Port๋กœ connect ํ›„ send/recv)

๐Ÿ“Œ Market & Application Value

์ ์šฉ ์‚ฐ์—…/์‹œ์žฅ

  • ์Šค๋งˆํŠธ ํŒฉํ† ๋ฆฌ/๋นŒ๋”ฉ ์ž๋™ํ™”: RS-485(์„ผ์„œ/์ธ๋ฒ„ํ„ฐ/๊ณ„์ธก๊ธฐ) โ†” Ethernet(์ƒ์œ„ ๊ด€์ œ) ๋ณ€ํ™˜ ์ˆ˜์š”๊ฐ€ ๊พธ์ค€ํ•ฉ๋‹ˆ๋‹ค.
  • ์˜จ์‹ค/ํ™˜๊ฒฝ ๋ชจ๋‹ˆํ„ฐ๋ง: CO2/์˜จ์Šต๋„/๊ณต๊ธฐ์งˆ ์„ผ์„œ๊ฐ€ RS-485(Modbus)๋กœ ์ œ๊ณต๋˜๋Š” ์ œํ’ˆ๊ตฐ์ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค(์„ผ์„œ ์‹œ์žฅ ์ผ๋ฐ˜ ์ •๋ณด).
  • ๋ ˆ๊ฑฐ์‹œ ์„ค๋น„ ๋ฐ์ดํ„ฐ ์ˆ˜์ง‘: โ€œ๊ธฐ์กด RS-485 ์žฅ๋น„๋ฅผ IP๋กœ ๋Œ์–ด์˜ฌ๋ฆฌ๋Š”โ€ ์ „ํ™˜ ์ˆ˜์š”

๐Ÿ“Œ WIZnet Strategic Value

Maker ์ƒํƒœ๊ณ„ ๊ด€์  ์˜๋ฏธ

  • โ€œW5500 + STM32 + RS-485โ€๋Š” ํ˜„์žฅ IoT์—์„œ ๋ฐ˜๋ณต ๋“ฑ์žฅํ•˜๋Š” ์กฐํ•ฉ์ด๋ผ, ๊ฒŒ์ดํŠธ์›จ์ด ๋ ˆํผ๋Ÿฐ์Šค ํ…œํ”Œ๋ฆฟ์œผ๋กœ ๊ฐ€์น˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
  • FreeRTOS ํƒœ์Šคํฌ ๋ถ„๋ฆฌ ๊ตฌ์กฐ๋Š” Maker ์‚ฌ์šฉ์ž์—๊ฒŒ โ€œํ™•์žฅ ๊ฐ€๋Šฅํ•œ ์ฝ”๋“œ ๋ผˆ๋Œ€โ€๋กœ ๊ต์œก ํšจ๊ณผ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.
  • W5500์„ ์“ฐ๋ฉด ๊ณ ์„ฑ๋Šฅ MCU ์—†์ด๋„ ์•ˆ์ •์ ์ธ ์ด๋”๋„ท ๊ธฐ๋ฐ˜ ํ•„๋“œ ๊ฒŒ์ดํŠธ์›จ์ด๋ฅผ ๋น ๋ฅด๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ“Œ Summary

์ด UCC๋Š” STM32F103 + W5500 ๊ธฐ๋ฐ˜ ์ด๋”๋„ท ๊ฒŒ์ดํŠธ์›จ์ด๋กœ, RS-485(Modbus) ์„ผ์„œ ๋ฐ์ดํ„ฐ๋ฅผ TCP ์„œ๋ฒ„์™€ ์—ฐ๋™ํ•˜๋Š” ํ˜„์žฅ IoT ๋ธŒ๋ฆฟ์ง€ ๊ตฌ์กฐ๋ฅผ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

๐Ÿ“Œ FAQ

Q1. STM32F103 + W5500 COโ‚‚ Gateway ํ”„๋กœ์ ํŠธ๋Š” ๋ฌด์—‡์ธ๊ฐ€์š”?

์ด ํ”„๋กœ์ ํŠธ๋Š” STM32F103C8T6 MCU์™€ WIZnet W5500์„ ์‚ฌ์šฉํ•˜์—ฌ RS-485(Modbus RTU) ์„ผ์„œ ๋ฐ์ดํ„ฐ๋ฅผ TCP ์„œ๋ฒ„๋กœ ์ „์†กํ•˜๋Š” ์ด๋”๋„ท ๊ฒŒ์ดํŠธ์›จ์ด ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.
ํ˜„์žฅ RS-485 ๊ธฐ๋ฐ˜ ์„ผ์„œ ๋ฐ์ดํ„ฐ๋ฅผ IP ๋„คํŠธ์›Œํฌ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” IoT ๋ธŒ๋ฆฟ์ง€ ๊ตฌ์กฐ๋ฅผ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค.

Q2. ์ด ๊ฒŒ์ดํŠธ์›จ์ด๋Š” ์–ด๋–ค ํ†ต์‹  ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉํ•˜๋‚˜์š”?

๊ฒŒ์ดํŠธ์›จ์ด๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๊ตฌ์กฐ๋กœ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค:

  • RS-485 (UART ๊ธฐ๋ฐ˜ Modbus RTU) โ†’ STM32 ์ˆ˜์ง‘
  • STM32 โ†’ W5500 (SPI ์—ฐ๊ฒฐ) โ†’ TCP Client ํ†ต์‹ 
  • TCP ์„œ๋ฒ„ โ†” STM32 (๋ฌธ์ž์—ด ๊ธฐ๋ฐ˜ ๋ฐ์ดํ„ฐ ์†ก์ˆ˜์‹ )
  • ๋กœ์ปฌ OLED์— ์ƒํƒœ ํ‘œ์‹œ

์ฆ‰, Field Bus(RS-485) โ†” Ethernet(TCP/IP) ๋ณ€ํ™˜ ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค.

Q3. WIZnet W5500์˜ ์—ญํ• ์€ ๋ฌด์—‡์ธ๊ฐ€์š”?

W5500์€ ํ•˜๋“œ์›จ์–ด TCP/IP ์˜คํ”„๋กœ๋”ฉ ๊ธฐ๋Šฅ์„ ๊ฐ€์ง„ SPI ๊ธฐ๋ฐ˜ Ethernet ์ปจํŠธ๋กค๋Ÿฌ์ž…๋‹ˆ๋‹ค.

์ด ํ”„๋กœ์ ํŠธ์—์„œ W5500์€:

  • TCP Client ์†Œ์ผ“ ์ƒ์„ฑ
  • ์„œ๋ฒ„ IP/Port๋กœ connect ์ˆ˜ํ–‰
  • send()/recv() ๊ธฐ๋ฐ˜ ๋ฐ์ดํ„ฐ ์†ก์ˆ˜์‹  ์ฒ˜๋ฆฌ
  • MCU ๋ถ€ํ•˜ ๊ฐ์†Œ

๋ฅผ ๋‹ด๋‹นํ•ฉ๋‹ˆ๋‹ค.

Q4. ์™œ W5500์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์œ ๋ฆฌํ•œ๊ฐ€์š”?

W5500์€ TCP/IP ์Šคํƒ์„ ํ•˜๋“œ์›จ์–ด๋กœ ์ฒ˜๋ฆฌํ•˜๋ฏ€๋กœ:

  • STM32F103๊ณผ ๊ฐ™์€ ์ค‘๊ธ‰ MCU์—์„œ๋„ ์•ˆ์ •์ ์ธ TCP ํ†ต์‹  ๊ฐ€๋Šฅ
  • ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ๋Ÿ‰ ๊ฐ์†Œ
  • ์†Œํ”„ํŠธ์›จ์–ด ๋„คํŠธ์›Œํฌ ์Šคํƒ ๊ตฌํ˜„ ๋ถ€๋‹ด ์ œ๊ฑฐ
  • ์‚ฐ์—…์šฉ ๋„คํŠธ์›Œํฌ ํ™˜๊ฒฝ์—์„œ ๋†’์€ ์•ˆ์ •์„ฑ ์ œ๊ณต

๋”ฐ๋ผ์„œ ์ €๋น„์šฉ MCU ๊ธฐ๋ฐ˜ ๊ฒŒ์ดํŠธ์›จ์ด ์„ค๊ณ„์— ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค.

Q5. RS-485(Modbus RTU)๋Š” ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌ๋˜๋‚˜์š”?

STM32๋Š” UART ๊ธฐ๋ฐ˜ RS-485 ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด Modbus RTU ์งˆ์˜/์‘๋‹ต์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

๊ตฌํ˜„ ํŠน์ง•:

  • CRC16 ๊ณ„์‚ฐ ํ›„ ํ”„๋ ˆ์ž„ ์ „์†ก
  • ์ˆ˜์‹  ๋ฐ์ดํ„ฐ ํŒŒ์‹ฑ ๊ตฌ์กฐ ํฌํ•จ
  • COโ‚‚, ์˜จ๋„ ๋“ฑ ์„ผ์„œ ๊ฐ’ ์ถ”์ถœ

์ด๋ฅผ ํ†ตํ•ด ํ•„๋“œ ์„ผ์„œ ๋ฐ์ดํ„ฐ๋ฅผ ๋””์ง€ํ„ธ ๋„คํŠธ์›Œํฌ๋กœ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค.


๐Ÿ“Œ Overview

This is an example of a โ€œfield sensor โ†” networkโ€ gateway that links RS-485 (Modbus RTU) sensor data to Ethernet (TCP) using a combination of STM32F103 + WIZnet W5500. It is confirmed from the MCU configuration file that the STM32F103C8T6 series is used.

๐Ÿ“Œ Features

RS-485 (Modbus RTU) query/response-based sensor data collection

  • Includes a structure for transmitting frames after CRC16 calculation and parsing based on received data.

TCP client communication based on W5500 hardware TCP/IP offloading

  • Reduces MCU load and enables TCP connection setup using a relatively simple socket API in embedded systems.

Multi-task structure (FreeRTOS-based functional separation)

  • Separates communication reception, display, local temperature (DS18B20), and RS-485 collection into individual tasks, making it advantageous for scalability.

Includes local display (OLED) and local temperature sensor (DS18B20)

  • Allows the gateway to go beyond a simple relay and provide a UI for on-site debugging and status monitoring.

Basic server integration structure based on fixed IP/port

  • Server IP and port are hardcoded in the firmware, enabling rapid PoC (proof-of-concept) implementation.

๐Ÿ“Œ System Architecture

Components

  • MCU: STM32F103C8T6
  • Ethernet: WIZnet W5500 (SPI connection, using CS/RST pins)
  • Field I/F: RS-485 (UART-based, Modbus RTU)
  • Local Sensor/UI: DS18B20 (1-Wire), OLED

Data Flow

  • RS-485 sensor โ†’ (Modbus RTU response) โ†’ STM32
  • STM32 โ†’ (W5500 socket send/recv) โ†’ TCP server
  • When the TCP server sends data to STM32, the project includes a string parsing structure (e.g., in the form of co2, temperature)
  • STM32 โ†’ Displays temperature/humidity and other status information on the OLED

๐Ÿ“Œ Role and Application of the WIZnet's Chip

Chip used: WIZnet W5500

Role in the network:

  • TCP client socket communication (connect to server IP/port, then perform send/recv)

๐Ÿ“Œ Market & Application Value

Applicable Industries/Markets

  • Smart factory/building automation: There is steady demand for converting RS-485 (sensors/inverters/meters) โ†” Ethernet (upper-level control/monitoring systems).
  • Greenhouse/environmental monitoring: There are product lines where CO2, temperature/humidity, and air quality sensors are provided via RS-485 (Modbus) (general information about the sensor market).
  • Legacy equipment data acquisition: Demand for transitioning โ€œexisting RS-485 devices to IP-based networks.โ€

๐Ÿ“Œ WIZnet Strategic Value

Significance from the Maker ecosystem perspective

  • โ€œW5500 + STM32 + RS-485โ€ is a frequently recurring combination in field IoT, giving it value as a gateway reference template.
  • The FreeRTOS task separation structure provides educational value to Maker users as a โ€œscalable code framework.โ€
  • By using the W5500, it is possible to quickly build a stable Ethernet-based field gateway without requiring a high-performance MCU.

๐Ÿ“Œ Summary

This UCC presents a field IoT bridge architecture based on an STM32F103 + W5500 Ethernet gateway, linking RS-485 (Modbus) sensor data with a TCP server.

๐Ÿ“Œ FAQ

Q1. What is the STM32F103 + W5500 COโ‚‚ Gateway project?

This project is an Ethernet gateway example that uses the STM32F103C8T6 MCU and the WIZnet W5500 to transmit RS-485 (Modbus RTU) sensor data to a TCP server.
It implements an IoT bridge architecture that converts field RS-485-based sensor data into an IP network.

Q2. What communication architecture does this gateway use?

The gateway operates with the following structure:

  • RS-485 (UART-based Modbus RTU) โ†’ Data collected by STM32
  • STM32 โ†’ W5500 (SPI connection) โ†’ TCP client communication
  • TCP server โ†” STM32 (string-based data transmission and reception)
  • Local status displayed on OLED

In other words, it implements a Field Bus (RS-485) โ†” Ethernet (TCP/IP) conversion architecture.

Q3. What is the role of the WIZnet W5500?

The W5500 is an SPI-based Ethernet controller with hardware TCP/IP offloading capability.

In this project, the W5500 is responsible for:

Creating TCP client sockets

Connecting to the server IP/port

Handling data transmission and reception using send()/recv()

Reducing MCU load

Q4. Why is it advantageous to use the W5500?

Since the W5500 processes the TCP/IP stack in hardware:

  • Stable TCP communication is possible even with mid-range MCUs like the STM32F103
  • Reduced memory usage
  • Eliminates the burden of implementing a software network stack
  • Provides high stability in industrial network environments

Therefore, it is well suited for low-cost MCU-based gateway designs.

Q5. How is RS-485 (Modbus RTU) handled?

The STM32 performs Modbus RTU query/response communication through a UART-based RS-485 interface.

Implementation features:

  • Frame transmission after CRC16 calculation
  • Includes a structure for parsing received data
  • Extracts sensor values such as COโ‚‚ and temperature

Through this process, field sensor data is converted into a digital IP-based network format.

 

Comments

Similar projects you might like

Comments