Skip to content

natKit-IMU

ESP32-based IMU sensor device for the natKit BCI toolkit. This device collects inertial measurement data and streams it to the natKit backend via MQTT.

Lihan__

Published August 30, 2026

Original author: neuralbertatechOriginal source (new tab)

natKit-IMU

Project description

atKit-IMU โ€” A Sensor Network That Chose a Cable to Save the Airwaves

#ESP32S3 #W5500 #MACRAW #esp_eth #ESP-NOW #MQTT #IMU #BCI #ESP-IDF

๐Ÿ“š A BCI toolkit project by NeurAlbertaTech (NAT), a non-profit student research group at the University of Alberta A rare, genuinely verifiable repository โ€” the source comments record measured numbers and the wrong calls the team made


01 โ€” What is this project?

Background: BCI and motion artifacts

BCI (Brain-Computer Interface) is the technology of reading brain signals to control machines. The most common approach is EEG, which measures brainwaves through electrodes on the scalp โ€” and it comes with one chronic problem.

The brain signals EEG picks up are extraordinarily faint, on the order of microvolts (ยตV). But when a person turns their head, blinks, or clenches their jaw, the electrical signal that movement produces bleeds in at tens of times the amplitude of the brainwave itself. This is called a motion artifact. You are trying to look at a brain signal, and body movement paints over the whole screen.

The fix is to record separately when the movement happened. If you know the timing and magnitude of the motion, you can subtract that contamination afterward. The component that keeps that record is the IMU (Inertial Measurement Unit) โ€” an inertial sensor package containing an accelerometer, gyroscope, and magnetometer.

So this project is

So this project is

 

The hub (primary) runs on an Espressif ESP Thread Border Router board, with the W5500 sitting on the separately-sold Sub-Ethernet daughter board rather than the main board itself. Every other board is a plain off-the-shelf ESP32 or ESP32-C3 devkit.

natKit-IMU is the motion sensor arm of natKit, the BCI toolkit NeurAlbertaTech is building. IMU nodes are attached at multiple points on the body, and 100 samples per second stream out to an MQTT broker. The end goal is a labeled dataset for training activity-recognition models.

From that goal comes the one constraint that governs every design decision in this project.

Data from multiple sensors must align precisely on a single timeline.

To remove an artifact, "this instant in the EEG" and "this movement in the IMU" have to be the same instant. The same holds when labeling training data. If clocks between nodes drift apart by milliseconds, labels land on the wrong window and the entire dataset is contaminated.

Why multiple boards is hard

One sensor board is easy. Put WiFi on an ESP32, spin up a single MQTT client, done.

The original Arduino-based version worked exactly that way. Every sensor board associated to the access point on its own, ran its own MQTT client, and pulled its own time over NTP. There was no hub and no hierarchy.

As boards were added, that approach collapsed. The airwaves got crowded, batteries drained, and โ€” worst of all โ€” every board's clock ran on its own. Each pulled time from the internet independently, so errors accumulated differently on each one, which runs directly against the single-timeline requirement above.

So the team redesigned the firmware from the ground up. WiFi, MQTT, and NTP were stripped out of the sensor boards entirely, leaving them to transmit over ESP-NOW to a hub โ€” a role-separated hierarchy (pure ESP-IDF).

ESP-NOW โ€” Espressif's connectionless transport: it uses the WiFi radio but skips association, IP, and TCP entirely, sending frames straight to a peer's MAC address.

Now exactly one board reaches the internet and distributes time. And this is where the W5500 enters โ€” the old design had no place for Ethernet, but once a hub role existed, something had to carry its uplink.

Here is the head-to-head, same boards, same conditions, three hours.

 Old
(WiFi โ†’ MQTT)
New
(ESP-NOW โ†’ hub โ†’ MQTT)
Usable samples per board56โ€“80 /s98 /s
Inter-arrival jitter17 ms1.4 ms
Board-to-board clock agreement2.7โ€“5.5 ms0.1โ€“0.2 ms
Bandwidthbaselinehalf

Board-to-board clock error went from 5.5 ms to 0.2 ms. A human arm takes several hundred milliseconds to complete a motion. At 5 ms of skew you cannot tell whether the shoulder or the wrist moved first; at 0.2 ms that ordering becomes something you can actually reason about. This is not an "improvement" โ€” it is the line between usable and unusable.


02 โ€” Data flow

There are three roles. leaf only reads sensors and transmits wirelessly, primary is the hub that collects them and acts as timing master, and gateway appears only when needed to hand data off to the broker.

02 โ€” Data flow

Three uplink branches. The one that misleads people is #2. UART is not a destination โ€” it is a short bridge to the chip next door, and what actually reaches the broker is that chip's WiFi. So #1 and #2 both ultimately go out over the air, and only #3 is wired end to end.

PathBoards requiredResult
1. WiFi1ร— ESP32 devkit85% frame loss (โ†’ 03)
2. UART โ†’ WiFiESP32 devkit + C3 devkit, wired with 3 UART linesno loss, but one more chip
3. EthernetThread BR board + W5500 daughter boardno loss, and one chip

This choice is also fixed at build time and does not change once flashed. On the ESP32-S3, #3 is the default.

Behind the broker. The broker (mosquitto) only delivers; a bridge forwards to Kafka, which stores the stream as a time series. From there it forks four ways โ€” live signal monitoring, experiment session records such as calibration and task runs, labeling and model training, and export for external analysis.


03 โ€” Why the architecture looks like this: 85% frame loss

Looking at the flow alone, you might wonder why the roles were split three ways and the uplink three ways. The answer sits in a single measurement, recorded in the ethernet_net.hpp comments.

With the primary associated to WiFi, roughly 85% of ESP-NOW frames were lost. The MAC layer was even ACKing them โ€” the WiFi task above it, busy servicing association, threw them away. The leaves themselves were perfectly fine.

The MAC sending an ACK means the radio waves arrived correctly. This is not something you fix by adjusting an antenna or transmit power; it is something you fix by changing the structure.

Which is where the role separation seen in 02 came from.

03 โ€” Why the architecture looks like this: 85% frame loss

 

RoleWhat it doesNetworking
leafreads sensors and transmitsESP-NOW only
primarycollection hub + timing masterESP-NOW + uplink
gatewayreceives and forwards to brokerWiFi (only when needed)

Roles are not a runtime switch but a Kconfig build option. The leaf image contains no WiFi and no MQTT code at all. Since ESP-NOW does not go through LwIP, a leaf never even calls esp_netif_init(). As a bonus, only one board in the entire system holds WiFi credentials โ€” the one doing the uplink.


04 โ€” Why W5500? โญ

๐Ÿ”ท In the author's own words: "sidesteps the argument entirely"

The title of the comment block in main/ethernet_net.hpp is the answer โ€” "Why this exists, and why it is the better answer."

This epic assumed primary and gateway had to be two chips, because one radio cannot do ESP-NOW and WiFi association at the same time. Ethernet sidesteps that whole argument. The uplink is OFF THE RADIO. There is no association to inherit a channel from. One chip, no serial bridge, no contention.

The "off-radio uplink" that the UART approach barely achieves with two boards and three wires, the W5500 delivers with a single chip.

๐Ÿ”ท Two ways it fails silently โ€” and first-timers hit both

1. The W5500 has no MAC address of its own.

No eFuse, no OTP. Leave it unset and it comes up all zeros or at a vendor default, and two boards on the same network collide.

This project derives one from the S3's base MAC (ESP_MAC_ETH).

2. The GPIO ISR service must be installed before the driver.

Without it the driver logs "GPIO isr service is not installed" and the link never comes up. It does not fail loudly; it simply never reports a connection.

And losing default y if IDF_TARGET_ESP32S3 produces this โ€” "it boots with no uplink, and the uplink counters cheerfully report frames 'sent' over a UART nobody is reading. This cost two debugging cycles."

๐Ÿ”ท Verified evidence โœ…

The console prints WIRED UPLINK: link up, ip โ€ฆ, mqtt up, published โ€ฆ, with the primary publishing MQTT directly over Ethernet. The pin map is taken verbatim from Espressif's official example.


05 โ€” Key components

๐ŸŒ W5500 (MACRAW) โ€” The S3 has no built-in Ethernet MAC, so both MAC and PHY must come from outside. The W5500 is an integrated MAC+PHY solution behind SPI, which fits that requirement exactly.

๐Ÿ“ก ESP-NOW v2 โ€” A 4-byte envelope with a magic byte and a version byte. The reasoning is practical: on a shared channel, broadcasts from unrelated ESP-NOW devices also land in your receive callback.

๐ŸŽฏ BNO08x + CEVA sh2 โ€” Accel, gyro, mag, and rotation arrive as separate reports at different rates. So against a 100 Hz frame, acceleration is fresh nearly every time, orientation about 95% of the time, and magnetometer about 91%; each frame carries a has_data bit to mark which.

