Arduino-based current-transformer data collector that publishes machine "working / idle" state to the AWM monitoring system over HTTP.
RawDataWorker is a small hardware agent that turns an ordinary
current transformer (CT) into a non-invasive machine activity sensor.
It measures the RMS current drawn by the machine's power line, decides
whether the machine is currently working or idle, and pushes the state
to the AWM backend via a plain HTTP POST.
The project is part of a larger monitoring stack:
┌──────────────┐ HTTP/JSON ┌──────────────┐ SignalR ┌────────────┐
│ RawDataWorker│ ────────────► │ AWM │ ──────────► │ Dashboard │
│ (Arduino) │ │ (ASP.NET) │ │ (browser) │
└──────────────┘ └──────────────┘ └────────────┘
This repository contains only the firmware and hardware artifacts. The backend lives in a separate repository.
-
The current transformer is clamped onto one phase of the machine's power cable. It outputs a small AC voltage proportional to the line current.
-
The Arduino samples the CT via
EmonLib::calcIrms()and computes the RMS current. -
Estimated active power is
P ≈ U · I(nominal 230 V). -
A simple debouncer requires
Nconsecutive equal readings before the state is considered stable. -
When the stable state differs from the last state that was successfully sent, the Arduino opens a TCP connection to the AWM backend and issues:
POST /api/Wincc/updateMachineStatus HTTP/1.1 Host: 192.168.10.200 Content-Type: application/json Content-Length: 87 Connection: close {"machineName":"Danobat","Condition":true,"current":3.42,"power":787}
-
The server replies
200 OKwith a body indicating whether the state was actually changed. The Arduino treats any200 OKas success.
| Component | Notes |
|---|---|
| Arduino Mega 2560 | Any AVR board with enough RAM will do |
| Ethernet Shield W5100 | Or a compatible W5100/W5500 module |
| SCT-013-030 CT | 30 A / 1 V output; adjust CT_CALIBRATION to taste |
| Burden resistor | Already built into the SCT-013-030 |
| 3D-printed enclosure | See hardware/case |
⚠️ The current transformer must be clamped around a single phase conductor, not around the whole cable. Otherwise the magnetic fields cancel out and you will read ~0 A.
Photos of the assembled device: hardware/photos.
EmonLib— current measurementEthernet— W5100/W5500 networkingSPI— bundled with the AVR core
- Open
firmware/RawDataWorker/RawDataWorker.inoin the Arduino IDE. - Select Tools → Board → Arduino Mega or Mega 2560.
- Select the correct serial port.
- Adjust the configuration block at the top of the sketch
(IP addresses,
MACHINE_NAME,CT_CALIBRATION, …). - Upload and open the Serial Monitor at 9600 baud.
All tunables live in a single block at the top of the sketch:
| Constant | Purpose |
|---|---|
mac, localIp, … |
Static network configuration of the Arduino |
serverIp, serverPort |
AWM backend address |
MACHINE_NAME |
Identifier sent in every payload |
CT_CALIBRATION |
EmonLib calibration coefficient; tune to your CT |
CURRENT_THRESHOLD_A |
Current above which the machine is considered active |
MAINS_VOLTAGE_V |
Nominal voltage used for the power estimate |
NEED_STABLE_READINGS |
Number of equal readings to confirm a state change |
MEASURE_INTERVAL_MS |
Sampling period |
HTTP_TIMEOUT_MS |
Socket timeout for the outgoing request |
========================================
=== RAW DATA WORKER (current) ===
========================================
Sensor... OK
Ethernet... OK, IP=192.168.10.177
Server: 192.168.10.200:5050
========================================
0.02 A | Stop 1/3
0.02 A | Stop 2/3
0.01 A | Stop 3/3
3.41 A | Work 1/3
3.44 A | Work 2/3
3.39 A | Work 3/3 -> sending... [CHANGED] OK
See docs/protocol.md for the full request/response
contract, error handling and retry behaviour.
If you just want to flash a working binary without setting up the
Arduino toolchain, grab RawDataWorker.ino.standard.hex from the
latest release.
The pre-built binary uses the default configuration from the source code. If you need a different IP address, machine name, or CT calibration, build the sketch yourself using the instructions above.
- Blocking HTTP. While the request is in flight (up to
HTTP_TIMEOUT_MS), the loop does not sample. At a 1 Hz rate this is acceptable; if higher frequencies are needed, the HTTP client should be rewritten as a non-blocking state machine. P ≈ U · I. This is an apparent power estimate. For machines with poor power factor the real active power may be lower. A true energy meter or a PZEM-004T module would give real power directly.- EmonLib is in maintenance mode. A future revision may switch to
EmonLibCMorEmonLibDBfor continuous, interrupt-driven sampling. - No TLS. The device talks plain HTTP on a trusted industrial LAN.
.
├── .github/workflows/ CI: build the sketch on every push
├── firmware/
│ └── RawDataWorker/ Arduino sketch (folder name = sketch name)
├── hardware/
│ ├── case/ 3D enclosure drawings
│ ├── photos/ Photos of the assembled device
│ └── wiring/ Wiring diagram
├── docs/
│ └── protocol.md HTTP contract between the device and AWM
├── .editorconfig
├── .gitattributes
├── .gitignore
├── LICENSE
└── README.md
The
firmware/RawDataWorker/folder has the same name as the.inofile inside it. This is required by the Arduino build system — the sketch name must match the folder name.
MIT — see LICENSE.
Hardware artifacts (drawings, enclosure) are released under the same license unless stated otherwise.
Dmitry Kharchenko — C#/.NET backend developer with a soft spot for the hardware side of things.
- GitHub: @Dimo4ka174
- Email:
Dmitry.Kharchenko.Dev@yandex.ru
This repository is a personal project. It does not contain any code, schematics, or data belonging to previous or current employers.
