ESP32 Firmware & IoT for Smart Buildings
Smart-building edge nodes fail in the field, not on the bench: an RS-485 trunk that wired fine drops BACnet MS/TP tokens the moment the rooftop unit's VFD spins up. We build ESP32 firmware that treats the fieldbus, the control loop, and the commissioning handoff as one problem, so the panel that passes point-to-point also holds setpoint a year later.
Challenges specific to Smart Buildings
BACnet MS/TP token loss on the RS-485 trunk
VFD and contactor noise corrupts framing, the token drops, and the ESP32 silently falls off the MS/TP ring until a power cycle, so points read stale.
HVAC setpoint hunting after commissioning
A PI loop tuned on a cool morning oscillates the damper at 3 PM, the zone overshoots two degrees, and occupants override the thermostat for the whole floor.
Cheap CO2 sensors drift out of spec
NDIR cells age and the ABC baseline algorithm latches onto an occupied room, so demand-controlled ventilation over-ventilates and burns reheat energy.
Lighting and shade nodes flood the BACnet bus
Every occupancy edge and lux change publishes a COV, the MS/TP bus saturates, and the AHU controller's reads time out during the busiest part of the day.
Commissioning point lists never match the panel
The mechanical schedule says AI3 is mixed-air temp but the integrator wired it to discharge-air, and nobody catches it until the building runs backwards in winter.
How GizanTech solves them
- Hardened MS/TP and Modbus RTU stack. 1) Isolated RS-485 with biased fail-safe termination, automatic baud detection, MAC poll-for-master recovery, and a watchdog that rejoins the MS/TP token ring without a power cycle.
- Field-tunable, anti-windup control loops. 2) PI/PID with deadband, integral clamping, and slew-limited damper output exposed as BACnet writable AVs so a balancer retunes setpoint hunting from a laptop, no reflash.
- Self-validating CO2/IAQ acquisition. 3) Dual-source NDIR with ABC baseline lockout during occupancy, cross-check against differential pressure, and an out-of-range BACnet reliability flag instead of a silent bad reading.
- COV throttling and bus scheduling. 4) Per-object COV increment thresholds, rate limiting, and token-pass-aware transmit windows so lighting and shade traffic never starves the AHU controller's polls.
- Commissioning-first point exposure. 5) Object names, units, and present-value source map straight to the mechanical point list, with a built-in point-test mode and CSV export the integrator signs off against.
| BMS point | Fieldbus protocol | Control loop | Comfort / energy impact | Commissioning note |
|---|---|---|---|---|
| HVAC zone setpoint | BACnet MS/TP (AV, writable) | PI with deadband, anti-windup, slew-limited damper | Holds +/-0.5 C, kills setpoint hunting and reheat overshoot | Expose as priority-array AV; balancer tunes Kp/Ki live, no reflash |
| Occupancy | Modbus RTU coil to BACnet BV | Debounced PIR fused with schedule, COV-throttled | Drives DCV and unoccupied setback, trims fan and reheat hours | Force point in test mode; verify polarity vs. lighting relay |
| CO2 / IAQ | BACnet MS/TP AI (ppm) | Dual-NDIR median, ABC lockout, reliability flag | DCV trims over-ventilation; bad cell flags instead of over-fanning | Span-check against reference; log ABC baseline at handover |
| Lighting / shade | BACnet MS/TP MV + AO (0-10 V / lux) | Daylight-harvest AO, COV-increment rate limit | Cuts lighting load without starving AHU polls on the trunk | Cap COV increment; confirm dimming curve and shade end-stops |
Go deeper
ESP32 Firmware & IoT Development for other industries
Frequently asked questions
Do you support BACnet MS/TP and Modbus on the same panel?
Yes. The ESP32 firmware runs a hardened BACnet MS/TP server and a Modbus RTU/TCP master concurrently, bridging legacy Modbus meters and VFDs into your BACnet point list on one isolated RS-485 bus.
How do you stop setpoint hunting after we commission a zone?
The PI/PID loops expose Kp, Ki, deadband, and output slew as BACnet writable values, so a balancer retunes a hunting damper from a laptop without a firmware reflash or a site visit.
Can the device join an existing BACnet building network?
Yes. It is a routable BACnet MS/TP device with configurable MAC, baud, and Device Instance, and it exposes named objects that map to your mechanical point list for integrator sign-off.
How do you keep cheap CO2 sensors from over-ventilating?
We median dual NDIR cells, lock out ABC baseline correction during occupied hours, cross-check differential pressure, and raise a BACnet reliability flag instead of feeding a drifted reading to DCV.
What happens if the RS-485 trunk is noisy from VFDs?
Isolated transceivers, biased fail-safe termination, and a poll-for-master watchdog let the node rejoin the MS/TP token ring automatically after VFD-induced framing errors, with no power cycle needed.