๐Ÿงญ Time synchronization โ€” A leaf has no NTP and no wall clock. The primary broadcasts two packets per second, and the leaf fits a rolling least-squares line over the most recent 32 pairs. The key detail is that the transmit timestamp is read inside the send callback, not before calling esp_now_send โ€” read it beforehand and you are measuring transmit-queue latency, which swings between 1.4 and 13.8 ms, an error three orders of magnitude larger than the quantity being estimated. And a leaf never rewrites its own timestamps; correction is left to the consumer so it can be undone or improved later.


06 โ€” Application scenarios

  • Motion capture ยท gait analysis โ€” With clock error down at the microsecond scale, the ordering of movement between joints becomes something you can discuss.
  • BCI motion artifact removal โ€” The project's original purpose (see 01).
  • Rehabilitation ยท sports form measurement โ€” Leaves carry no credentials, so field deployment stays simple.
  • Industrial vibration ยท multi-point measurement โ€” Factory WiFi is crowded and racks usually already have an Ethernet port. A W5500 uplink fits this environment particularly well.

07 โ€” Field notes: wireless links fail quietly

๐Ÿ”ป One channel separated everything from nothing

Measured with a leaf a few centimetres from the hub, changing only the channel.

ChannelRSSIDelivery
3โˆ’22 dBmall 10 frames/s
6โˆ’21 to โˆ’57 dBmerratic
9 / 11โˆ’61 / โˆ’83 dBmnothing delivered
1โˆ’82 dBmjammed by the board itself

Same board, same distance, same firmware โ€” and the result is all or nothing. Worse, this is a property of the location, not the firmware, so a hardcoded value that works in one room is wrong in the next, and the failure mode looks like "a bad radio," which drags diagnosis out.

The fix is clever. All 13 channels are surveyed at boot, and it costs nothing โ€” the primary cannot publish anything for roughly 33 seconds after reset anyway while NTP is unsynced, and that dead window is exactly enough to sweep them.

๐Ÿ”ป A healthy board was convicted twice

One board was written off as "physically damaged" and removed. Its neighbour was clean while this one showed 274 sequence gaps, which looked like reasonable grounds. Four days later it was plugged back in, worked normally, and posted the strongest RSSI of all four nodes at โˆ’36 dBm.

The author's conclusion is the striking part โ€” "the original diagnosis was not so much wrong as unsafe." The pattern that convicted it (one of two adjacent leaves degrading) went on appearing between two known-good boards, with nothing changed, alternating on a 10โ€“30 minute cycle.

The other case was simply unplugged. The hub had just kept publishing a registry entry for a leaf that was no longer there. One principle came out of it โ€” "the absence of a data topic is not evidence about a board until you have confirmed it has power."

๐Ÿ”ป The plausible-looking metric is the dangerous one

The only metrics trusted are beacons_missed and leaf_send_failures. A healthy node missed 22 of 913 beacons with 4 send failures; the problem node missed 616 with 1800 failures.

What got discarded:

  • Clock-fit residual โ€” the healthy node and the dying node were equally saturated. Zero discriminating power.
  • Hardware receive timestamp โ€” a genuine hardware stamp, yet it scattered 20โ€“57 ms against esp_timer. Just reading esp_timer in the callback gives 25 ยตs.

๐Ÿ”ป Still open

Powering the Ethernet rig's S3 and the WiFi rig at the same time makes them adopt each other as neighbouring hubs on the shared channel. The current response is avoidance โ€” the S3 stays powered down while the WiFi rig runs. But opening a USB console on the S3 resets and re-enumerates it, so this board must be diagnosed from its published status topics rather than the console.

Also outstanding on that board: the S3's transmissions are heard fine by the leaves, but leafโ†’S3 unicasts mostly go unacknowledged. Transmitter healthy, receiver deaf โ€” the signature of an in-band interferer sitting right next to it. The suspect is the ESP32-H2 co-processor a few millimetres away, whose stock firmware transmits 802.15.4 in the same 2.4 GHz band. A Kconfig option that holds the H2 in reset was added to turn the hypothesis into an experiment. The Ethernet uplink was disabled during this investigation and the symptom persisted, which cleared the W5500 as a cause.


Conclusion

"What you have not measured, you do not know" โ€” this project proves that principle in its source comments rather than its README.

  • โœ… Role separation took clock error from 5.5 ms to 0.2 ms, jitter from 17 ms to 1.4 ms, and halved bandwidth
  • โœ… Measured 85% frame loss when one chip does both, and pinned the cause on the upper task rather than the MAC
  • โœ… Removed the contention structurally with a wired W5500 uplink โ€” one chip, no bridge
  • โœ… Documented the W5500's two traps (no MAC address, ISR service first) in code and comments
  • โœ… Surveys 13 channels at boot โ€” free, by using the 33-second NTP wait
  • โœ… Publicly corrected two hardware misdiagnoses, and separated trustworthy metrics from plausible ones by measurement
  • โœ… A complete pipeline running from sensor all the way to a labeled training dataset

Q&A

Q. Why is a W5500 needed to add Ethernet to an ESP32-S3? A. The S3 has no built-in Ethernet MAC (EMAC). On a classic ESP32 you attach a PHY to the internal EMAC, but the S3 needs both MAC and PHY from outside. The W5500 is an integrated MAC+PHY behind SPI, which fits exactly.

Q. What are the most common traps in W5500 initialization? A. โ‘  It has no MAC address of its own โ€” leave it unset and two boards on the same network collide. โ‘ก The GPIO ISR service must be installed before the driver. Both fail silently, with no error.

Q. Can the three uplinks be switched at runtime? A. No. They are Kconfig build options, decided at compile time, with the code excluded entirely via #ifdef. On the S3, Ethernet is the default.

Q. Why not just hardcode the channel? A. Channel 3 delivered all 10 frames/s while channels 9 and 11 delivered none at all. And because this is a property of the location, a value that is right in one room is wrong in the next.

Q. Where does the collected data ultimately go? A. The broker only delivers; a bridge forwards to Kafka for storage. From there it splits into live monitoring, experiment session records, labeling and model training, and export. The final product is a labeled training dataset.

 


[ํ•œ๊ธ€ ๋ฒ„์ „] natKit-IMU โ€” ์ „ํŒŒ๋ฅผ ์•„๋ผ๋ ค๊ณ  ๋žœ์„ ์„ ๊ณ ๋ฅธ ์„ผ์„œ ๋„คํŠธ์›Œํฌ

#ESP32S3 #W5500 #MACRAW #esp_eth #ESP-NOW #MQTT #IMU #BCI #ESP-IDF

๐Ÿ“š ์บ๋‚˜๋‹ค ์•จ๋ฒ„ํƒ€ ๋Œ€ํ•™ ๊ธฐ๋ฐ˜ ๋น„์˜๋ฆฌ ์—ฐ๊ตฌ๋‹จ์ฒด NeurAlbertaTech(NAT)์˜ BCI ํˆดํ‚ท ํ”„๋กœ์ ํŠธ ์†Œ์Šค ์ฃผ์„์— ์‹ค์ธก ์ˆ˜์น˜์™€ ํ‹€๋ฆฐ ํŒ๋‹จ๊นŒ์ง€ ๋‚จ๊ฒจ๋‘”, ๋ณด๊ธฐ ๋“œ๋ฌผ๊ฒŒ ๊ฒ€์ฆ ๊ฐ€๋Šฅํ•œ ์ €์žฅ์†Œ


01 โ€” ๋ฌด์—‡์„ ๋งŒ๋“ค์—ˆ๋‚˜

๋ฐฐ๊ฒฝ: BCI์™€ ๋ชจ์…˜ ์•„ํ‹ฐํŒฉํŠธ

BCI(Brain-Computer Interface) ๋Š” ๋‡Œ ์‹ ํ˜ธ๋ฅผ ์ฝ์–ด ๊ธฐ๊ณ„๋ฅผ ์ œ์–ดํ•˜๋Š” ๊ธฐ์ˆ ์ž…๋‹ˆ๋‹ค. ๋‘ํ”ผ์— ์ „๊ทน์„ ๋ถ™์—ฌ ๋‡ŒํŒŒ๋ฅผ ์ธก์ •ํ•˜๋Š” EEG๊ฐ€ ๊ฐ€์žฅ ํ”ํ•œ ๋ฐฉ์‹์ธ๋ฐ, ์—ฌ๊ธฐ์—” ๊ณ ์งˆ์ ์ธ ๋ฌธ์ œ๊ฐ€ ํ•˜๋‚˜ ์žˆ์Šต๋‹ˆ๋‹ค.

