# Silvia PID build



## iJim

Hi everyone!

New Silvia owner here... with a lot of time on my hands during lock down and a shiny new Silvia to play around with I decided to try build my own PID controller. I thought I'd post here what I came up with just in case anyone interested and may even like to club together to refine the system. I'm more than happy to share circuit details and code etc. Basically, I'm an electrical engineer, so the hardware is up to scratch, but the software still has a few bugs and I can think of many improvements I'd like to implement but don't have the skills! Apologies in advance for the long post, but here goes...

Within a couple of weeks of owning the Silvia I was already sick of temperature surfing and inconsistent shots etc, so I started looking into PID controllers and what options are available to buy. There seems to be a few options but they are quite pricey and I had a few requirements that they didn't quite meet: (1) as it's a new machine, I didn't really want to be drilling holes etc, (2) I'm short on space so didn't want a screen poking out from the side, and (3) I wanted a really simple install process that could be easily reversed if needed (machine is still under warranty, or at least it was until I messed with it!).

After studying the wiring diagram of the machine, I decided the simplest thing to do would be disconnect the brew thermostat and connect the wires to a solid state relay. This is my only change to the wiring inside the machine, literally moving two wires. I left the brew thermostat in place just in case I ever need to switch back. I left the steam thermostat in place for a few reasons, mainly because it acts as a safety net just in case my temperature control goes haywire (which it did many times during testing), this thermostat cuts power to the heating element when the boiler reaches steam temp no matter what my temperature control system is trying to do.

As I didn't want a screen on the actual machine, I decided to go with an (overcomplicated) web interface. The idea being that I can use my phone to connect to the machine via wifi and vary the temperature from the comfort of my own bed! It also gives me a nice display to plot graphs etc. One thing that crossed my mind was if the network ever goes down (which isn't that unusual) then I wouldn't be able to make a coffee if I relied entirely on my phone to control things. To get around this, I have the machine automatically go to a pre-set brew temperature as soon as it is powered on, while I can't change this temperature without a wifi connection it's fine for brewing and I can still use the steam switch to reach steaming temperature. In other words, the machine works just like any other Silvia if the network is down.

After some initial testing, I was happy enough with the performance and decided to get some printed circuit boards made, I even started work on a stand alone version with a screen and rotary encoder but have parked that for now as the web version works so well! Anyways, I've included a few photos and more details below...









