The pH acidity sensor and how to connect it
In Cheesemaking mode the pH sensor lets Samovar wait for the set acidity at the "pH wait" («Ожидание pH») stage. The measuring kit consists of a submersible electrode and a PH-4502C board. The electrode connects to the BNC connector of the board; its analog output PO passes the voltage to Samovar. Do not connect the electrode itself directly to the ESP32 or ADS1115: it needs a signal-processing board.
The electrode must be suitable for the product being measured and its temperature. A sensor designed for water can become fouled with protein and fat in milk; whether it is suitable for continuous immersion is determined by the electrode's datasheet. Calibration does not remove fouling or wear.
Connection via ADS1115
The ADS1115 is an external ADC, a converter of voltage to a number. To connect it you need an ADS1115 module, two 10 kΩ resistors with 1% tolerance and a 100 nF capacitor. The values refer to the output of the PH-4502C board, not to the electrode cable.
Power the PH-4502C with 5 V and the ADS1115 with 3.3 V. Join the GND grounds of both boards and of Samovar. Before connecting, check the pin markings of your board: the pin order differs between modules.
Connect PO of the PH-4502C to AIN0 of the ADS1115 through the first 10 kΩ resistor. Place the second 10 kΩ resistor between AIN0 and GND. Connect the 100 nF capacitor in parallel with the second resistor. The divider halves the voltage: 5 V on PO becomes 2.5 V on AIN0. The DO output is not used for pH measurement.
Connect SDA and SCL of the ADS1115 to the lines of the same name of the Samovar I2C — the common two-wire communication line with modules. Use the pins of your ESP32 board given in its schematic; GPIO numbers depend on the build. The SDA/SCL pull-ups must go to 3.3 V.
Connect ADDR to GND: the ADS1115 address will be 0x48. If this address is already taken by another device, choose a free ADS1115 address and specify it in the build setting. Two devices with the same address must not work on one line.
Enable the USE_ADS1115 build setting with the address value, for example #define USE_ADS1115 0x48, and upload the firmware. pH is read from AIN0 automatically. LUA_PIN stays free. If the ADS1115 is unavailable, starting cheesemaking and saving the pH calibration are blocked.
Check the voltage between AIN0 and GND with a multimeter before connecting to the ESP32. The ADS1115 measurement range in the firmware is ±4.096 V, but it does not allow applying a voltage above the chip's supply to the input. After changing the circuit or switching to the ADS1115, calibrate again.
Connection without the ADS1115
If USE_ADS1115 is disabled, the output of the same divider is connected to LUA_PIN instead of AIN0. The PH-4502C is powered from 5 V; its GND is joined to the Samovar GND. You must not apply 5 V directly to an ESP32 input. LUA_PIN is also used by the MPX5010DP pressure sensor: connect only one device to it. During cheesemaking this input is occupied by the pH measurement and cannot be read from Lua.
If the readings jump when equipment is switched on
First compare the readings in a separate plastic cup with buffer and in the vat, switching on the pump, the stirrer and the heating one at a time. If the jumps are linked to switching equipment on, electrical interference is a likely cause. A slow drift of the readings in the buffer with the equipment off requires checking the electrode and the PH-4502C; isolation will not fix their fault.
To eliminate interference through the common power supply and ground, you can separate the measuring part: electrode → PH-4502C → 1:2 divider → ADS1115 → ADuM1250 → ESP32. The ADuM1250 is an I2C electrical isolation module: it passes data without electrically connecting the two sides.
Power the PH-4502C, the ADS1115 and the measuring side of the ADuM1250 from a separate USB power bank with a 5 V output that supports low load. In this circuit the ADS1115 also gets 5 V; the divider at its input stays. During measurement the power bank must not be charging or powering other parts of Samovar.
Power the side of the ADuM1250 facing the ESP32 from the 3.3 V of Samovar. Connect SDA/SCL of the ADS1115 to the 5 V side, and SDA/SCL of Samovar to the 3.3 V side. The pull-up resistors of each side must be connected to the supply of that very side.
Do not join the grounds of the two sides. If you join them with a wire, a USB cable or through other equipment, the isolation is broken. The other I2C devices of Samovar stay on the ESP32 side.
Place the PH-4502C and the ADS1115 close together, away from the heating regulator. Keep the PO wire short and route the electrode cable away from power wires. The ADS1115 address and the USE_ADS1115 setting stay the same.
This is a connection option against electrical interference, not a guarantee of electrode accuracy. After calibration, repeat the check with equipment being switched on; the circuit must not give a reproducible pH shift on switching.
Software filter and limitations
In firmware with the median filter, the pH reading is calculated from five consecutive measurements taken one second apart. The median is the middle number in order after sorting: the series 5.42; 5.41; 3.10; 5.43; 5.42 gives 5.42. The filter removes short spikes but does not fix a constant error or a slow drift of the readings. With a smooth change the delay is about two seconds.
pH becomes available after all five samples are filled. After a read error, an invalid reading, a gap between measurements of more than five seconds, a change of the calibration coefficients or a process reset, the window is filled anew. An old result is not passed off as a new valid measurement. At the "pH wait" («Ожидание pH») stage, confirmation of reaching the threshold is kept for 30 seconds.
The filter applies to both connections — via the ADS1115 and via LUA_PIN. The ADC field on the calibration page shows a fresh raw sample, without this filter; wait for it to stabilize before fixing a point. Samovar does not take temperature into account in the pH conversion: compare results and control samples at the same temperature. Updating the documentation on the website does not update the firmware on your device.
Calibration and care
Calibrate the whole assembled kit with two fresh buffer solutions at about pH 7 and pH 4. Enter the values from the solution label for the measurement temperature. The procedure with the buttons is described in the section
pH calibration.
After milk, clean the electrode with a compatible cleaner for protein and fat deposits, following the manufacturer's instructions. Store the sensing end in the recommended electrode storage solution, not dry and not in distilled water. Do not exceed the electrode's permitted temperature. After cleaning, check the readings in a fresh portion of buffer.