ESP32 to monitor different sensors in HX and displays data on LCD mounted under the machine.
It also sends the data to the other ESP using the ESP Now protocol.
Sensors for:
Temperature Group Head
Temperature Boiler (thermocouple screwed down into outside of boiler)
Flow rate
Pressure sensor
to send data to Webserver ESP32
ESP's have a protocol called "ESP Now" that lets ESP32's and ESP8266's talk to each other over 2.4 GHz without going through a router.
But I couldn't get an ESP8266 to broadcast to a ESP32, so I used two ESP32's, and I have can them broadcast to each other.
There is extra code to figure out the wifi channel to use, and initialize wifi. Its in mostly in setup.
Sensor ESP32 uses the mac address of the Webserver ESP32, so you need to figure out the mac address of the ESP32 used for webserver. I put the mac address in the credentials.h file
The same structure needs to be in both ESP's, to format the data sent. It lets the receiver figure out how to process the data.
My structure is:
typedef struct struct_message {
int Sid;
double StempGroup;
double StempBoiler;
double Srate; //ml/s from flowmeter
double StotalML; //total ml from flowmeter for this shot
double Spressure;
double Sweight; //placeholder for weight
int StimerPump; //not used, used timer from start of flow instead
int StimerFlow;
int SreadingId;
} struct_message;
Used an 16x2 Ebay I2C LCD
If the link doesn't work, search for "i2c 16x2 lcd" on ebay, you should find plenty of choices.
Easy to connect, uses +5VDC, so +5, ground, and two I2C wires, for clock (SCL) and data (SDA).
SDA connects to ESP32 GPIO 21
SCL connects to ESP32 GPIO 22
VCC to ESP32 5V pin
GND to ground
Picture of the back of the LCD installed in its case. I used hot glue to secure the LCD. It has a little daughtercard for the I2C interface. There is also a pot on the card to set the LCD intensity for the lettering.
I built the temperature sensor part of this when I first bought the Expobar, around 10 years ago. There were fewer options at the time, and I used a TC4 thermocouple interface board that is mostly used for coffee roasters. I had one available.
Even though it has 4 inputs, I use two. One is for grouphead temp, the other I have screwed into the boiler exterior.
This schematic is for a newer version of the board, with more features. I just use the TC inputs and ambient temp sensor part of it
The J2 analog connector is where you connect the I2C lines.
Power is 5V from ESP32 5V pin
The yellow connectors are special thermocouple connectors for k type.
Bought a "0-4.5V Stainless Steel Pressure Transducer Sender Sensor Oil Fuel 1/8NPT Air US" in the 200 psi version from ebay.
Link here, but ebay links expire, you can search for one on ebay.
200 psi = 13.8 bar, its output is: 0.5V~4.5V linear voltage output. 0 psi outputs 0.5V, 100 psi outputs 2.5V, and 200 psi outputs 4.5V
I calculated this will output 3.3V at 9.8 bar. You don't want to go much over 3.3V to a ESP32 GPIO pin, so this works since my OPV will keep the pressure at about 9 bar max.
Based on this numbers, I calculated how to convert, and use this in the program
PresBar = (MeasPres-660)/382; //scale pressure sensor value to bar
The 660 is to account for 0.5V = 0 psi. 382 converts psi to bar. Seems to be accurate, I get the same reading from this and from my analog pressure gauge.
To install, I cut the teflon tubing after the OPV, and added a 6mm Tee connector. The teflon tubing is 4mm x 6mm.
5508K162 Push-to-Connect Tube Fitting for Air and Water High-Temperature, Tee Connector, 6mm Tube OD
2129T25 5 feet of 4mm x 6mm fep tubing
5508K123 High-Temperature, Straight Adapter, 6mm Tube OD, 1/8 BSPT Male. (already had this)
This 1/8" FIP brass coupler fitting from Home Depot
So add the Push to Connect Tee somewhere inline with the teflon tubing coming out of the OPV (from pump out)
Add a piece of 6mm fep (teflon) tubing to top of tee, add 6mm to 1/8 BSPT Male adapter to other end of tube.
Male adapter goes to Home Depot coupler, and pressure sensor into other side of coupler.
Wiring
+5V to Red, Ground to black, GPIO to yellow
Cut into the 6mm teflon tube out of pump, and added a T.
Pressure sensor to Home Depot FIP coupler to adapter, 6mm Tube OD, 1/8 BSPT Male.
First time I put it together it leaked, I had used teflon tape on the threads. Bought some thread sealant, Oatey Great White Sealant with PTFE. With that, no leaks
Three wires out of the pressure sensor. I spliced wires onto them to bring down to the ESP32
.8 to 18 ml/s, 3V
Try a USN-HS06P
.7 to 2.5 ms/s
Sensor: YF-S401
https://bc-robotics.com/shop/liquid-flow-meter-yf-s401/
Datasheet: outputs 5880 pulses per liter (approximately 1 pulse per 0.17mL
I measured it as 5298 pulses per liter, 1 pulse per 0.189ml. So I set the cal factor to 5.298
flowRate = ((1000.0 / (millis() - previousFlow)) * pulse1Sec) / calibrationFactor;
This is called about once per second.
pulse1Sec is number of pulses since last call
previousFlow is time in millis when they was last called
result is in ml/sec
Bought a 932-9505-B Flow Meter from ebay
There are many other similar models, I picked this one because it has the lowest linear flow rate, 0.033 l/min which is 33 ml/min or about 0.5 ml/sec
On the graph for this model, the highest flow shown is 0.4 l/min. Thats 400 ml/min or 6.7 ml/sec. Much faster than I would want a shot to flow at.
I figured a shot flows in a range of 20-40 ml in 30 secs. Easy math to use 30ml/30 secs or 1 ml/sec
Flow meter was added on the input side of the pump, between the pump and the water tank.
Horizontal position used, its when the contacts facing up
power supply +3.8 to +20 VDC
2382 pulses / liter
0.41 gr/pulse
May be able to find as replacement part for delonghi or other machines for less
Flow sensor at top of pic
Earthquake putty on it to stick to machine and hold in place.
The tube from water tank to pump used to go through a hole in the back of the machine. I drilled a hole in the front, you can see the tube going through it. Goes though here, to the flow sensor, then to the pump inlet.
Installed a 9 pin "D" connector on the back of the case to connect to the pressure and flow sensors, and to bring power to the other ESP32 and arduino.
Lets me easily remove the LCD case. I unplug the DC jack, two thermocouple connectors and this D connector.
Pin
1 Flow Sensor GPIO27
2 NC
3, 4, 5 Ground
6 Pressure Sensor GPIO36
7 +5 front switch pins 7&8 provide power to flow and pressure sensors
8 +5 front switch
9 +5 rear switch to top of machine to power ESP32 and arduino
After this picture, moved the rear switch to other side of yellow connectors to make it easier to access.
Case and Wiring
Bought the case and LCD bezel a long time ago
Don't remember where the case came from