This is the printed circuit board I designed, it uses an ESP32 development board, and include a thermocouple amplifier, voltage regulator and some level shifting resistors so I can connect a 5V contactless liquid level sensor (this is the white thing in the photo - it's not implemented in the software yet). I guess total price for everything (excluding water sensor) is around £30. The PCB's are really cheap (less the $1 per board), but the postage is $30 from china regardless of how many you order. I got ten, so have 9 spares. As you can tell from the photo, there's a couple of issues with the board design that needed fudging. If anyone wants a board let me know and I can send you one for the price of postage.









This is the web interface, the default brew temp is set to 102C (this is the temperature of the metal boiler, not the water coming out!), the slider lets me change between 90-110C. I only enable the PID control when the temperature goes above 85C, so warm up from cold is as quick as it possibly can be. What you can't see is in this image the second slider that sets the steam temperature, I have this set to 130C. Sliding the red button to the steam position causes it to heat up.









The temperature stability is pretty good, it stays within +/-1C of the setpoint. But there are actually quite a few improvements that could be made with the PID control, I've not had time to explore all of these yet.









All the electronics are in a box underneath the machine. By the way, when I said the cost of the PCB and components is about £30 I was ignoring the fact you also need a solid state relay and a DC power supply. You can get both these on amazon/ebay quite cheap, probably less than £10 combined. However, I'm very nervous about using these cheap knockoff components in a relatively high power application such as this, so I splashed out on a proper SSR from RS components (cost about £25) and a decent quality DC power supply (about £15).









I use this TP link smart plug to switch it the machine on before I wake up so it's ready to use straight away. I also get it to cycle the power every 29 minutes at the weekend when I'll have a few drinks over the space of a couple of hours. This prevents the energy saving relay nonsense from switching things off. I was very tempted to remove this power saving device, but this would be a major modification and I kind of like the idea of having the power go off after 30 mins should I ever forget to turn the machine off... I wouldn't want it on the whole day!









Finally, this is the small OLED screen I was working on, it's actually working to the point it could be installed and tested, but I lost enthusiasm for it as the web system has run for months without issue now&#8230; if it ain't broke why change it!

So all in all, I'm pretty happy with the machine now, it's making tasty shots and most of all they are consistent. When I next have some free time I'll get the liquid sensor installed and look into setting up some kind of pre infusion step (although this would require some further wiring changes I guess).

Cheers,

Jim


----------



## Mattius2

Great stuff. It's some time since I owned this machine but still have a soft spot for a PID mod and this is v skillful


----------



## Rincewind

@iJim Well done, i shall be following this thread closely....keep up the good work :classic_smile:


----------



## iJim

Thanks guys!

My next move will be to get the liquid level sensor setup. The only thing holding me back is that it needs sticking to the side of the tank, meaning once installed it'll be nigh on impossible to get the tank out without entirely stripping the case off. Shouldn't be a big problem, but I'm using a Britta filter with knock-off filter cartridges from amazon, they tend to spill a bit of carbon along with the filtered water. Not a massive problem but unsightly so I like to remove the tank and give it a good wash once per week! I really like the idea of the heating element not switching on if the tank is empty though, especially as I have the machine on when asleep!


----------



## 28267

@iJim what are you thinking of using for the water level sensor?

I've been contemplating building a replacement for the basic washing machine part used in the Silvia Pro. That triggers with no last shot protection and lots of water in the tank. The tank is the same as on the Silvia.

I'm thinking of a solution that needs two levels, Low and very low. Low would trigger low water if the brew pump is not running (i.e. no shot in progress) and as a safely very low would trigger instantly as a final protection. Leaving enough between the two should mean it doesn't ever trigger during a shot. The output would just match the existing sensor on the pro via a relay.


----------



## Rincewind

It's a shame there is no seperate "gully/tube/other" to keep a floating magnet *in a fixed area* so it rises up & down (but not sideways)...that way you could incorporate a few Hall effect sensors into the body (at different heights) right next to where the magnet would be rising and falling....perhaps a "tube" fixed in one corner of the tank say ??? ...just a thought.


----------



## phario

@iJim Great work!

Some questions if you don't mind?



Quite intriguing to store under the machine! I don't think I've seen a Silvia PID build with that idea. Most people prefer storing near the pump. Any reason why you didn't do it within the main compartment?


What did you end up using for a temperature gauge?


The thing that bugs me about Wifi connectivity is the fact that it makes the physical switch obsolete. Am I correct in assuming that you have it switched on all the time, and if you want to manually switch it on and off while in front of the machine, you reach instead for the TP Link controller? Basically I would want a WiFi setup where all the Silvia switches are still functional but now with additional option of Wifi. Could you do that with a retractive button?


----------



## iJim

@AdG For the water level sensor, I bought a non-contact capacitive sensor from Amazon (~£15), they work great and can be mounted on the outside of the tank. There's actually a photo of it in my first post, it's a white cylinder about an inch in diameter. I didn't really fancy having something floating in the tank, I was just planning to use some double sided tape to hold it in place. Here's the link: https://www.amazon.co.uk/gp/product/B088PGKPJ4

One drawback with the sensor is that there's little data available on how to connect it. I spotted it was a 5V device which could be a problem for my esp32 microcontroller (3.3V io), but I factored this into the PCB design. What I subsequently learnt is that it has an npn output so it needs a resistor between the output wire and the 5V power source. Annoying, I had to fudge extra wires on the board to make it work.

@Phario, there are a few reasons I avoided putting everything within the case. Firstly, it's a new Siliva so it has this enormous 'CPU' (I think that's what they call it in the manual), which basically takes up most of the free space. It's a big encapsulated block that has many wires going in/out of it, annoying as all it appears to do is cut the power off every 30 minutes! If that wasn't there I would have definitely housed everything inside. My original plan was to house all the 240V items inside for safety and just have the microcontroller on the outside; unfortunately, there wasn't even enough room for the relay inside, well there was but it would have required drilling new holes to mount it. I don't really like the idea of having live terminals on the outside of the machine, but they are shrouded, they are also hard to access being underneath, plus I'm the only one that uses the machine, so the chances of there being an issue are slim [I just have to remember not to put my fingers under it when it's on!].

