Sciencemadness Discussion Board

Remotely monitored distillations using a Pi

Big Boss - 16-2-2018 at 16:30

I have managed to remotely monitor distillations using a Raspberry Pi, a £2.55 waterproof temperature sensor, RF controlled plugs and an equally as cheap 433MHz transmitter and receiver set.
Works really well, I managed to distill ethanol in my garage remotely from my house several times. I only needed to visit the garage to change the sugar wash in the boiling flask.
The temperature sensor was wired up to the Pi after soldering a 4.7k resistor between data and vcc.
The remotely controlled socket was a bit more difficult, I had to connect a 433MHz receiver to the Pi then press the On and Off buttons that was provided with the sockets in order to sniff the codes sent by the remote.
Once I had the codes which the remote uses to toggle the plug on/off I could attach the DS18B20 temperature sensor to the Pi along with the 433MHz transmitter. I then plugged in my 3G dongle in order to connect to my Pi in the garage as the WiFi doesn't reach there.
Then I wrote a couple of simple python scripts allowing me to fetch the temperature of the sensor, turn the plug on and off and log the temperature and time every 3 seconds. Finally another script which would repeat a cycle of switching the hotplate on for 60 seconds, then off for 30 seconds whilst the temperature was less than 98°C

Hotplate.jpg - 53kB
After I wrote a script that converted the data into an Excel document then plotted a graph of each of the distillations.
The first one was the distillation of the sugar wash
1.jpg - 60kB
Then, as it became more concentrated
2.jpg - 80kB
The vapour temperature slowly creeps down to 78 after a few distillations meaning we have reasonably pure ethanol.
3.jpg - 77kB
This is a small proof of concept and I know my apparatus is pretty ghetto but this could be massively scaled up for example for fuel distillation.

[Edited on 17-2-2018 by Big Boss]

NEMO-Chemistry - 16-2-2018 at 16:38

seriously cool project

ninhydric1 - 16-2-2018 at 16:50

It would be handy if we could set this up so that when the distillation reaches a certain temperature, it shuts off the heat source, stopping the distillation. Then distillations could complete without having a person attend it. It wouldn't be useful if, for ex., the distilling flask starts sludging up the adapter, because the distillation would be ruined.

NEMO-Chemistry - 16-2-2018 at 16:55

Quote: Originally posted by ninhydric1  
It would be handy if we could set this up so that when the distillation reaches a certain temperature, it shuts off the heat source, stopping the distillation. Then distillations could complete without having a person attend it. It wouldn't be useful if, for ex., the distilling flask starts sludging up the adapter, because the distillation would be ruined.


Thats pretty much what he has done, what your asking for is a couple of lines of code, if he can do what he has, then adding the lines like you asked is real easy.

The hard part of this project was setting up the comms, the rest is libs from python mainly.

[Edited on 17-2-2018 by NEMO-Chemistry]

Big Boss - 16-2-2018 at 17:00

I have done that, I'm not sure why you think I didn't implement that but yes whenever the vapour temperature reaches 98C I send the off RF signal to the socket twice.
And you're absolutely right Nemo, in fact here is the code for my main script. It's ridiculously simple.



NEMO-Chemistry - 16-2-2018 at 17:10

Quote: Originally posted by Big Boss  
I have done that, I'm not sure why you think I didn't implement that but yes whenever the vapour temperature reaches 98C I send the off RF signal to the socket twice.
And you're absolutely right Nemo, in fact here is the code for my main script. It's ridiculously simple.




I think he misunderstood the off part, what I was trying to say was, once you can communicate with the pi remotely, then the switching on and off is entirely upto you.

You could do ultra fine PID controlled fractional distillations, or add a pump to auto top up, the hard part is getting comms when you cant get a wifi :D.

nice way around that BTW :D.

Is it the PI3? I got a couple of 2B's, I am thinking of getting the 3, with that you can stick the OS on a USB drive from start up!!

So no card needed at all!! i get through cards on the pi2.

No end to tweaks you could do now. But great project, i like that alot.

Big Boss - 16-2-2018 at 17:21

Yep it's the Pi 3, I didn't even know you could load an OS from the USB with the 3 that's pretty neat. nice suggestions btw they would be really easy to do, I got 3 remotes from ebay for £13. I didn't even need to write a lot of difficult code either, the hard part was trying to solve the issue of noise from the cheap RF receiver so I could decode the signals. Have a look at the rpi-rf library if you're interested.

NEMO-Chemistry - 16-2-2018 at 17:38

Quote: Originally posted by Big Boss  
Yep it's the Pi 3, I didn't even know you could load an OS from the USB with the 3 that's pretty neat. nice suggestions btw they would be really easy to do, I got 3 remotes from ebay for £13. I didn't even need to write a lot of difficult code either, the hard part was trying to solve the issue of noise from the cheap RF receiver so I could decode the signals. Have a look at the rpi-rf library if you're interested.

I hand rolled my comms, I can get 6KM out of mine.

