Reading a knitting machine's XML status with an ESP32 PLC
An HTTP client reading machine XML is often the cheapest integration on the floor: many machine controllers already expose their state as a web resource. Terrot circular knitting machines publish statusErw.xml with revolutions, RPM and machine state. This example polls that file over Ethernet from an ESP32 PLC, extracts the values and repackages them as JSON — the exact approach used in a real textile machine monitoring deployment.
Use the interface the machine already has
No PLC programming on the machine side, no fieldbus gateway — just a GET request to the controller's embedded web server on the same plant subnet. The PLC connects, sends "GET /statusErw.xml HTTP/1.1" with Connection close, and reads the body. For machine builders that expose XML or JSON status pages, this beats retrofitting sensors for data you can simply ask for.
A 20-line XML parser is enough
The response is flat XML with no nesting, so a full parser library would be wasted flash. getTagValue() simply finds the text between an opening and closing tag with two indexOf calls — more than enough to pull revolutions, rpm and machstat reliably. A 500 ms read timeout with a sliding window means a powered-off machine costs half a second per poll, never a hung loop.
Normalise to JSON at the edge
The extracted values are immediately repackaged into the same JSON schema the rest of the fleet publishes over MQTT, with a source field marking where the datapoint came from. Downstream — broker, Node-RED concentrator, database, dashboards — nothing needs to care whether a value originated in a pulse sensor, a Modbus register or the machine's own XML page. Missing or empty tags are mapped to null rather than fake zeros, so a parsing gap can never masquerade as a stopped machine.
A snippet from the implementation
Straight from the example as deployed on the ESP32 PLC — copy it freely:
The full example is a complete program — wiring header, setup and main loop — ready to adapt to your application.
Frequently asked questions
How do I find out whether my machine exposes a status page?
Point a browser at the machine controller's IP address while on the plant network. Many controllers ship with an embedded web server; check the manual or sniff the traffic of the vendor's own monitoring tool to find URLs like statusErw.xml.
Why poll every 10 seconds instead of faster?
Machine state and RPM change slowly compared with network cost, and embedded controllers can be fragile under load. Ten seconds gives smooth trends without stressing the machine's web server; adjust to taste.
What if the XML structure changes with a firmware update of the machine?
The tag-based extraction fails soft — missing tags produce null fields in the JSON rather than crashes. Pair it with OTA updates on the PLC so you can adapt the parser fleet-wide in minutes.