EEG๊ฐ€ ์žก์•„๋‚ด๋Š” ๋‡Œ ์‹ ํ˜ธ๋Š” ๋งˆ์ดํฌ๋กœ๋ณผํŠธ(ยตV) ๋‹จ์œ„๋กœ ๊ทน๋„๋กœ ๋ฏธ์•ฝํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ์‚ฌ๋žŒ์ด ๊ณ ๊ฐœ๋ฅผ ๋Œ๋ฆฌ๊ฑฐ๋‚˜ ๋ˆˆ์„ ๊นœ๋นก์ด๊ฑฐ๋‚˜ ํ„ฑ์— ํž˜์„ ์ฃผ๋ฉด, ๊ทธ ์›€์ง์ž„์ด ๋งŒ๋“œ๋Š” ์ „๊ธฐ ์‹ ํ˜ธ๊ฐ€ ๋‡ŒํŒŒ๋ณด๋‹ค ์ˆ˜์‹ญ ๋ฐฐ ํฌ๊ฒŒ ์„ž์—ฌ ๋“ค์–ด์˜ต๋‹ˆ๋‹ค. ์ด๊ฑธ ๋ชจ์…˜ ์•„ํ‹ฐํŒฉํŠธ(motion artifact) ๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๋‡Œ ์‹ ํ˜ธ๋ฅผ ๋ณด๋ ค๋Š”๋ฐ ๋ชธ ์›€์ง์ž„์ด ํ™”๋ฉด์„ ๋ฎ์–ด๋ฒ„๋ฆฌ๋Š” ์…ˆ์ž…๋‹ˆ๋‹ค.

ํ•ด๊ฒฐ์ฑ…์€ "์–ธ์ œ ์›€์ง์˜€๋Š”์ง€๋ฅผ ๋”ฐ๋กœ ๊ธฐ๋กํ•ด๋‘๋Š” ๊ฒƒ" ์ž…๋‹ˆ๋‹ค. ์›€์ง์ž„์˜ ์‹œ๊ฐ๊ณผ ํฌ๊ธฐ๋ฅผ ์•Œ๋ฉด, ์‚ฌํ›„์— ๊ทธ ๊ตฌ๊ฐ„์˜ ์˜ค์—ผ์„ ๋ถ„๋ฆฌํ•ด๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ ๊ธฐ๋ก์„ ๋‹ด๋‹นํ•˜๋Š” ๊ฒŒ IMU(Inertial Measurement Unit) โ€” ๊ฐ€์†๋„๊ณ„ยท์ž์ด๋กœ์Šค์ฝ”ํ”„ยท์ง€์ž๊ธฐ๊ณ„๊ฐ€ ๋“  ๊ด€์„ฑ์ธก์ • ์„ผ์„œ์ž…๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ์ด ํ”„๋กœ์ ํŠธ๋Š”

natKit-IMU๋Š” NeurAlbertaTech๊ฐ€ ๋งŒ๋“œ๋Š” BCI ํˆดํ‚ท natKit์˜ ๋ชจ์…˜ ์„ผ์„œ ํŒŒํŠธ์ž…๋‹ˆ๋‹ค. ๋ชธ ์—ฌ๋Ÿฌ ๊ณณ์— IMU ๋…ธ๋“œ๋ฅผ ๋ถ™์ด๊ณ  ์ดˆ๋‹น 100์ƒ˜ํ”Œ์„ MQTT ๋ธŒ๋กœ์ปค๋กœ ํ˜๋ ค๋ณด๋ƒ…๋‹ˆ๋‹ค. ์ตœ์ข… ๋ชฉ์ ์€ ๋™์ž‘ ์ธ์‹ ๋ชจ๋ธ ํ•™์Šต์šฉ ๋ผ๋ฒจ๋ง ๋ฐ์ดํ„ฐ์…‹์ž…๋‹ˆ๋‹ค.

์—ฌ๊ธฐ์„œ ์ด ํ”„๋กœ์ ํŠธ์˜ ๋ชจ๋“  ์„ค๊ณ„ ํŒ๋‹จ์„ ์ง€๋ฐฐํ•˜๋Š” ์ œ์•ฝ์ด ํ•˜๋‚˜ ๋‚˜์˜ต๋‹ˆ๋‹ค.

์—ฌ๋Ÿฌ ์„ผ์„œ์˜ ๋ฐ์ดํ„ฐ๊ฐ€ ํ•˜๋‚˜์˜ ํƒ€์ž„๋ผ์ธ ์œ„์— ์ •ํ™•ํžˆ ์ •๋ ฌ๋ผ์•ผ ํ•œ๋‹ค.

์•„ํ‹ฐํŒฉํŠธ๋ฅผ ์ œ๊ฑฐํ•˜๋ ค๋ฉด "EEG์˜ ์ด ์‹œ์ "๊ณผ "IMU์˜ ์ด ์›€์ง์ž„"์ด ๊ฐ™์€ ์ˆœ๊ฐ„์ด์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ•™์Šต ๋ฐ์ดํ„ฐ์— ๋ผ๋ฒจ์„ ๋ถ™์ผ ๋•Œ๋„ ๋งˆ์ฐฌ๊ฐ€์ง€์ž…๋‹ˆ๋‹ค. ๋…ธ๋“œ ๊ฐ„ ์‹œ๊ฐ์ด ๋ฐ€๋ฆฌ์ดˆ ๋‹จ์œ„๋กœ ์–ด๊ธ‹๋‚˜๋ฉด ๋ผ๋ฒจ์ด ์—‰๋šฑํ•œ ๊ตฌ๊ฐ„์— ๋ถ™๊ณ , ๋ฐ์ดํ„ฐ์…‹ ์ „์ฒด๊ฐ€ ์˜ค์—ผ๋ฉ๋‹ˆ๋‹ค.

์™œ ์—ฌ๋Ÿฌ ๋…ธ๋“œ๊ฐ€ ์–ด๋ ค์šด๊ฐ€

์„ผ์„œ ๋ณด๋“œ๊ฐ€ ํ•˜๋‚˜๋ฉด ์‰ฝ์Šต๋‹ˆ๋‹ค. ESP32์— WiFi ๋ถ™์ด๊ณ  MQTT ํด๋ผ์ด์–ธํŠธ ํ•˜๋‚˜ ๋„์šฐ๋ฉด ๋์ž…๋‹ˆ๋‹ค.

์ดˆ๊ธฐ ๋ฒ„์ „(Arduino ๊ธฐ๋ฐ˜)์ด ์‹ค์ œ๋กœ ๊ทธ ๋ฐฉ์‹์ด์—ˆ์Šต๋‹ˆ๋‹ค. ์„ผ์„œ ๋ณด๋“œ๊ฐ€ ์ €๋งˆ๋‹ค ๊ณต์œ ๊ธฐ์— ์ ‘์†ํ•ด ๊ฐ์ž MQTT ํด๋ผ์ด์–ธํŠธ๋ฅผ ๋„์šฐ๊ณ , ๊ฐ์ž NTP๋กœ ์‹œ๊ฐ„์„ ๋ฐ›์•„์™”์Šต๋‹ˆ๋‹ค. ํ—ˆ๋ธŒ๋„, ๊ณ„์ธต๋„ ์—†์—ˆ์Šต๋‹ˆ๋‹ค.

๋ณด๋“œ๊ฐ€ ๋Š˜์–ด๋‚˜์ž ์ด ๋ฐฉ์‹์ด ๋ฌด๋„ˆ์กŒ์Šต๋‹ˆ๋‹ค. ์ „ํŒŒ๋Š” ๋ถ๋น„๊ณ , ๋ฐฐํ„ฐ๋ฆฌ๋Š” ๋…น๊ณ , ๋ฌด์—‡๋ณด๋‹ค ๋ณด๋“œ๋งˆ๋‹ค ์‹œ๊ณ„๊ฐ€ ๋”ฐ๋กœ ๋†‰๋‹ˆ๋‹ค. ๊ฐ์ž ์ธํ„ฐ๋„ท์—์„œ ์‹œ๊ฐ„์„ ๋ฐ›์•„์˜ค๋‹ˆ ์˜ค์ฐจ๊ฐ€ ์ œ๊ฐ๊ฐ ์Œ“์ด๋Š”๋ฐ, ์ด๊ฑด ์•ž์„œ ๋งํ•œ "ํ•˜๋‚˜์˜ ํƒ€์ž„๋ผ์ธ" ์š”๊ตฌ์™€ ์ •๋ฉด์œผ๋กœ ์ถฉ๋Œํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ํŒ€์€ ํŽŒ์›จ์–ด๋ฅผ ํ†ต์งธ๋กœ ๋‹ค์‹œ ์„ค๊ณ„ํ–ˆ์Šต๋‹ˆ๋‹ค. ์„ผ์„œ ๋ณด๋“œ์—์„œ WiFi์™€ MQTT์™€ NTP๋ฅผ ์ „๋ถ€ ๊ฑท์–ด๋‚ด๊ณ , ESP-NOW๋กœ ํ—ˆ๋ธŒ์—๋งŒ ์˜๋„๋ก ์—ญํ• ์„ ๋‚˜๋ˆˆ ๊ณ„์ธต ๊ตฌ์กฐ(์ˆœ์ • ESP-IDF)๋กœ ๊ฐˆ์•„์—Ž์—ˆ์Šต๋‹ˆ๋‹ค.

