
Wire encoder modbus interface
pe1mew/wire-encoder-modbus-interface
A modbus interface for a resistor wire encoder and a WCH CH32V003J4M6

Universal interface for cup-anemo- and wind-directon- sensor to modbus
Windmeter modbus interface is an open-source printed circuit board by pe1mew, from the pe1mew/windmeters-modbus-interface repository on GitHub. It is a 2-layer board of 67 × 92 mm with 30 parts on 26 nets, routed with 258 tracks and 113 vias.
It is built around the CH32V003J4M6, MAX3485ED and DB207. Its parts include 7 resistors, 6 connectors, 5 capacitors, 2 ICs and 2 diodes. It belongs with the interfaces and adapters and sensors and measurement boards and the RISC-V boards of this library.
A CH32V003-based interface board that bridges classic analog wind sensors — a cup anemometer (reed-relay pulses) and a wind-vane potentiometer (0–360°) — onto Modbus RTU over RS-485, powered by 24 V passive PoE and designed for daisy-chained field buses.
One PCB serves both sensor types; the firmware build selects the variant. Each variant responds at its own Modbus address, selected by a solder jumper:
| Variant | Jumper open | Jumper bridged |
|---|---|---|
Wind speed (wind_speed) | 30 | 35 |
Wind direction (wind_direction) | 31 | 36 |
Both, one slave (wind_combined) | 32 | 37 |
The wind_combined build serves both sensors through a single Modbus
address; its register map carries speed and direction at their own
register addresses, with the direction raw-ADC diagnostic at 30013 (30005
holds the speed pulse count).
| Area | State |
|---|---|
| Requirements | design/TDS.md v0.9 — 69 active requirements (incl. FR-S39 persistence, FR-S40 runtime calibration) + §4 as-built hardware from the KiCad PCB, hardened by multi-agent audits + verification passes |
| Drivers | Pulse counting, ADC/circular-mean, Modbus RTU — all HIL-verified on silicon (design/driverDevelopment.md) |
| Product firmware | Integration stages A–F complete; TDS-functionally complete on all three variants (speed, direction, combined), acceptance suite green (design/integrationPlan.md) |
| Hardware/HIL | KiCad schematic/PCB in design; §9.1 MAX3485-rig HIL complete on all three variants; real-PCB rows (§9.2) pending |
| Release | Firmware version 1 not yet tagged (software/firmware/RELEASES.md) |
design/softwareArchitecture.md).12 input registers (FC04) and 6 holding registers (FC03/06/16); registers
of an absent sensor read 0, and the combined build adds a 13th input
register (30013, direction raw ADC). Highlights: instantaneous and averaged
values, status bits, identification (build + firmware version), uptime,
CRC/served counters, gust, seconds-since-last-pulse.
6 holding registers: direction offset, measurement window, averaging
window, low-speed cut-off, and the anemometer calibration (factor C +
pulses-per-rotation, FR-S40 — so one image serves any anemometer, set over
Modbus). All persisted in flash across reset/power-loss (FR-S39); the §2.8
defaults apply only on first boot / erased store. The authoritative map with
ranges, defaults, and requirement IDs is design/TDS.md
§2.7/§2.8.
| Path | Contents |
|---|---|
design/ | The design-document chain (index in design/README.md): scratchBook → TDS → softwareArchitecture (+ UML diagrams in design/diagrams/) → driverDevelopment → integrationPlan |
hardware/KiCad/ | Schematic + PCB (KiCad); symbol libraries as git submodules |
hardware/Documentation/ | Component datasheets (HLK-K78xx, DB20x, Kradex enclosure, …) |
software/firmware/ | Product firmware (PlatformIO + ch32v003fun), three build envs (speed / direction / combined) + _test variants |
software/drivers/ | Standalone driver projects with HIL test shells (the verified libraries the product references in place) |
software/hil/ | Scripted hardware-in-the-loop harness: Saleae Logic 2 (MCP) + ADALM2000 (libm2k) + acceptance/ pytest suite; consolidated testReport.md |
Doxyfile | Doxygen config — builds a single site (design docs + API reference) with this README as the landing page |
documentation/ | Chip pinout and project reference images |
Clone with submodules:
git clone --recurse-submodules https://github.com/pe1mew/windmeters-modbus-interface.gitRequires PlatformIO and a WCH-LinkE on SWIO.
cd software/firmware
pio run -e wind_speed # or wind_direction, or wind_combined
pio run -e wind_speed -t upload # flash via WCH-LinkEResource ceilings (14 336 B flash / 1 792 B RAM, NFR-RES01) are enforced as
hard build gates. *_test environments add bench-only hooks — never
release those binaries. The firmware version byte lives in
src/version.h; the release process is documented in RELEASES.md.
Host tests (no hardware): the circular-mean math is exhaustively
verified in Python — python software/drivers/common/circmean/test_circmean.py.
Acceptance suite (bench: Saleae Logic 2 with its MCP server, ADALM2000, WCH-LinkE, TTL Modbus rig):
cd software/hil/acceptance
..\.venv-m2k\Scripts\python.exe -m pytest . --build speedOne command per flashed variant; covers the register map, protocol
vectors, measurement services, averaging engine, version chain, and
build gates. See software/hil/README.md for
instrument setup, wiring, and the bench-quirk catalogue.
HIL test report — software/hil/testReport.md
consolidates every hardware-in-the-loop test (driver-phase, integration-
stage, and MAX3485 transceiver rig) with its setup, expected result, and
pass/fail verdict in one place.
Design record — design/README.md indexes the
document chain (requirements → architecture → drivers → integration) and
the UML diagrams.
API + design site — the firmware headers/sources carry full Doxygen,
and Doxyfile folds the design docs in as pages with this
README as the landing page. Build the browsable HTML with:
doxygen Doxyfile # output in documentation/doxygen/html/index.htmlTest evidence — software/hil/testReport.md
is the consolidated hardware-in-the-loop test report.
pe1mew/windmeters-modbus-interface-tester —
the Modbus RTU master bench tool (M5Stack AtomS3 + RS-485) used to
exercise this device; its bench findings seeded this project's TDS.Software is provided under a Source-Available Non-Commercial License; documentation and images under CC BY-NC-ND 4.0. See LICENSE and license.md. Third-party datasheets and KiCad library submodules remain under their owners' terms.
Remko Welling (PE1MEW)
| Qty | Value | Footprint | References |
|---|---|---|---|
| 4 | ~ | Jumper:SolderJumper-3_P1.3mm_Bridged12_Pad1.0x1.5mm_NumberLabels | JP2, JP3, JP4, JP5 |
| 3 | 100n | Capacitor_SMD:C_1206_3216Metric_Pad1.33x1.80mm_HandSolder | C1, C2, C5 |
| 3 | 10k | Resistor_SMD:R_1206_3216Metric_Pad1.30x1.75mm_HandSolder | R4, R5, R7 |
| 2 | 20k | Resistor_SMD:R_1206_3216Metric_Pad1.30x1.75mm_HandSolder | R2, R3 |
| 2 | RJ14 | Connector_RJ:RJ14_Connfly_DS1133-S4_Horizontal | J4, J5 |
| 1 | 100 | Resistor_SMD:R_1206_3216Metric_Pad1.30x1.75mm_HandSolder | R6 |
| 1 | 100u | Capacitor_THT:CP_Radial_D8.0mm_P5.00mm | C3 |
| 1 | 120 | Resistor_SMD:R_1206_3216Metric_Pad1.30x1.75mm_HandSolder | R1 |
| 1 | 4u7 | Capacitor_THT:CP_Radial_D5.0mm_P2.50mm | C4 |
| 1 | Address select | Jumper:SolderJumper-2_P1.3mm_Open_Pad1.0x1.5mm | JP6 |
| 1 | BZX84Cxx | Package_TO_SOT_SMD:SOT-23 | D2 |
| 1 | CH32V003J4M6 | Package_SO:JEITA_SOIC-8_3.9x4.9mm_P1.27mm | U1 |
| 1 | DB207 | my-KiCad-library:DB207-DIP-4 | B1 |
| 1 | LOGO_LogoRFSee_28x5-6mm | my-KiCad-library:LOGO_LogoRFSee_28x5-6mm | G*** |
| 1 | MAX3485 | Package_SO:SOIC-8_3.9x4.9mm_P1.27mm | U2 |
| 1 | MODBUS-P1 | my-KiCad-library:CONN_215877-1 | J1 |
| 1 | MODBUS-P2 | my-KiCad-library:CONN_215877-1 | J3 |
| 1 | Programming | Connector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_Vertical | J2 |
| 1 | SM712_SOT23 | Package_TO_SOT_SMD:SOT-23 | D1 |
| 1 | enable term. | Jumper:SolderJumper-2_P1.3mm_Open_Pad1.0x1.5mm | JP1 |
| 1 | ~ | my-KiCad-library:HLK-K7803-500R3 | P1 |