The temperature gauge is an interesting one, I tried to go too fancy and use a DS18B20, which is a digital thermometer and really easy to use with a microcontroller. I tested it extensively and was happy enough to epoxy the bloody thing to the boiler. What I had conveniently ignored was the 125 C max operating temperature... not a problem when I was setting up the PID for brew temperature, but one hell of a problem when I tried to steam some milk! After this, I opted for a k-type thermocouple, which is good up to 1300 C  The drawback is less accuracy, +/- 1.5C and the need for some additional electronics to condition the signal. I went with the MAX6675 and made space for it on the PCB.

In terms of wifi, I decided right at the start that I wanted the machine to operate as if it had never been modified, even if the wifi doesn't work. Basically, at the moment, all my controller does is heat the machine up to 102C (which is around 96C water temp out of the group head), without wifi that's all it'll ever do. You still need to press the brew button to activate the pump. You can also press the steam button on the machine, this short-circuits the relay and uses the steam thermostat. In other words, someone using my machine would not know it even had the PID in there, it operates just as intended. Using my phone and wifi, I can vary the brew temperature and I can set it up at 130C (or whatever) for steaming, which makes pressing the steam button redundant.

The TP link plug is not linked to the controller, it just switches the power on to the machine 15 mins before I wake up. I should also add, that this functionality is exactly why I didn't use a Raspberry Pi! A Pi takes time to boot up and needs to be shutdown properly etc, which requires a touch screen or mouse etc... way too much hassle, my controller is ready to go in seconds and is doesn't get corrupted when the mains power is cut!

Cheers,

Jim


----------



## Rincewind

iJim said:


> @AdG For the water level sensor, I bought a non-contact capacitive sensor from Amazon (~£15), they work great and can be mounted on the outside of the tank. There's actually a photo of it in my first post, it's a white cylinder about an inch in diameter. I didn't really fancy having something floating in the tank, I was just planning to use some double sided tape to hold it in place. Here's the link: https://www.amazon.co.uk/gp/product/B088PGKPJ4


 I'd forgotten all about these....good find....waaaaaay cheaper than the ones i saw yonks ago :classic_smile:


----------



## iJim

phario said:


> @iJim Great work!
> 
> Some questions if you don't mind?
> 
> 
> 
> Quite intriguing to store under the machine! I don't think I've seen a Silvia PID build with that idea. Most people prefer storing near the pump. Any reason why you didn't do it within the main compartment?
> 
> 
> What did you end up using for a temperature gauge?
> 
> 
> The thing that bugs me about Wifi connectivity is the fact that it makes the physical switch obsolete. Am I correct in assuming that you have it switched on all the time, and if you want to manually switch it on and off while in front of the machine, you reach instead for the TP Link controller? Basically I would want a WiFi setup where all the Silvia switches are still functional but now with additional option of Wifi. Could you do that with a retractive button?


 Sorry, was half asleep last night and totally forgot that the very first modification I made was to swap out that intermittent pushbutton power switch for something latching. So yes, you're absolutely right. The front power button is on all the time, and the TP link switch is used to turn the machine on and off. I don't mind this as the smart plug has a pushbutton that is in easy to reach so I can still turn it on by hand (I also have a smart speaker, so can just ask for it to be switched on). It would be an easy mod to have it so the front switch actually controls the power into the machine, but it would involve snipping a few wires so opted not to do it.


----------



## 28267

@iJim - Thanks, just taken a look and they could be good. I can also seem some similar ones setup to work with Arduino / Pi on Farnell and The Pi Hut at a good price so might have a play with them to workout a control system. One of those had 5v/3.3v switch and looked like the same sensor as you had so looks like it shouldn't be too hard to get to work on the lower voltage.


----------



## Jordash184

This is a cool project. I'm looking to do something similar with mine. I could be in the market for one of your spare boards!


----------



## Mart1512

I always felt that you could do a bit more clever stuff than a standard PID mod, like looking at when the pump gets switched on and setting the output to 100% for example. I like this project lots and have wanted to have a steam setting with my PID setup but we use the original steam switch.


----------



## iJim

