Example — a brewery control system
The flagship SignalSQL build is the backend for a brewery control system. Brewing needs precise temperatures held over long periods during mashing, which makes the PID algorithm a natural fit. In the reference setup the frontend is built with NodeJS and the Vue framework, and SignalSQL plays a dual role: it is the brewery backend and it logs the process temperatures on a regular basis — one place for both control and monitoring.
This page shows how the rig is modelled as tables. It builds on Built-in tables and references and Hardware modules.
Everything is a row
- Each temperature probe is a 1-wire
OWDEVICEthermometer; SignalSQL surfaces it as anINPUTrow namedowdevice:{id}. - Each pump and heating element is an
OUTPUTrow. - Each control loop is a row in the
PIDtable. - The operator’s setpoints are plain values you
UPDATE.
Bring a vessel online by inserting/configuring rows; run the brew by updating setpoints.
Read the probes
Once the OWSERVER module has connected and discovered
the devices, the hot-liquor-tank probe is just an INPUT row:
SELECT Value FROM INPUT WHERE Name = 'owdevice:28.F049AF040000';
Hold a setpoint with PID
Keep your target temperatures in an ordinary table you can update at any time:
CREATE TABLE setpoints (
ID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(255),
Value double
);
INSERT INTO setpoints VALUES (0, 'hlt', 63.8);
Then drive the HLT element from a PID loop whose input is the probe, whose
setpoint is that row, and whose output is the element’s OUTPUT signal:
INSERT INTO PID (INPUT, SETPOINT, Kp, Ki, Kd, Direction, OUTPUT)
VALUES (
'=INPUT/owdevice:28.F049AF040000/Value',
'=setpoints/hlt/Value',
2.0, 0.5, 1.0, 1,
'=OUTPUT/owdevice:12.574B7D000000/Value'
);
Change the target at any time — the loop picks it up on its next evaluation:
UPDATE setpoints SET Value = 67.0 WHERE Name = 'hlt';
Log for charts
Sample the HLT temperature once a second into a table Grafana can plot:
INSERT INTO logger VALUES (1, 'hlt', 1000, 3, '=INPUT/owdevice:28.F049AF040000/Value');
Point Grafana’s MySQL data source at the server (see Connecting) and chart the logged temperature against the setpoint. You now have a full brew controller — sensors, setpoints, PID heating, logging, and a live dashboard — expressed entirely in SQL.
The Vue / Node dashboard from the reference setup is a separate project and isn’t part of the SignalSQL download — this page focuses on the SQL that runs the rig. Have a question about the example? Reach us via Feedback & support.