ESP-NOW โ€” WiFi ๋ผ๋””์˜ค๋ฅผ ์“ฐ๋˜ ์ ‘์†ยทIPยทTCP ์ ˆ์ฐจ๋ฅผ ๋ชจ๋‘ ๊ฑด๋„ˆ๋›ฐ๊ณ , ์ƒ๋Œ€ MAC ์ฃผ์†Œ๋งŒ์œผ๋กœ ํ”„๋ ˆ์ž„์„ ๋ฐ”๋กœ ์˜๋Š” Espressif์˜ ์—ฐ๊ฒฐ ์—†๋Š” ํ†ต์‹  ๋ฐฉ์‹.

์ด์ œ ์ธํ„ฐ๋„ท์— ์ ‘์†ํ•˜๊ณ  ์‹œ๊ฐ„์„ ๋ฐฐํฌํ•˜๋Š” ๊ฑด ํ—ˆ๋ธŒ ํ•˜๋‚˜๋ฟ์ž…๋‹ˆ๋‹ค. ๊ฐ™์€ ๋ณด๋“œยท๊ฐ™์€ ์กฐ๊ฑด 3์‹œ๊ฐ„ ๋น„๊ต ๊ฒฐ๊ณผ์ž…๋‹ˆ๋‹ค.

 ๊ธฐ์กด
(WiFi โ†’ MQTT๋ธŒ๋กœ์ปค)
์‹ ๊ทœ
(ESP-NOW โ†’ ํ—ˆ๋ธŒ โ†’ MQTT๋ธŒ๋กœ์ปค)
๋ณด๋“œ๋‹น ์œ ํšจ ์ƒ˜ํ”Œ56โ€“80 /์ดˆ98 /์ดˆ
๋„์ฐฉ ๊ฐ„๊ฒฉ ์ง€ํ„ฐ17 ms1.4 ms
๋ณด๋“œ ๊ฐ„ ์‹œ๊ฐ ์ผ์น˜๋„2.7โ€“5.5 ms0.1โ€“0.2 ms
๋Œ€์—ญํญ๊ธฐ์ค€์ ˆ๋ฐ˜

๋ณด๋“œ ๊ฐ„ ์‹œ๊ฐ ์˜ค์ฐจ 5.5ms โ†’ 0.2ms. ์‚ฌ๋žŒ์˜ ํŒ” ํ•˜๋‚˜๊ฐ€ ์›€์ง์ด๋Š” ๋ฐ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„์ด ์ˆ˜๋ฐฑ ๋ฐ€๋ฆฌ์ดˆ์ž…๋‹ˆ๋‹ค. 5ms๊ฐ€ ์–ด๊ธ‹๋‚˜๋ฉด ์–ด๊นจ์™€ ์†๋ชฉ ์ค‘ ๋ญ๊ฐ€ ๋จผ์ € ์›€์ง์˜€๋Š”์ง€ ์•Œ ์ˆ˜ ์—†์ง€๋งŒ, 0.2ms๋ฉด ๊ทธ ์ˆœ์„œ๋ฅผ ๋…ผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๊ฑด "๊ฐœ์„ "์ด ์•„๋‹ˆ๋ผ ์“ธ ์ˆ˜ ์žˆ๋А๋ƒ ์—†๋А๋ƒ์˜ ๊ฒฝ๊ณ„์ž…๋‹ˆ๋‹ค.


02 โ€” ๋ฐ์ดํ„ฐ ํ๋ฆ„

์—ญํ• ์ด ์…‹์œผ๋กœ ๋‚˜๋‰ฉ๋‹ˆ๋‹ค. leaf๋Š” ์„ผ์„œ๋งŒ ์ฝ์–ด ๋ฌด์„ ์œผ๋กœ ์˜๊ณ , primary๋Š” ๊ทธ๊ฑธ ๋ชจ์œผ๋Š” ํ—ˆ๋ธŒ์ด์ž ํƒ€์ด๋ฐ ๋งˆ์Šคํ„ฐ์ด๋ฉฐ, gateway๋Š” ํ•„์š”ํ•  ๋•Œ๋งŒ ๋“ฑ์žฅํ•ด ๋ธŒ๋กœ์ปค๋กœ ๋„˜๊น๋‹ˆ๋‹ค.02 โ€” ๋ฐ์ดํ„ฐ ํ๋ฆ„

 

์—…๋งํฌ ์„ธ ๊ฐˆ๋ž˜. ์—ฌ๊ธฐ์„œ ์˜คํ•ดํ•˜๊ธฐ ์‰ฌ์šด ๊ฒŒ 2๋ฒˆ์ž…๋‹ˆ๋‹ค. UART๋Š” ์ข…์ฐฉ์ง€๊ฐ€ ์•„๋‹ˆ๋ผ ์˜† ์นฉ๊นŒ์ง€ ๊ฐ€๋Š” ์งง์€ ๋‹ค๋ฆฌ์ด๊ณ , ๋ธŒ๋กœ์ปค๋กœ ๋‚˜๊ฐ€๋Š” ๊ฑด ๊ฒฐ๊ตญ ๊ทธ ์นฉ์˜ WiFi์ž…๋‹ˆ๋‹ค. ์ฆ‰ 1๋ฒˆ๊ณผ 2๋ฒˆ์€ ๊ฒฐ๊ตญ ๋ฌด์„ ์œผ๋กœ ๋‚˜๊ฐ€๊ณ , 3๋ฒˆ๋งŒ ์ฒ˜์Œ๋ถ€ํ„ฐ ๋๊นŒ์ง€ ์œ ์„ ์ž…๋‹ˆ๋‹ค.

02 โ€” ๋ฐ์ดํ„ฐ ํ๋ฆ„
๊ฒฝ๋กœํ•„์š”ํ•œ ๋ณด๋“œ๊ฒฐ๊ณผ
1. WiFiESP32 devkit 1์žฅํ”„๋ ˆ์ž„ 85% ์†์‹ค (โ†’ 03)
2. UART โ†’ WiFiESP32 devkit + C3 devkit, UART 3์„  ๋ฐฐ์„ ์†์‹ค ์—†์Œ, ์นฉ์ด ํ•˜๋‚˜ ๋”
3. EthernetThread BR ๋ณด๋“œ + W5500 ๋„ํ„ฐ๋ณด๋“œ์†์‹ค ์—†์Œ, ์นฉ๋„ ํ•˜๋‚˜

 

์ด ์„ ํƒ๋„ ๋นŒ๋“œ ํƒ€์ž„์— ๊ฒฐ์ •๋˜๊ณ  ๋ณด๋“œ์— ์˜ฌ๋ฆฐ ๋’ค์—” ์•ˆ ๋ฐ”๋€๋‹ˆ๋‹ค. ESP32-S3์—์„œ๋Š” 3๋ฒˆ์ด ๊ธฐ๋ณธ๊ฐ’์ž…๋‹ˆ๋‹ค.

๋ธŒ๋กœ์ปค ๋’ค. ๋ธŒ๋กœ์ปค(mosquitto)๋Š” ๋ฐฐ๋‹ฌ๋งŒ ํ•˜๊ณ , ๋ธŒ๋ฆฌ์ง€๊ฐ€ Kafka๋กœ ๋„˜๊ฒจ ์‹œ๊ณ„์—ด๋กœ ์Œ“์Šต๋‹ˆ๋‹ค. ๊ฑฐ๊ธฐ์„œ ๋„ค ๊ฐˆ๋ž˜๋กœ ๊ฐˆ๋ฆฝ๋‹ˆ๋‹ค โ€” ์‹ค์‹œ๊ฐ„ ์‹ ํ˜ธ ๊ด€์ธก, ์บ˜๋ฆฌ๋ธŒ๋ ˆ์ด์…˜ยท๊ณผ์ œ ์‹คํ–‰ ๊ฐ™์€ ์‹คํ—˜ ์„ธ์…˜ ๊ธฐ๋ก, ๋ผ๋ฒจ๋ง๊ณผ ๋ชจ๋ธ ํ•™์Šต, ์™ธ๋ถ€ ๋ถ„์„์šฉ ๋‚ด๋ณด๋‚ด๊ธฐ.


03 โ€” ์™œ ์ด๋Ÿฐ ๊ตฌ์กฐ๊ฐ€ ๋๋‚˜: ํ”„๋ ˆ์ž„ 85% ์†์‹ค

ํ๋ฆ„๋งŒ ๋ณด๋ฉด "์™œ ๊ตณ์ด ์—ญํ• ์„ ์…‹์œผ๋กœ ์ชผ๊ฐœ๊ณ  ์—…๋งํฌ๋ฅผ ์„ธ ๊ฐˆ๋ž˜๋กœ ๋’€๋‚˜" ์‹ถ์Šต๋‹ˆ๋‹ค. ๋‹ต์€ ์ด ์ธก์ •์น˜ ํ•˜๋‚˜์— ์žˆ์Šต๋‹ˆ๋‹ค. ethernet_net.hpp ์ฃผ์„์ž…๋‹ˆ๋‹ค.