@Mart1512 I was thinking the same... I don't like seeing the temperature plummet when you hit the brew switch, it takes a few degrees drop before the PID begins to compensate. At the minute, as soon as I hit the brew switch on the machine, I tap the steam switch on my phone. This basically puts the heater on full whack as the set point increases ~30C. It's still not enough to stop the temperature dropping, but without doing this you can drop 10-15 degrees over a 30 second shot! There are quite a few other things that could be done (if you're willing to start cutting wires). I saw a video of someone that implemented a PID controller to maintain a constant pressure whilst brewing. I guess they pulse modulated the pump to achieve this, although the video was only 30 seconds long with no details. I even identified a suitable digital manometer for about £50, but electronics are my bag, not plumbing, so I chickened out.

One thing I urgently need to fix though is the IP address, I have it dynamically allocated at the moment, which is fine, but every few it changes and I have to log into router to find the new address. 8 o'clock this morning was one of those times, not what you need when you're half asleep and you just want your coffee!

@Jordash184 Happy to send you a board, you'd need an ESP32 dev board with the same pin out as the one I used, they are a about £6 on amazon (I got three for £19 - https://www.amazon.co.uk/gp/product/B08DXSMZSB/ ). It's programmed in Arduino IDE and I'm happy to share the pretty amateur code! You'd also need MAX6675 thermocouple amplifier, these are about £10 from RS. They are minuscule surface mount devices, if you're not practiced in soldering smt components then buying a pre-soldered board from amazon might be easier, but not as compact ( https://www.amazon.co.uk/DollaTek-MAX6675-Interface-Thermocouple-Temperature/dp/B07DK8VG87 ).


----------



## Mart1512

@iJim Interesting, my PID is set to recover very quickly, so we can do two brews/flush the head without waiting for ages, but there is a fair bit of overshoot, so it's a bit of a manual process involved and keeping an eye on the temps still, this would overcome my issues.

Plumbing is the same as electricity with water, give it a go what's the worst that could happen, but that could be an interesting addition if it worked.

I never realised the newer machines has a 30m power off, something we need at times.

How about fixing the ESP32's IP address in the router to be static if you can?, that would be my first choice.


----------



## Jordash184

iJim said:


> @Mart1512 I was thinking the same... I don't like seeing the temperature plummet when you hit the brew switch, it takes a few degrees drop before the PID begins to compensate. At the minute, as soon as I hit the brew switch on the machine, I tap the steam switch on my phone. This basically puts the heater on full whack as the set point increases ~30C. It's still not enough to stop the temperature dropping, but without doing this you can drop 10-15 degrees over a 30 second shot! There are quite a few other things that could be done (if you're willing to start cutting wires). I saw a video of someone that implemented a PID controller to maintain a constant pressure whilst brewing. I guess they pulse modulated the pump to achieve this, although the video was only 30 seconds long with no details. I even identified a suitable digital manometer for about £50, but electronics are my bag, not plumbing, so I chickened out.
> 
> One thing I urgently need to fix though is the IP address, I have it dynamically allocated at the moment, which is fine, but every few it changes and I have to log into router to find the new address. 8 o'clock this morning was one of those times, not what you need when you're half asleep and you just want your coffee!
> 
> @Jordash184 Happy to send you a board, you'd need an ESP32 dev board with the same pin out as the one I used, they are a about £6 on amazon (I got three for £19 - https://www.amazon.co.uk/gp/product/B08DXSMZSB/ ). It's programmed in Arduino IDE and I'm happy to share the pretty amateur code! You'd also need MAX6675 thermocouple amplifier, these are about £10 from RS. They are minuscule surface mount devices, if you're not practiced in soldering smt components then buying a pre-soldered board from amazon might be easier, but not as compact ( https://www.amazon.co.uk/DollaTek-MAX6675-Interface-Thermocouple-Temperature/dp/B07DK8VG87 ).


 Awesome, thanks iJim, that's brilliant. I'm happy to have a go at surface mount soldering, done it quite a bit previously. I'll send you a PM with my details.


----------



## 28267

Mart1512 said:


> I always felt that you could do a bit more clever stuff than a standard PID mod, like looking at when the pump gets switched on and setting the output to 100% for example. I like this project lots and have wanted to have a steam setting with my PID setup but we use the original steam switch.


 Not sure on the PID programming Rancilio have used on the pro, but the temperature is very stable when you pull a shot.

The only time I've seen it drop even one degree is when I was setting the grinder up and was way off so got a gusher of a shot.

As the boiler and heating element is the same as the Silvia it should be possible to keep the temperature stable with the right programming.


----------



## iJim

Interesting! From the sounds of it, I think there are a few things to improve in my code.

My PID settings could certainly be improved, there's barely any overshoot at the moment which is a sure sign the settings are too conservative. Also, I've seen plenty videos of PID's on the Silvia where the heating element lamp appears to flicker because it's being switched so quickly. I'm not sure if this risks prematurely damaging the element. To play it safe, my code spends 500 ms reading the temperature during which time the element is off (basically five reads from the thermocouple amp, with a 100 ms delay after each), then the PID calculates the on-time which can be either 0 (when over temp), or anywhere between 100 - 2000 ms. After this two second period the code repeats. I'm beginning to think a 2.5 second control loop is way too slow... I thought a big block of insulated metal would have quite a lot of thermal mass and it's temperature would change slowly, but pumping in cold water certainly speeds things up! I also don't like the fact that the 0.5 second read-time basically limits my max duty cycle to 80%. The ESP32 microcontroller is dual core so it's possible to have one core handle the temperature reads (and wifi etc), while the other core just handles the PID, but getting this up and running will probably take some time!


----------



## Mart1512

AdG said:


> Not sure on the PID programming Rancilio have used on the pro, but the temperature is very stable when you pull a shot.


 I wonder where the thermocouple is in the pro, is it built into the boiler?


----------



## 28267

@Mart1512 - The top of the boiler is slightly different, the outlet for the steam wand is missing and the thermocouple is just next to that where you probably have a blank circle.

Below is the image from https://www.talkcoffee.com.au/rancilio-silvia-pro-first-impressions/


----------



## iJim

Interesting, it seems like the thermocouple goes directly through the boiler wall on the Pro. This will definitely improve response time, also I guess the measured temperature will be a lot closer to what you actually get out of the group head.

A few years ago, I put a thermowell in the side of a 40L tea urn for brewing beer... it was a right pain, constantly leaking, so I'm not even slightly tempted to try it on the Silvia boiler given the high pressure operation! 😅


----------



## Mart1512

That would make the PID work so much better being inside the boiler.

@iJim that reminds me I need to brew some beer in my tea urn soon.

Running your loop at 5hz would be fine, the heater will even thank you for it, the thing that will probably damage it is the heating/cooling cycle and the constant expansion the element undergoes, running the loop at a faster speed will reduce the amount it expands and gets stressed.


----------



## bpgoa

I've been reading this forum for a while now, and yesterday pulled the trigger on a 2nd hand Silvia v3 espresso machine.

I'd read the issues with the wide band of hysteresis on the bimetallic switch used on this system, and considered using a small microcontroller running a PID loop (or two) to solve some issues. I have a little experience of this, having written something similar using PlatformIO and an esp8266 for my smd reflow oven.

I never got round to creating a dedicated board, although I can say that the cheap SSR's work well and higher frequency switching does indeed stress the heating elements far less. I solved the networking issues in two parts. The first was to run a simple implementation of mDNS (bonjour) to advertise itself with a ".local" address, and secondly, if it lost network connection (and for initial configuration) to start in AP mode. Until I read your post, I was thinking about a simple triac circuit for switching and using the LMT01LPG temperature sensor, Datasheet Arduino (solid to 150c). I also wanted a display to show current settings and position in the workflow.

If you are considering open sourcing this work, I would love to get involved.

A.


----------



## iJim

bpgoa said:


> I've been reading this forum for a while now, and yesterday pulled the trigger on a 2nd hand Silvia v3 espresso machine.
> 
> I'd read the issues with the wide band of hysteresis on the bimetallic switch used on this system, and considered using a small microcontroller running a PID loop (or two) to solve some issues. I have a little experience of this, having written something similar using PlatformIO and an esp8266 for my smd reflow oven.
> 
> I never got round to creating a dedicated board, although I can say that the cheap SSR's work well and higher frequency switching does indeed stress the heating elements far less. I solved the networking issues in two parts. The first was to run a simple implementation of mDNS (bonjour) to advertise itself with a ".local" address, and secondly, if it lost network connection (and for initial configuration) to start in AP mode. Until I read your post, I was thinking about a simple triac circuit for switching and using the LMT01LPG temperature sensor, Datasheet Arduino (solid to 150c). I also wanted a display to show current settings and position in the workflow.
> 
> If you are considering open sourcing this work, I would love to get involved.
> 
> A.


 Hey bpgoa,

Sounds interesting! I'm really keen to make the project open source as there are many aspects that could be improved, I'm definitely not a programmer and the code is a real cut and paste job from many different online examples etc. I just need to figure out how setup an open source project (GitHub is the obvious choice, but I've never used it before - will look into it). I certainly think it would be great if a few people could chip in to really develop the project into something that matches the commercial versions in terms of functionality (and cost). Actually, this was one of the reasons I made the initial post!

When your Silvia arrives and you get a temperature probe on the boiler you will immediately see the need for the PID... If I remember correctly, the temperature rises well above 115C before the brew thermostat switched, which is a bit of a disaster for brewing! The LMT01LPG looks interesting, it would do away with the need for a thermocouple amp, which is one of the most pricey items on the board. My only slight worry would be the peak temperature reached if relying on the steam thermostat, I bet this isn't far from 150C!

Regarding the network connection, I'm just being lazy by not giving it a fixed IP, I can probably do this just on the router using the MAC address. Other than that it's been rock solid, which is surprising given that the ESP32 is under the machine hence surrounded by metal on 5 sides!

One thing I never really looked into was my SSR, I just assumed it was TRIAC based and can only switch at the zero crossing point. To be safe I limited the minimum on time to 100 ms (or maybe 200 - I forget) with a maximum of 2 seconds, this is certainly too slow. From a few videos I've seen online the brew light (indicating the boiler is powered) is flickering almost too fast to see, so the control loop must be running 10+ times per second. Actually, a major update to the code would be to use the OTA programming functionality, although I'm not sure it is compatible with the webserver. If it could be made to work all of these settings could be tweaked quickly without having to drag my computer to the kitchen and faff around connecting a cable every time I want to change a setting!

Once I figure out how to share the source files and circuit/pcb designs I'll give you a shout.

Cheers,

Jim.


----------



## dave1138

Hi - which thermal glue/paste did you use to stick the probe onto the boiler? My auber pid is nearly 10 yo and the glue has nearly turned to dust.


----------



## iJim

Hi Dave,

I glued my original temperature sensor (a dsb18b20) using 'Phobya 2-component thermal glue' that I found on Amazon:

https://www.amazon.co.uk/gp/product/B005EOB2HC/

I was surprised to find it on Amazon, as RS had few options for thermally conductive epoxy and it was really expensive (and toxic). God knows what's in the stuff from amazon, there are hardly any details.

When the sensor broke, I just left it attached but now use a thermocouple... I just wrapped the tip in a bit of Kapton tape and wedged it between my boiler and it's foam insulation, not ideal as it's not actually fixed but I can't imagine it'll move.

Cheers


----------



## iJim

Apologies for the double post, but I started a project on GitHub:

https://github.com/jimmy142/Silvia-PID

The only thing that's missing at the moment is the code! It's on my laptop that I left in the office, will upload asap.


----------



## Rincewind

iJim said:


> I started a project on GitHub:


 👏 Well done Jim...i look forward to seeing the code added.....keep up the good work ✊


----------



## newdent

Hi Jim

Looking like you've done a great job here. I also like the idea of it being mounted underneath assuming it's safe as I usually get the counter wet near the coffee machine!

I'm keen to have a crack at this. Could you send me a board please? I'm no professional programmer but have studied a few basic programming modules at uni in VB, C and Python (and I'm familiar with html if the web stuff needs tweaking), so happy to have a crack at helping out if you want? My electronics aren't great, is there any limiting factors on running the loop a bit faster than 2s? Cheers!


----------



## luiccn

I've also built a PID and power controller for my V6 Silvia E. My code is in a fork of this.


----------



## iJim

newdent said:


> Hi Jim
> 
> Looking like you've done a great job here. I also like the idea of it being mounted underneath assuming it's safe as I usually get the counter wet near the coffee machine!
> 
> I'm keen to have a crack at this. Could you send me a board please? I'm no professional programmer but have studied a few basic programming modules at uni in VB, C and Python (and I'm familiar with html if the web stuff needs tweaking), so happy to have a crack at helping out if you want? My electronics aren't great, is there any limiting factors on running the loop a bit faster than 2s? Cheers!


 @ Newdent, sure, message me with your address.

@luiccn, thanks for heads up. Your code looks good and the GUI is a lot nicer than mine!! I initially wanted to use a Pi (I even bought a zero-W), but the idea of having to wait for it to boot up and then shutting it down properly put me off a bit. The ESP32 is great as it works almost instantly and you can just cut the power with the machine, the downside is the lack of options for a GUI etc.


----------



## luiccn

@iJim indeed, my Pi just runs all the time so no problems with boot time. I think Arduino would give you a bit more possibilities.


----------



## Rincewind

One downside i found with the ESP32 is the high failure rate....out of 30 on one occasion 7 of them were D.O.A. ....on another occasion it was roughly half of them were D.O.A....it seemed to depend on where they were sourced from that determined if they had a good chance of being ok or a good chance of failing (within hours/days) or just D.O.A......it seemed the really cheap priced ones were total pants....wasn't my money but still demoralising to students who sometimes blamed themselves instead of the garbage made product.


----------



## iJim

Yikes, I've not had any DOA yet, but I've only used 3 or 4 of them on various projects over the last few months. I guess almost any microcontroller with wifi would be work fine, but as far as my (limited) experience goes you can't beat the ESP32 on features/cost... I even used one to read my heart rate monitor using Bluetooth low energy and have It vary the speed of a fan when I'm on my exercise bike, they're pretty cool!


----------



## Rincewind

@iJim it worked out the dearer we paid for them the more reliable they were..go figure...totally agree on the functionality per cost; makes them very appealing.

Your project ☝sounds like a poor-mans Ant+ dongle lol...have you put up on GitHub ?


----------



## bpgoa

@ijim Thanks for posting up all the schematics and code onto GitHub. Now that we are on the Easter holiday's, I'll get a chance to run through and have a look. I know this is a little cheeky, but would it be possible to get hold of one of your boards? I'll happily pay for it/ postage.

Cheers A.


----------



## iJim

bpgoa said:


> @ijim Thanks for posting up all the schematics and code onto GitHub. Now that we are on the Easter holiday's, I'll get a chance to run through and have a look. I know this is a little cheeky, but would it be possible to get hold of one of your boards? I'll happily pay for it/ postage.
> 
> Cheers A.


 Sure, it'll probably be next week before I can post the board though.

Drop me a message with your address and i'll sort it out.


----------



## bpgoa

Thanks... I dropped you a PM, and set a watch on your GitHub page. I'm interested in how you would like to further develop this, and how I can help you? Also, where/how you want those discussions to take place?

I have a little embedded experience (mostly Keil, but have dabbled with Mbed, PlatformIO and Arduino), and also a microelectronics background. Though, TBH, I have spent most of my career managing.


----------



## iJim

bpgoa said:


> Thanks... I dropped you a PM, and set a watch on your GitHub page. I'm interested in how you would like to further develop this, and how I can help you? Also, where/how you want those discussions to take place?
> 
> I have a little embedded experience (mostly Keil, but have dabbled with Mbed, PlatformIO and Arduino), and also a microelectronics background. Though, TBH, I have spent most of my career managing.


 I got the PM cheers, will get back to you shortly (I'm tapping this out on what feels like my death bed, got vaccinated yesterday and feeling rough as today!)...

As for how to further improve it or even where to discuss it, I didn't think so far ahead! I've never really done anything like this before so am definitely open to suggestions! For sure the code is really clunky and I'm sure someone with more experience than I could make a much better job. Certainly being able to set the PID settings from the webpage would be useful (and a pretty easy thing to do). I'm more experienced in the hardware side of things so have loads of ideas of what could be done, just not sure when I'll get around to it. I let the bloody thing run dry yesterday, so getting the liquid level sensor setup is a must. Fortunately, I already made space on the PCB for it (as the sensor is 5V and the i/o on the ESP32 is 3.3.V). There's also pre-infusion that could be setup. I like the idea of monitoring / controlling the pressure too, but don't like the idea of cutting pipes etc.


----------



## bpgoa

Ah! Yes... a few have had that reaction... hope you are feeling better today!

I ordered up all the hardware that I didn't have and a few bits landed today including the sensor. The ESP32 has so much grunt, that as long as we modify the code to be non-blocking, it'll be more than man enough for the job. It was a great choice.

I'm really interested in adding a little display! To show what's going on, but less so in adding extra controls. As you hinted, it should just work when switched on and not require you to get your browser out. I think using a web page for configuration would be my preference and, depending on where the project ends up, consider repurposing the existing buttons to interface.

I'm also lucky enough to have a reasonable workshop, so if needed, making new pipes shouldn't be too hard or expensive!. However... the pressure sensor cost may make our eyes water.

For pre infusion, we will need control of the three-way valve, as the pressure will need to be maintained during this phase...

Anyhow, loads to think about, probably should have a chat at some point..

A.


----------



## Daniel R

Hi,

I'm also doing a DYI PID on ESP32. Coding in MicroPython.

Wondering why you are not using PID under 85C? The proportional will just give 100% power when the boiler is cold.

May eventually post on GitHub, but have so far posted some PID code on the MicroPython forum, with anti integrator windup.

First step was to just get temperature control. Steam switch as digital in to change target temp. A bit crude:









The next step will be a bit more ambitious. Some more components









PSU, 2 SSR and a pressure sensor. The pressure gauge attached to the original portafilter holder will only be used to calibrate the sensor. Plan to remove the OPV.

Plan to completely re-wire the machine, fit all components inside and connect the switches as digital ins. A pretty major job, that will take some time to reverse. So, a bit hesitant.

Final step could be to integrate a weight sensor under the drip tray or a BLE scale. The Acaia Lunar has documented API, but costs more than what I payed for my Silvia.

Daniel


----------



## iJim

Daniel R said:


> Plan to completely re-wire the machine, fit all components inside and connect the switches as digital ins. A pretty major job, that will take some time to reverse. So, a bit hesitant.


 Hi Daniel,

Looks good! You're braver than me going for a full re-wire. Have to admit I fancied doing it, but I just couldn't bring myself to completely strip down a brand new machine. If I ever do it though, that stupid power saving module is going in the bin immediately!

Are you going to control the pressure or is the sensor just for monitoring? After a water level sensor that would be my next upgrade.

As for my PID settings, basically I originally wrote the code for beer brewing in a 50L boiler and couldn't be bothered to spend too long tuning for the new setup. The performance seemed ok with a bit of playing around, although the settings are way too conservative hence the fudge below 85C.

cheers

Jim


----------



## Daniel R

Yep, will try to implement pressure profiling.

Vibratory pumps seems a bit tricky to control. It has a diode, so that every half cycle is a stroke. I read that having a 250k resistor across the SSR is required for it detect the zero crossing (and work correctly).

Will make sure that I can control pump power before installing the pressure sensor and removing the OPV.

Not sure when I will continue this project. Will probably wait until my wife and kids are traveling, so that I have more time available. Would hate to be without good espresso for longer than necessary.

Also, I have not properly tuned the PID. Just using the proportional for now. Oscillates a bit, but within 1C.

Daniel


----------



## phario

Daniel R said:


> Plan to completely re-wire the machine, fit all components inside and connect the switches as digital ins.


 Hi Daniel,

I was actually most curious about this! Can you say more? What rewiring changes would you do? What is a digital in?


----------



## Jordash184

Sorry this is a bit of a necro post. iJim, how are you getting on with your PID. I'm at a point where I want to install this in my Silvia. I just need to order the parts. What psu did you use inside your machine?

Thanks.


----------



## Jordash184

I have now managed to get mine up and running. It seems a little awkward, so I've been working on the code a little. But it does work and it keeps the temperature very stable, so thank you very much for sharing the project with us.


----------



## iJim

Jordash184 said:


> I have now managed to get mine up and running. It seems a little awkward, so I've been working on the code a little. But it does work and it keeps the temperature very stable, so thank you very much for sharing the project with us.


 Hey,

Sorry for the slow reply, I've been away for a couple of weeks. Glad you got things up and running... the code is probably terrible, I only did very basic coding projects prior to embarking on this one (with the web interface etc, it was much more advanced than anything I did previously). Did you manage to make any improvements to it? I've been lazy and haven't touched it since first install, it's working 'good enough' for now.

When I can be bothered I need to tune the PID better, the temperature is really steady when not pulling a shot, but drops quickly as soon as water flows, I've seen DIY controllers perform much better than this. To overcome it, I have to quickly switch to steam mode on my phone, this holds the temperature more or less steady while pulling a shot.

Cheers,

Jim

p.s. I ordered RS#144-6269 (AC-DC Converter, 5V dc, 4.1A, 20.5W Encapsulated) for the power supply. It's totally overkill, but as I knew I'd be switching the machine on while asleep or outside, I wanted something I could trust!


----------



## Jordash184

iJim, no worries.

I've done a few bits and pieces. I added OTA updates, which means I can update the firmware without needing to plug the ESP into a PC, very helpful since it's totally inaccessible inside my machine! I had all sorts of issues when I first started playing with the code. In particular it would come out of the loop and just turn the boiler on. One time I didn't realise this is what it had done and it tripped the thermal cutoff on the boiler itself.

Since then I have just made small tweaks and improvements. There's definitely something no quite right because it won't turn the boiler on for more than half the time. I tackled this with adding a couple of while loops to turn the boiler on to 88C (like you did), and then again to 120C when the steam mode is selected in the app.

I've also separated out the CSS into it's own file. Then I added PID adjustments onto the main screen, but I haven't really played with this.


----------