I will find the link for the start up code for you, its the best bit of the pi3. It boots the pi directly from a usb hard drive (external one), dosnt go near that awful card slot.

I will go through my libs see what I got that might interest you. Add a K type sensor to the plate, that way you could fine tune the temp so it distills higher concentrations in a single run.

Although your system seems spot on and this would be adding shit for the sake of it. But temp control on a column opens up some interesting ideas.

I will get a 3, i dont leave distillations alone. I am too good at starting fires, i could start a fire under water with a wet match!

But I happen to have something else that a PI would be a nice solution.....

Yeah ok if you dont mind sharing the libs, thx for heads up on the noise, I will stick a band pass filter on, its really noisy around here with turbines etc.

Mad that it beats wifi!! I got a old router meant for sim card and text message control, but you can control it via the router signal.

Hmm loads of ideas, its far from ghetto!! Actually I think its pretty clever to switch off based on the temp rise, no need to mess with a level sensor.

Add a servo on the tap of an addition funnel, then when the temp starts to budge get the servo to drip more in the pot. use a big enough pot and you should be able to do shit loads by addition.

ficolas - 16-2-2018 at 18:26

Really cool, I am working on something similar and more extensible, but the project is going very slow mostly because of a lack of time.
An idea, by storing the temperature values, and a way of telling how much distilate comes over, like a balance, you coul make a small script to stimate the concentration of the distilate

[Edited on 17-2-2018 by ficolas]

Sulaiman - 16-2-2018 at 18:30

Great project ... well done. :cool:

Does the controller in the garage sequence down power if communications are lost ?

How would you know if your garage is on fire ? :o

Big Boss - 16-2-2018 at 18:51

Haha nope it only shuts off the hotplate once it reaches 98C, I always have a terminal window sitting on my desktop when I have a distillation running so I can make sure it turns off. Then afterwards I monitor the temperature and it drops so I know the socket is off.

aga - 17-2-2018 at 00:33

Excellent work !

Very impressive. Love the graphs.

Quote: Originally posted by ficolas  
Really cool, I am working on something similar and more extensible, but the project is going very slow mostly because of a lack of time.

Yep. Same here. Only been about 4 years so far and hardly any progress.

One device i had in mind was a servo, so the vac adapter could be moved between a waste container and the collection bottle.

That was specifically for ethanol to automatically discard everything below 78 C, collect the main flow, then discard any higher boiling components.

Big Boss - 17-2-2018 at 04:47

Quote: Originally posted by ficolas  

An idea, by storing the temperature values, and a way of telling how much distilate comes over, like a balance, you coul make a small script to stimate the concentration of the distilate

Good idea, I was thinking about comparing it to a table of boiling points for ethanol water mixtures but I can't find good data. How would you go about estimating concentration with those temp values and the mass of the distillate?

Sulaiman - 17-2-2018 at 07:29

Fermentation and distillation are well covered here https://homedistiller.org/calcs/reflux_calc
and other pages on that site.

VSEPR_VOID - 3-3-2018 at 00:46

The best part about science is the cool graphs

Sulaiman - 3-3-2018 at 03:16

Quote: Originally posted by aga  
Excellent work !

Very impressive. Love the graphs.

Quote: Originally posted by ficolas  
Really cool, I am working on something similar and more extensible, but the project is going very slow mostly because of a lack of time.

Yep. Same here. Only been about 4 years so far and hardly any progress.

One device i had in mind was a servo, so the vac adapter could be moved between a waste container and the collection bottle.

That was specifically for ethanol to automatically discard everything below 78 C, collect the main flow, then discard any higher boiling components.

I too have been considering semi-unattended fractional distillation;
I do not know compatibility with ethanol,
but you could use from this https://www.ebay.co.uk/itm/Mini-2-Position-3-Way-Electric-Co...
to a more reliable central heating diverter valve
e.g. https://www.ebay.co.uk/itm/Honeywell-V4073A1039-3-Port-Mid-P...
with loads of options inbetween
https://www.ebay.co.uk/itm/DC-12V-1-2-Electric-Solenoid-Valv...
http://www.ebay.co.uk/itm/Motorized-Ball-Valve-Brass-220v-3-...
https://www.ebay.co.uk/itm/DC-12V-3-Way-NO-NC-Solenoid-Valve...
https://www.ebay.co.uk/itm/HSH-Flo-1-2-3-Way-T-Port-Brass-Mo...

The most fool-proof scheme I've conceived of so far is to have the liquid distillate flow
through a tee piece to the heads/tails collection vessel, with venting
with a normally closed valve beneath the tee piece
that opens to collect the wanted fraction.
O.K. for ethanol, or where only one fraction range is required.

For ethanol, I would want to see the still operating stably before relying on automation,
for a fractionating still this would take quite a while,
so waiting for foreshots/heads would not add much extra time,
and you would 'feel' safer leaving a stably running still that only requires the cessation of heating to stop.

With more complex fractionation remember to consider what happens when all valves 'stick' in worst-case positions.