primary๊ฐ€ WiFi์— associate๋œ ์ƒํƒœ์—์„œ ESP-NOW ํ”„๋ ˆ์ž„์˜ ์•ฝ 85%๊ฐ€ ์œ ์‹ค๋๋‹ค. MAC ๊ณ„์ธต์—์„œ๋Š” ACK๊นŒ์ง€ ๋ฐ›์•˜๋Š”๋ฐ, association์„ ์ฒ˜๋ฆฌํ•˜๋А๋ผ ๋ฐ”์œ WiFi ํƒœ์Šคํฌ๊ฐ€ ๊ทธ ์œ„์—์„œ ๋ฒ„๋ ธ๋‹ค. ์ •์ž‘ leaf๋“ค์€ ์™„๋ฒฝํžˆ ์ •์ƒ์ด์—ˆ๋‹ค.

MAC์ด ACK๋ฅผ ๋ณด๋ƒˆ๋‹ค๋Š” ๊ฑด ์ „ํŒŒ๋Š” ์ œ๋Œ€๋กœ ๋„์ฐฉํ–ˆ๋‹ค๋Š” ๋œป์ž…๋‹ˆ๋‹ค. ์•ˆํ…Œ๋‚˜๋‚˜ ์ถœ๋ ฅ์„ ๋งŒ์ ธ์„œ ๋  ๋ฌธ์ œ๊ฐ€ ์•„๋‹ˆ๋ผ ๊ตฌ์กฐ๋ฅผ ๋ฐ”๊ฟ”์•ผ ํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ 02์—์„œ ๋ณธ ์—ญํ•  ๋ถ„๋ฆฌ๊ฐ€ ๋‚˜์™”์Šต๋‹ˆ๋‹ค.

์—ญํ• ํ•˜๋Š” ์ผ๋„คํŠธ์›Œํฌ
leaf์„ผ์„œ๋งŒ ์ฝ๊ณ  ์œ๋‹คESP-NOW only
primary์ˆ˜์ง‘ ํ—ˆ๋ธŒ + ํƒ€์ด๋ฐ ๋งˆ์Šคํ„ฐESP-NOW + ์—…๋งํฌ
gateway๋ฐ›์•„์„œ ๋ธŒ๋กœ์ปค๋กœWiFi (ํ•„์š”ํ•  ๋•Œ๋งŒ)

์—ญํ• ์€ ๋Ÿฐํƒ€์ž„ ์Šค์œ„์น˜๊ฐ€ ์•„๋‹ˆ๋ผ Kconfig ๋นŒ๋“œ ์˜ต์…˜์ž…๋‹ˆ๋‹ค. leaf ์ด๋ฏธ์ง€์—๋Š” WiFi๋„ MQTT๋„ ์ฝ”๋“œ ์ž์ฒด๊ฐ€ ์•ˆ ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค. ESP-NOW๋Š” LwIP๋ฅผ ์•ˆ ๊ฑฐ์น˜๋ฏ€๋กœ leaf๋Š” esp_netif_init()์กฐ์ฐจ ํ˜ธ์ถœํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋ค์œผ๋กœ WiFi ์ž๊ฒฉ์ฆ๋ช…์„ ๊ฐ€์ง„ ๋ณด๋“œ๊ฐ€ ์—…๋งํฌ ๋‹ด๋‹น ํ•˜๋‚˜๋ฟ์ด ๋ฉ๋‹ˆ๋‹ค.


04 โ€” ์™œ W5500์ธ๊ฐ€? โญ

๐Ÿ”ท ์ €์ž ๋ณธ์ธ์˜ ํ‘œํ˜„: "๋…ผ์Ÿ ์ž์ฒด๋ฅผ ์šฐํšŒํ•œ๋‹ค"

main/ethernet_net.hpp์˜ ์ฃผ์„ ์ œ๋ชฉ์ด ๊ทธ๋Œ€๋กœ ๋‹ต์ž…๋‹ˆ๋‹ค โ€” "Why this exists, and why it is the better answer."

์ด ์—ํ”ฝ์€ primary์™€ gateway๊ฐ€ ๋‘ ์นฉ์ด์–ด์•ผ ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ–ˆ๋‹ค. ํ•œ ๋ผ๋””์˜ค๊ฐ€ ESP-NOW์™€ WiFi association์„ ๋™์‹œ์— ๋ชป ํ•˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค. ์ด๋”๋„ท์€ ์ด ๋…ผ์Ÿ ์ „์ฒด๋ฅผ ์šฐํšŒํ•œ๋‹ค. ์—…๋งํฌ๊ฐ€ ๋ผ๋””์˜ค ๋ฐ–์— ์žˆ๋‹ค(OFF THE RADIO). ์ฑ„๋„์„ ๋ฌผ๋ ค๋ฐ›์„ association๋„ ์—†๋‹ค. ์นฉ ํ•˜๋‚˜, ์‹œ๋ฆฌ์–ผ ๋ธŒ๋ฆฟ์ง€ ์—†์Œ, ๊ฒฝํ•ฉ๋„ ์—†์Œ.

UART ๋ฐฉ์‹์ด ๋ณด๋“œ ๋‘ ์žฅ๊ณผ ์ „์„  ์„ธ ๊ฐ€๋‹ฅ์œผ๋กœ ๊ฒจ์šฐ ๋งŒ๋“ค์–ด๋‚ธ "๋ผ๋””์˜ค ๋ฐ– ์—…๋งํฌ"๋ฅผ, W5500์€ ์นฉ ํ•˜๋‚˜๋กœ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

๐Ÿ”ท ์กฐ์šฉํžˆ ์‹คํŒจํ•˜๋Š” ๋‘ ๊ฐ€์ง€ โ€” ์ฒ˜์Œ ์“ฐ๋Š” ์‚ฌ๋žŒ์ด ๊ทธ๋Œ€๋กœ ๋ฐŸ๋Š”๋‹ค

1. W5500์€ ์ž๊ธฐ MAC ์ฃผ์†Œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

eFuse๋„ OTP๋„ ์—†๋‹ค. ์„ค์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ์ „๋ถ€ 0์ด๊ฑฐ๋‚˜ ๋ฒค๋” ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์˜ฌ๋ผ์˜ค๊ณ , ๊ฐ™์€ ๋„คํŠธ์›Œํฌ์˜ ๋‘ ๋ณด๋“œ๊ฐ€ ์ถฉ๋Œํ•œ๋‹ค.

์ด ํ”„๋กœ์ ํŠธ๋Š” S3์˜ base MAC(ESP_MAC_ETH)์—์„œ ์œ ๋„ํ•ด ๋„ฃ์Šต๋‹ˆ๋‹ค.

2. GPIO ISR ์„œ๋น„์Šค๋ฅผ ๋“œ๋ผ์ด๋ฒ„๋ณด๋‹ค ๋จผ์ € ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์—†์œผ๋ฉด "GPIO isr service is not installed"๋ฅผ ์ฐ๊ณ  ๋งํฌ๊ฐ€ ์˜์›ํžˆ ์˜ฌ๋ผ์˜ค์ง€ ์•Š๋Š”๋‹ค. ์š”๋ž€ํ•˜๊ฒŒ ์‹คํŒจํ•˜์ง€ ์•Š๊ณ , ๊ทธ๋ƒฅ ์—ฐ๊ฒฐ์„ ์˜์˜ ๋ณด๊ณ ํ•˜์ง€ ์•Š๋Š”๋‹ค.

๊ทธ๋ฆฌ๊ณ  default y if IDF_TARGET_ESP32S3๋ฅผ ์žƒ์œผ๋ฉด ์ด๋ ‡๊ฒŒ ๋ฉ๋‹ˆ๋‹ค โ€” "์—…๋งํฌ ์—†์ด ๋ถ€ํŒ…๋˜๊ณ , ์—…๋งํฌ ์นด์šดํ„ฐ๋Š” ์•„๋ฌด๋„ ์•ˆ ์ฝ๋Š” UART๋กœ ํ”„๋ ˆ์ž„์„ '๋ณด๋ƒˆ๋‹ค'๊ณ  ํƒœ์—ฐํžˆ ๋ณด๊ณ ํ•œ๋‹ค. ์ด๊ฑธ๋กœ ๋””๋ฒ„๊น… ์‚ฌ์ดํด์„ ๋‘ ๋ฒˆ ๋‚ ๋ ธ๋‹ค."

๐Ÿ”ท ๊ฒ€์ฆ๋œ ์ฆ๊ฑฐ โœ…

