/* Version 3.2 Written by Steff Eberle GBS St. Gallen August 20ieth 2025
Implementation for the Arduino Machine Control Board on the Portenta H7 M7core
The current version of this Temperature control unit is capable of:
- controlling up to 3 Heating Cirquits
- communicating with a MQTT Broker via Ethernet/Internet
- communicating with a MQTT Broker to receive /subscribe the target temperature for each Heating Cirquit
- communicating with a MQTT Broker to receive /subscribe the HeatingPump activation for each Heating Cirquit
- doing Temperature Measurements /measures the actual Temperature of each Heating Cirquit with the HW on the Arduino Machine Control Board
- Controls the Valves of each Heating Cirquit...the open/close valves need to be operated in a duty cycle mode, as there is a time delay of valve adjustment and the effect of temperature adjustment
- communicating with a MQTT Broker to send/ publish the actual temperature of each Heating Cirquit
- Publishes status and temperatures for a Node‑RED dashboard. */
- Up to 3 circuits (
NUM_CIRCUITS
in code). - MQTT (1‑based topics):
- Inputs (subscribe):
heating/target/1..3
(float °C),heating/pump/1..3
(0
or1
) - Outputs (publish):
heating/status/1..3
(JSON),heating/temperature/1..3
(float)
- Inputs (subscribe):
- Non‑blocking valve pulses (no
delay()
), with deadband and rest-time between moves. - Optional pump digital outputs (configure pins in
Config.h
).
- Arduino Portenta H7 + Machine Control board
- 3x motorized valves (OPEN/CLOSE digital pins each)
- 0..3 pumps (digital outputs)
- RTD sensors via Adafruit MAX31865 (PT100/PT1000). Adjust reference resistor and wiring mode in
TemperatureSensor
(e.g.,MAX31865_3WIRE
,430.0
Ω).
*.ino
— main sketch (non‑blocking loop withmillis()
timers)Config.h
— topics, pins, static IP/MAC (useuint8_t
arrays), pump DO pinsMQTTClient.h/.cpp
— Ethernet + ArduinoMqttClient wrapper, topic subscriptions, message routingValveController.h/.cpp
— valve state machine (Idle/Open/Close), proportional pulse timingTemperatureSensor.*
— MAX31865 integration (adjust PT type and Rref)node_red_heating_flow.json
— Node‑RED dashboard (sliders, switches, status, charts)
- Set targets:
heating/target/1
,heating/target/2
,heating/target/3
(payload e.g.21.5
) - Set pump ON/OFF:
heating/pump/1
,heating/pump/2
,heating/pump/3
(payload"1"
/"0"
) - Status JSON (controller → broker):
heating/status/1..3
{"actual": 20.8, "target": 21.5, "pump": 1, "state": "open"}
- Temperature (controller → broker):
heating/temperature/1..3
(payload float like20.80
)
Libraries (Library Manager):
- ArduinoMqttClient
- Ethernet (or Portenta_Ethernet, depending on your setup)
- Adafruit MAX31865
Board: Portenta H7 (M7 core).
Adjust Config.h
for network (MAC/IP) and pins.
Import node_red_heating_flow.json
and point the broker to your MQTT host (default 192.168.1.50
).
Dashboard provides target sliders, pump switches, status text, and temperature charts.
- Edit
Config.h
:MQTT_BASE_TOPIC
(default"heating"
)- Network: MAC/IP/DNS/GW/Subnet (as
uint8_t
arrays) - Valve pins and
PUMPx_DO_PIN
pins
- Flash the sketch.
- Start MQTT broker (e.g., Mosquitto).
- Import Node‑RED flow and deploy.
- Adjust targets and pumps from the dashboard.
MIT (or choose your preferred license).