pe1mew/wire-encoder-modbus-interface
A modbus interface for a resistor wire encoder and a WCH CH32V003J4M6


do2mad/messsystem-1mhz
Ein kleines Messgerät für den Reparaturplatz: Es überwacht sechs Gleichspannungen (0–30 V) und eine Wechselspannung (9 V) gleichzeitig und zeigt sie auf einem 20×4-LCD an.

74th/stickpoint-firmware
Pointer module with joystick (PIM447 Compatible)

KaiPereira/Alchemical-Cosmological-Badges
These are alchemical-cosmological PCB hackathon badges I designed in a day for the Fallout hackathon in Shenzhen, China.


tvecera/ch32-projects
A collection of example projects and experiments for CH32-series microcontrollers from WCH (Nanjing Qinheng Microelectronics).

74th/usb-rebooter
We would appreciate it if you would not sell them. 販売はしないでいただけるとありがたいです。
It measures 67 × 92 mm and has 2 copper layers, 1.6 mm thick.
30 parts, built around the CH32V003J4M6, MAX3485ED and DB207. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the pe1mew/windmeters-modbus-interface repository on GitHub, at the commit this page was made from: the board is hardware/KiCad/windmeter-modbus-interface.kicad_pcb and its schematic hardware/KiCad/windmeter-modbus-interface.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask pe1mew before reusing the design.