๋กœ๊ทธ์— WIRED UPLINK: link up, ip โ€ฆ, mqtt up, published โ€ฆ๊ฐ€ ์ฐํžˆ๋ฉฐ primary๊ฐ€ ์ด๋”๋„ท์œผ๋กœ ์ง์ ‘ MQTT๋ฅผ ๋ฐœํ–‰ํ•ฉ๋‹ˆ๋‹ค. ํ•€๋งต์€ Espressif ๊ณต์‹ ์˜ˆ์ œ ๊ฐ’ ๊ทธ๋Œ€๋กœ์ž…๋‹ˆ๋‹ค.


05 โ€” ํ•ต์‹ฌ ๊ตฌ์„ฑ ์š”์†Œ

๐ŸŒ W5500 (MACRAW) โ€” S3์—๋Š” ๋‚ด์žฅ ์ด๋”๋„ท MAC์ด ์—†์–ด์„œ MAC๊ณผ PHY๋ฅผ ๋ชจ๋‘ ์™ธ๋ถ€์—์„œ ๊ฐ€์ ธ์™€์•ผ ํ•ฉ๋‹ˆ๋‹ค. W5500์€ SPI ๋„ˆ๋จธ์˜ MAC+PHY ํ†ตํ•ฉ ์†”๋ฃจ์…˜์ด๋ผ ์ด ์š”๊ตฌ์— ์ •ํ™•ํžˆ ๋งž์Šต๋‹ˆ๋‹ค.

๐Ÿ“ก ESP-NOW v2 โ€” 4๋ฐ”์ดํŠธ ๋ด‰ํˆฌ์— ๋งค์ง + ๋ฒ„์ „ ๋ฐ”์ดํŠธ. ์ด์œ ๊ฐ€ ์‹ค์šฉ์ ์ž…๋‹ˆ๋‹ค โ€” ๊ณต์œ  ์ฑ„๋„์—์„œ๋Š” ๋ฌด๊ด€ํ•œ ESP-NOW ๊ธฐ๊ธฐ์˜ ๋ธŒ๋กœ๋“œ์บ์ŠคํŠธ๋„ ์ˆ˜์‹  ์ฝœ๋ฐฑ์— ๋“ค์–ด์˜ค๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

๐ŸŽฏ BNO08x + CEVA sh2 โ€” accel/gyro/mag/rotation์„ ๊ฐ๊ฐ ๋‹ค๋ฅธ ์ฃผ๊ธฐ๋กœ ๋ƒ…๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ 100Hz ํ”„๋ ˆ์ž„ ๊ธฐ์ค€ ๊ฐ€์†๋„๋Š” ๊ฑฐ์˜ ๋งค๋ฒˆ, ์ž์„ธ๋Š” 95%, ์ง€์ž๊ธฐ๋Š” 91%๋งŒ ์ƒˆ ๊ฐ’์ด๊ณ , ํ”„๋ ˆ์ž„๋งˆ๋‹ค has_data ๋น„ํŠธ๋กœ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค.

๐Ÿงญ ํƒ€์ด๋ฐ ๋™๊ธฐํ™” โ€” leaf์—๋Š” NTP๋„ ๋ฒฝ์‹œ๊ณ„๋„ ์—†์Šต๋‹ˆ๋‹ค. primary๊ฐ€ ์ดˆ๋‹น ๋‘ ํŒจํ‚ท์„ ๋ฟŒ๋ฆฌ๊ณ  leaf๊ฐ€ ์ตœ๊ทผ 32์Œ์— ์ตœ์†Œ์ž์Šน ์ง์„ ์„ ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค. ํ•ต์‹ฌ์€ ์†ก์‹  ์‹œ๊ฐ์„ esp_now_send ํ˜ธ์ถœ ์ „์ด ์•„๋‹ˆ๋ผ ์†ก์‹  ์ฝœ๋ฐฑ ์•ˆ์—์„œ ์ฝ๋Š” ๊ฒƒ โ€” ํ˜ธ์ถœ ์ „์— ์ฝ์œผ๋ฉด 1.4~13.8ms๋กœ ์š”๋™์น˜๋Š” ์†ก์‹  ํ ๋Œ€๊ธฐ์‹œ๊ฐ„์„ ์žฌ๊ฒŒ ๋˜๋Š”๋ฐ, ์ถ”์ •ํ•˜๋ ค๋Š” ๊ฐ’๋ณด๋‹ค ์„ธ ์ž๋ฆฟ์ˆ˜ ํฐ ์˜ค์ฐจ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  leaf๋Š” ์ž๊ธฐ ํƒ€์ž„์Šคํƒฌํ”„๋ฅผ ๊ณ ์ณ ์“ฐ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋ณด์ •์„ ๋˜๋Œ๋ฆฌ๊ฑฐ๋‚˜ ๋‚˜์ค‘์— ๊ฐœ์„ ํ•  ์ˆ˜ ์žˆ๊ฒŒ ์†Œ๋น„์ž์—๊ฒŒ ๋งก๊น๋‹ˆ๋‹ค.


06 โ€” ์‘์šฉ ์‹œ๋‚˜๋ฆฌ์˜ค

  • ๋ชจ์…˜ ์บก์ฒ˜ ยท ๋ณดํ–‰ ๋ถ„์„ โ€” ์‹œ๊ฐ ์˜ค์ฐจ๊ฐ€ ๋งˆ์ดํฌ๋กœ์ดˆ ๋‹จ์œ„๋ผ ๊ด€์ ˆ ๊ฐ„ ์›€์ง์ž„์˜ ์„ ํ›„ ๊ด€๊ณ„๋ฅผ ๋…ผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • BCI ๋ชจ์…˜ ์•„ํ‹ฐํŒฉํŠธ ์ œ๊ฑฐ โ€” ์ด ํ”„๋กœ์ ํŠธ์˜ ๋ณธ๋ž˜ ๋ชฉ์ (01 ์ฐธ์กฐ).
  • ์žฌํ™œ ยท ์Šคํฌ์ธ  ์ž์„ธ ์ธก์ • โ€” leaf์— ์ž๊ฒฉ์ฆ๋ช…์ด ์—†์–ด ํ˜„์žฅ ๋ฐฐํฌ๊ฐ€ ๋‹จ์ˆœํ•ฉ๋‹ˆ๋‹ค.
  • ์‚ฐ์—… ์ง„๋™ ยท ๋‹ค์ง€์  ๊ณ„์ธก โ€” ๊ณต์žฅ WiFi๋Š” ๋ถ๋น„๊ณ  ๋ž™์—” ๋žœ ํฌํŠธ๊ฐ€ ์ด๋ฏธ ์žˆ์Šต๋‹ˆ๋‹ค. W5500 ์—…๋งํฌ๊ฐ€ ํŠนํžˆ ์ž˜ ๋งž๋Š” ํ™˜๊ฒฝ.

07 โ€” ํ•„๋“œ ๊ธฐ๋ก: ๋ฌด์„  ๋งํฌ๋Š” ์กฐ์šฉํžˆ ๋Š์–ด์ง„๋‹ค

๐Ÿ”ป ์ฑ„๋„ ํ•˜๋‚˜๊ฐ€ ์ „๋ถ€์™€ ์ „๋ฌด๋ฅผ ๊ฐˆ๋ž๋‹ค

ํ—ˆ๋ธŒ์—์„œ ๋ช‡ ์„ผํ‹ฐ ๋–จ์–ด์ง„ leaf๋ฅผ ์ฑ„๋„๋งŒ ๋ฐ”๊ฟ” ์ธก์ •ํ•œ ๊ฒฐ๊ณผ์ž…๋‹ˆ๋‹ค.

์ฑ„๋„RSSI์ „๋‹ฌ
3โˆ’22 dBm10 frames/s ์ „๋ถ€
6โˆ’21 ~ โˆ’57 dBm๋“ค์ญ‰๋‚ ์ญ‰
9 / 11โˆ’61 / โˆ’83 dBm์ „๋‹ฌ ์—†์Œ
1โˆ’82 dBm๋ณด๋“œ ์ž์‹ ์ด ๋ฐฉํ•ด

๊ฐ™์€ ๋ณด๋“œ, ๊ฐ™์€ ๊ฑฐ๋ฆฌ, ๊ฐ™์€ ํŽŒ์›จ์–ด์ธ๋ฐ ์ „๋ถ€ ์•„๋‹ˆ๋ฉด ์ „๋ฌด์ž…๋‹ˆ๋‹ค. ๊ฒŒ๋‹ค๊ฐ€ ์ด๊ฑด ํŽŒ์›จ์–ด๊ฐ€ ์•„๋‹ˆ๋ผ ์žฅ์†Œ์˜ ์†์„ฑ์ด๋ผ ํ•œ ๋ฐฉ์—์„œ ๋งž๋Š” ํ•˜๋“œ์ฝ”๋”ฉ ๊ฐ’์ด ์˜†๋ฐฉ์—์„œ ํ‹€๋ฆฌ๊ณ , ์‹คํŒจ ์–‘์ƒ์ด "๋‚˜์œ ๋ผ๋””์˜ค"์ฒ˜๋Ÿผ ๋ณด์—ฌ ์ง„๋‹จ์ด ์˜ค๋ž˜ ๊ฑธ๋ฆฝ๋‹ˆ๋‹ค.

ํ•ด๋ฒ•์ด ์˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ๋ถ€ํŒ… ์‹œ 13์ฑ„๋„์„ ์ „๋ถ€ ํ›‘๋Š”๋ฐ, ์ด๊ฒŒ ๊ณต์งœ์ž…๋‹ˆ๋‹ค โ€” primary๋Š” ๋ฆฌ์…‹ ํ›„ ์•ฝ 33์ดˆ๊ฐ„ NTP ๋ฏธ๋™๊ธฐ๋ผ ์–ด์ฐจํ”ผ ์•„๋ฌด๊ฒƒ๋„ ๋ฐœํ–‰ํ•˜์ง€ ๋ชปํ•˜๊ณ , ๊ทธ ์ฃฝ์€ ์‹œ๊ฐ„์ด ์ •ํ™•ํžˆ ์Šค์บ”์— ์ถฉ๋ถ„ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ”ป ๋ฉ€์ฉกํ•œ ๋ณด๋“œ๋ฅผ ๋‘ ๋ฒˆ ์œ ์ฃ„๋กœ ๋งŒ๋“ค์—ˆ๋‹ค

ํ•œ ๋ณด๋“œ๋Š” "๋ฌผ๋ฆฌ์  ํŒŒ์†"์œผ๋กœ ํŒ์ •๋ผ ์ œ๊ฑฐ๋์Šต๋‹ˆ๋‹ค. ์˜† ๋…ธ๋“œ๊ฐ€ ๊นจ๋—ํ•œ๋ฐ ์ด ๋ณด๋“œ๋งŒ ์‹œํ€€์Šค ๊ฐญ 274๊ฐœ์˜€์œผ๋‹ˆ ํ•ฉ๋ฆฌ์ ์œผ๋กœ ๋ณด์˜€์Šต๋‹ˆ๋‹ค. ๋‚˜ํ˜ ๋’ค ๋‹ค์‹œ ๊ฝ‚์œผ๋‹ˆ ์ •์ƒ ๋™์ž‘ํ–ˆ๊ณ  RSSI โˆ’36dBm์œผ๋กœ ๋„ค ๋…ธ๋“œ ์ค‘ ๊ฐ€์žฅ ๊ฐ•ํ–ˆ์Šต๋‹ˆ๋‹ค.

์ €์ž์˜ ๊ฒฐ๋ก ์ด ์ธ์ƒ์ ์ž…๋‹ˆ๋‹ค โ€” "์›๋ž˜ ์ง„๋‹จ์ด ํ‹€๋ ธ๋‹ค๊ธฐ๋ณด๋‹ค, ์•ˆ์ „ํ•˜์ง€ ์•Š์€ ์ง„๋‹จ์ด์—ˆ๋‹ค." ์œ ์ฃ„์˜ ๊ทผ๊ฑฐ์˜€๋˜ ํŒจํ„ด(๋‚˜๋ž€ํ•œ ๋‘ leaf ์ค‘ ํ•˜๋‚˜๋งŒ ๋‚˜๋น ์ง)์ด, ์ดํ›„ ๋ฉ€์ฉกํ•œ ๋‘ ๋ณด๋“œ ์‚ฌ์ด์—์„œ ์•„๋ฌด๊ฒƒ๋„ ์•ˆ ๊ฑด๋“œ๋ฆฐ ์ฑ„ 10~30๋ถ„ ๊ฐ„๊ฒฉ์œผ๋กœ ๊ณ„์† ๋ฒˆ๊ฐˆ์•„ ๋‚˜ํƒ€๋‚ฌ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

๋˜ ํ•˜๋‚˜๋Š” ๊ทธ๋ƒฅ ์ „์›์ด ๋ฝ‘ํ˜€ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ํ—ˆ๋ธŒ๊ฐ€ ์‚ฌ๋ผ์ง„ leaf์˜ ๋ ˆ์ง€์ŠคํŠธ๋ฆฌ ํ•ญ๋ชฉ์„ ๊ณ„์† ๋ฐœํ–‰ํ•˜๊ณ  ์žˆ์—ˆ์„ ๋ฟ์ž…๋‹ˆ๋‹ค. ์›์น™ ํ•˜๋‚˜๊ฐ€ ๋‚จ์•˜์Šต๋‹ˆ๋‹ค โ€” "๋ฐ์ดํ„ฐ ํ† ํ”ฝ์ด ์—†๋‹ค๋Š” ์‚ฌ์‹ค์€, ์ „์›์„ ํ™•์ธํ•˜๊ธฐ ์ „๊นŒ์ง€ ์ฆ๊ฑฐ๊ฐ€ ์•„๋‹ˆ๋‹ค."

๐Ÿ”ป ๊ทธ๋Ÿด๋“ฏํ•œ ์ง€ํ‘œ๊ฐ€ ๊ฐ€์žฅ ์œ„ํ—˜ํ•˜๋‹ค

์‹ ๋ขฐํ•˜๋Š” ์ง€ํ‘œ๋Š” beacons_missed์™€ leaf_send_failures ๋‘˜๋ฟ์ž…๋‹ˆ๋‹ค. ์ •์ƒ ๋…ธ๋“œ๋Š” ๋น„์ฝ˜ 913๊ฐœ ์ค‘ 22๊ฐœ ๋ˆ„๋ฝยท์‹คํŒจ 4ํšŒ, ๋ฌธ์ œ ๋…ธ๋“œ๋Š” 616๊ฐœ ๋ˆ„๋ฝยท์‹คํŒจ 1800ํšŒ.

๋ฐ˜๋ฉด ๋ฒ„๋ ค์ง„ ๊ฒƒ๋“ค:

  • ํด๋Ÿญ ๋™๊ธฐํ™” ์ž”์ฐจ โ€” ์ •์ƒ ๋…ธ๋“œ์™€ ์ฃฝ์–ด๊ฐ€๋Š” ๋…ธ๋“œ๊ฐ€ ๋˜‘๊ฐ™์ด ํฌํ™”. ํŒ๋ณ„๋ ฅ 0.
  • ํ•˜๋“œ์›จ์–ด ์ˆ˜์‹  ํƒ€์ž„์Šคํƒฌํ”„ โ€” ์ง„์งœ ํ•˜๋“œ์›จ์–ด ์Šคํƒฌํ”„์ธ๋ฐ esp_timer ๋Œ€๋น„ 20~57ms ํฉ์–ด์ง. ์ฝœ๋ฐฑ์—์„œ ๊ทธ๋ƒฅ esp_timer๋ฅผ ์ฝ์œผ๋ฉด 25ยตs์ž…๋‹ˆ๋‹ค.

๐Ÿ”ป ์•„์ง ์—ด๋ ค ์žˆ๋Š” ๊ฒƒ

์ด๋”๋„ท ๋ฆญ์˜ S3์™€ WiFi ๋ฆญ์„ ๋™์‹œ์— ์ผœ๋ฉด ๊ฐ™์€ ์ฑ„๋„์—์„œ ์„œ๋กœ๋ฅผ ์ธ์ ‘ ํ—ˆ๋ธŒ๋กœ ์ธ์‹(adopt) ํ•ด๋ฒ„๋ฆฝ๋‹ˆ๋‹ค. ํ˜„์žฌ ๋Œ€์‘์€ ํšŒํ”ผ โ€” WiFi ๋ฆญ์ด ๋„๋Š” ๋™์•ˆ S3๋Š” ๊บผ๋‘ก๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ S3๋Š” USB ์ฝ˜์†”์„ ์—ด๋ฉด ๋ฆฌ์…‹๋˜๋ฉฐ ์žฌ์—ด๊ฑฐ๋˜๋ฏ€๋กœ, ์ฝ˜์†”์ด ์•„๋‹ˆ๋ผ ๋ฐœํ–‰๋œ ์ƒํƒœ ํ† ํ”ฝ์œผ๋กœ๋งŒ ์ง„๋‹จํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ๊ฐ™์€ ๋ณด๋“œ์—์„œ S3์˜ ์†ก์‹ ์€ ์ž˜ ๋“ค๋ฆฌ๋Š”๋ฐ leafโ†’S3 ์œ ๋‹ˆ์บ์ŠคํŠธ๋งŒ ACK๋ฅผ ๋ชป ๋ฐ›๋Š” ํ˜„์ƒ์ด ๋‚จ์•„ ์žˆ์Šต๋‹ˆ๋‹ค. ์†ก์‹ ๊ธฐ๋Š” ๋ฉ€์ฉกํ•˜๊ณ  ์ˆ˜์‹ ๊ธฐ๋งŒ ๋จน์€ ๋ชจ์Šต โ€” ์šฉ์˜์ž๋Š” ๋ช‡ ๋ฐ€๋ฆฌ๋ฏธํ„ฐ ์˜†์— ์–นํžŒ ESP32-H2 ์ฝ”ํ”„๋กœ์„ธ์„œ์ž…๋‹ˆ๋‹ค(๊ฐ™์€ 2.4GHz์—์„œ 802.15.4 ์†ก์‹ ). H2๋ฅผ ๋ฆฌ์…‹์— ๋ถ™์žก์•„๋‘๋Š” Kconfig ์˜ต์…˜์„ ๋งŒ๋“ค์–ด ๊ฐ€์„ค์„ ์‹คํ—˜์œผ๋กœ ์ „ํ™˜ํ•ด๋’€์Šต๋‹ˆ๋‹ค. ์ด ๊ณผ์ •์—์„œ ์ด๋”๋„ท๋„ ๊บผ๋ดค์ง€๋งŒ ์ฆ์ƒ์ด ๊ทธ๋Œ€๋กœ์—ฌ์„œ W5500์€ ์›์ธ์—์„œ ๋ฐฐ์ œ๋์Šต๋‹ˆ๋‹ค.


Conclusion

"์ธก์ •ํ•˜์ง€ ์•Š์€ ๊ฒƒ์€ ์•Œ์ง€ ๋ชปํ•œ ๊ฒƒ์ด๋‹ค" โ€” ์ด ํ”„๋กœ์ ํŠธ๋Š” ๊ทธ ์›์น™์„ README๊ฐ€ ์•„๋‹ˆ๋ผ ์†Œ์Šค ์ฃผ์„์œผ๋กœ ์ฆ๋ช…ํ•œ๋‹ค.

  • โœ… ์—ญํ•  ๋ถ„๋ฆฌ๋กœ ์‹œ๊ฐ ์˜ค์ฐจ 5.5ms โ†’ 0.2ms, ์ง€ํ„ฐ 17ms โ†’ 1.4ms, ๋Œ€์—ญํญ ์ ˆ๋ฐ˜
  • โœ… ํ•œ ์นฉ ๊ฒธ์šฉ ์‹œ ํ”„๋ ˆ์ž„ 85% ์†์‹ค์„ ์ธก์ •ํ•˜๊ณ  ์›์ธ์„ MAC์ด ์•„๋‹Œ ์ƒ์œ„ ํƒœ์Šคํฌ๋กœ ํŠน์ •
  • โœ… W5500 ์œ ์„  ์—…๋งํฌ๋กœ ๊ฒฝํ•ฉ์„ ๊ตฌ์กฐ์ ์œผ๋กœ ์ œ๊ฑฐ โ€” ์นฉ ํ•˜๋‚˜, ๋ธŒ๋ฆฟ์ง€ ์—†์Œ
  • โœ… W5500์˜ ๋‘ ํ•จ์ •(MAC ์ฃผ์†Œ ๋ถ€์žฌ, ISR ์„ ํ–‰ ์„ค์น˜)์„ ์ฝ”๋“œ์™€ ์ฃผ์„์œผ๋กœ ๋ฌธ์„œํ™”
  • โœ… ๋ถ€ํŒ… ์‹œ 13์ฑ„๋„ ์ธก์ • โ€” NTP ๋Œ€๊ธฐ 33์ดˆ๋ฅผ ํ™œ์šฉํ•ด ๋น„์šฉ 0
  • โœ… ํ•˜๋“œ์›จ์–ด ์˜ค์ง„ ๋‘ ๊ฑด์„ ๊ณต๊ฐœ ์ •์ •ํ•˜๊ณ , ๋ฏฟ์„ ์ง€ํ‘œ์™€ ์•„๋‹Œ ์ง€ํ‘œ๋ฅผ ์ธก์ •์œผ๋กœ ๊ตฌ๋ถ„
  • โœ… ์„ผ์„œ์—์„œ ๋ผ๋ฒจ๋งยทํ•™์Šต ๋ฐ์ดํ„ฐ์…‹๊นŒ์ง€ ์ด์–ด์ง€๋Š” ์™„๊ฒฐ๋œ ํŒŒ์ดํ”„๋ผ์ธ

Q&A

Q. ESP32-S3์— ์ด๋”๋„ท์„ ๋ถ™์ผ ๋•Œ W5500์ด ํ•„์š”ํ•œ ์ด์œ ๋Š”? A. S3์—๋Š” ๋‚ด์žฅ ์ด๋”๋„ท MAC(EMAC)์ด ์—†์Šต๋‹ˆ๋‹ค. ํด๋ž˜์‹ ESP32๋ผ๋ฉด ๋‚ด์žฅ EMAC์— PHY๋งŒ ๋ถ™์ด๋ฉด ๋˜์ง€๋งŒ, S3๋Š” MAC๊ณผ PHY๋ฅผ ๋ชจ๋‘ ์™ธ๋ถ€์—์„œ ๊ฐ€์ ธ์™€์•ผ ํ•ฉ๋‹ˆ๋‹ค. W5500์€ SPI ๋„ˆ๋จธ์˜ MAC+PHY ํ†ตํ•ฉ ์†”๋ฃจ์…˜์ด๋ผ ์ •ํ™•ํžˆ ๋งž์Šต๋‹ˆ๋‹ค.

Q. W5500 ์ดˆ๊ธฐํ™”์—์„œ ๊ฐ€์žฅ ์ž์ฃผ ๊ฑธ๋ฆฌ๋Š” ํ•จ์ •์€? A. โ‘  ์ž๊ธฐ MAC ์ฃผ์†Œ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค โ€” ์•ˆ ์ •ํ•ด์ฃผ๋ฉด ๊ฐ™์€ ๋„คํŠธ์›Œํฌ์˜ ๋‘ ๋ณด๋“œ๊ฐ€ ์ถฉ๋Œํ•ฉ๋‹ˆ๋‹ค. โ‘ก GPIO ISR ์„œ๋น„์Šค๋ฅผ ๋“œ๋ผ์ด๋ฒ„๋ณด๋‹ค ๋จผ์ € ์„ค์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋‘˜ ๋‹ค ์—๋Ÿฌ ์—†์ด ์กฐ์šฉํžˆ ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค.

Q. ์—…๋งํฌ ์„ธ ๊ฐ€์ง€๋Š” ์‹คํ–‰ ์ค‘์— ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‚˜์š”? A. ์•„๋‹ˆ์š”. Kconfig ๋นŒ๋“œ ์˜ต์…˜์ด๋ผ ์ปดํŒŒ์ผ ์‹œ์ ์— ๊ฒฐ์ •๋˜๊ณ  #ifdef๋กœ ์ฝ”๋“œ๊ฐ€ ์•„์˜ˆ ๋น ์ง‘๋‹ˆ๋‹ค. S3์—์„œ๋Š” ์ด๋”๋„ท์ด ๊ธฐ๋ณธ๊ฐ’์ž…๋‹ˆ๋‹ค.

Q. ์ฑ„๋„์„ ์™œ ํ•˜๋“œ์ฝ”๋”ฉํ•˜์ง€ ์•Š๋‚˜์š”? A. ์ฑ„๋„ 3์€ 10 frames/s๋ฅผ ์ „๋ถ€ ์ „๋‹ฌํ–ˆ๊ณ  9์™€ 11์€ ํ•˜๋‚˜๋„ ์ „๋‹ฌํ•˜์ง€ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด๊ฑด ์žฅ์†Œ์˜ ์†์„ฑ์ด๋ผ ํ•œ ๋ฐฉ์—์„œ ๋งž๋Š” ๊ฐ’์ด ์˜†๋ฐฉ์—์„œ ํ‹€๋ฆฝ๋‹ˆ๋‹ค.

Q. ์ˆ˜์ง‘ํ•œ ๋ฐ์ดํ„ฐ๋Š” ์ตœ์ข…์ ์œผ๋กœ ์–ด๋””์— ์“ฐ์ด๋‚˜์š”? A. ๋ธŒ๋กœ์ปค๋Š” ๋ฐฐ๋‹ฌ๋งŒ ํ•˜๊ณ , ๋ธŒ๋ฆฌ์ง€๊ฐ€ Kafka๋กœ ๋„˜๊ฒจ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค. ๊ฑฐ๊ธฐ์„œ ์‹ค์‹œ๊ฐ„ ๊ด€์ธก, ์‹คํ—˜ ์„ธ์…˜ ๊ธฐ๋ก, ๋ผ๋ฒจ๋ง๊ณผ ๋ชจ๋ธ ํ•™์Šต, ๋‚ด๋ณด๋‚ด๊ธฐ๋กœ ๊ฐˆ๋ผ์ง‘๋‹ˆ๋‹ค. ์ตœ์ข… ์‚ฐ์ถœ๋ฌผ์€ ๋ผ๋ฒจ์ด ๋ถ™์€ ํ•™์Šต ๋ฐ์ดํ„ฐ์…‹์ž…๋‹ˆ๋‹ค.

Comments

Comments