Source Code Sharing for Raspberry, Beaglebone, and Arduino?

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

RickH

Well-Known Member
Joined
Jun 16, 2013
Messages
65
Reaction score
5
Location
Princeton
Ok, So I have seen a number of threads with people talking about using Raspberry Pi, Arduino, and and Beaglebone Black for different brewing. I haven't seen much of any source code on them? Wondering if anyone is willing to share, maybe start a thread dedicated to each even. Looking at a price and total capability standpoint I would LOVE to do something with the Beaglebone Black since its cheap and seems like it has the most bang for the buck. I am hoping to get the person who works for TI to share his source code for the controlling his ferm temps and expand it out to something more. I would love to see something that could compete with the commercial solutions opensource here. That way they have to really add the features to compete. I am not a programmer but can understand the concepts but need to brush up on my programming languages and when I do so I plan to put it all out there. So anyone?
 
Great idea RickH. I have personally posted my PLC logic for my brewsystem, along with detailed documentation, and encourage others to post their source code.

It's all about community and brewing!
 
Get your repositories up on Github folks.

I have very nearly finished the firmware for an open source Arduino PID controller shield. Details to follow once I have thoroughly tested the thing!
 
Already an awesome start. I know we can keep this compiled and going well. All of the homebrewing and DIY is just another type of "opensource" in itself. In my work we actually use a number of opensource projects. I have two Raspberry PI's, a PiFace board, and a 4 relay board that I interfaced with it. After seeing the price and GPIO capabilities of the Beaglebone Black I decided its the best option for this. What I hope to do is really get an open source following for any of these so that we can come up with something anyone can use for a variety of purposes. But most of us are on right budgets or what is available doesn't quite meet our needs. I plan to research how its being used in robotic applications because that is the control that it will need is sensor input and relay output. The other goal is to have a easy web interface so anything can control it. Any hints or tips are ALWAYS appreciated. Once myself and a buddy can get started on this I will be posting updates and code.
 
Hi Rick, Bryan Wilder from TI pointed me to this thread. I'm in the Philippines right now for work and will be here for the next 5 months or so, I apologize if I'm too responsive on this thread.

I can tell you now that my code is pretty simple when it comes to the automation part. I have a PHP script that reads in the ADC value of the temp sensor, checks that against the set temperature and evaluates if I need to turn on/off the power supply. This script is executed on a regular basis through the linux OS crontab, or when anything is set from the website. The script also regularly updates a mySQL database that is located on a server elsewhere, this is for the web interface.

I was in the works of creating a circuit to reverse the polarity of the supply voltage to the TEM so that I could both heat and cool. I had it working fairly OK but got too busy with my relocation here to the Philippines.

If you have any background in programming/linux, setting up the automation shouldn't be any problem. It's the actual apparatus that cools/heats that's the biggest obstacle. My setup worked OK, but could certainly be improved upon especially if you want to brew lagers.

I'll try to get the code organized together for you when I have a chance to. Unfortunately I had to keep all of my hardware back in the states in a storage unit, so it will be some time till I can begin working on it again. But I'll be happy to help out the community to come up with an affordable automation system using the BBB.

People will argue that the BBB is overkill for automation, and I agree if that's all you want to do is automation. If you want to have a nice web interface, easy wi-fi setup and possibly even spit out a linux GUI to a small monitor, BBB is plenty capable of doing that while arduino is certainly not (not sure about raspberry pi when it comes to linux GUI output).

Cheers
-Trevor Hubbard
 
Should point out, my comment on that apparatus to heat/cool is disregarding just getting a fridge of course =). I was trying to create something that didn't take up much space and could heat AND cool.
 
Trevor I would first like to say its an honor to finally get to talk. And I am forever grateful to Bryan for making this happen.

I do agree it can be overkill but my main concern is expandability really. I would like this to be able to run a web interface that you could drag&drop events into. Such as a webpage where you have a box and in it you drop your events.
So say I drop in order the following.
[HEAT(165*), WAIT(30 Min),Boil(90min),Chiller(76*)]
So HEAT is set to keep on a relay unit that temp is met. Then Wait is just a timeout. Boil activates burner relay and a timer once 200* is met. It times 90 from the point that the water hits its temp. I hope you get where I am going with this. Most of what we do are the same steps, in a certain order. My endgame is to find a really userfriendly way to control it all. The variables and checks can be cronjobs in the background, but I want people to just see the pretty web interface most of the time. Since you have an understanding of this better than us. Should we be trying to just use the existing modules and write scripts to just look at the GPIO variables? Maybe make a little web interface to give it a visual at first and go from there?

I hope I am expressing this as best as possible.

Thanks,

Rick Hobson
 
Oh, and in the beginning when I was saying expandability I want to run a Natural gas Brew in a bag setup. I want this to also be able to control a HERMS setup, or any other for that matter. It to be able to see ferm temps, etc. I like the idea of too much vs too little. And the Modules I spoke of (HEAT,WAIT,Boil,Chiller) would all be clickable and have specific variables that can be set for each before starting it. Then it runs module by module.(in the future more than one at once so it can robotically drop in and pull out Hops)
 
Great to hear from you Trevor. Any good beers over in the Philippines?

Not much variety over here unfortunately, San Miguel has a monopoly on the market. Their best beer is red horse, 6.9% strong lager, it's OK. Nobody home brews over here unfortunately which was actually surprising to me, you'd think in a developing country they would find ways to make their beer cheaper. Perhaps I just need to search around more.

Trevor I would first like to say its an honor to finally get to talk. And I am forever grateful to Bryan for making this happen.

I do agree it can be overkill but my main concern is expandability really. I would like this to be able to run a web interface that you could drag&drop events into. Such as a webpage where you have a box and in it you drop your events.
So say I drop in order the following.
[HEAT(165*), WAIT(30 Min),Boil(90min),Chiller(76*)]
So HEAT is set to keep on a relay unit that temp is met. Then Wait is just a timeout. Boil activates burner relay and a timer once 200* is met. It times 90 from the point that the water hits its temp. I hope you get where I am going with this. Most of what we do are the same steps, in a certain order. My endgame is to find a really userfriendly way to control it all. The variables and checks can be cronjobs in the background, but I want people to just see the pretty web interface most of the time. Since you have an understanding of this better than us. Should we be trying to just use the existing modules and write scripts to just look at the GPIO variables? Maybe make a little web interface to give it a visual at first and go from there?

I hope I am expressing this as best as possible.

Thanks,

Rick Hobson

If I understand this correctly, you would have your own set of objects each doing their own tasks (boil, wait, chill, transfer etc). Then you can organize these objects into a flow. And maybe from there, create a customized flow for each kind of beer you're brewing and save them as recipes. Is that correct?

Oh, and in the beginning when I was saying expandability I want to run a Natural gas Brew in a bag setup. I want this to also be able to control a HERMS setup, or any other for that matter. It to be able to see ferm temps, etc. I like the idea of too much vs too little. And the Modules I spoke of (HEAT,WAIT,Boil,Chiller) would all be clickable and have specific variables that can be set for each before starting it. Then it runs module by module.(in the future more than one at once so it can robotically drop in and pull out Hops)

I'll have to read up on what a HERMS setup is. I hate to admit, but I am actually a bit of a noob when it comes to the all-grain brewing process.
 
Not much variety over here unfortunately, San Miguel has a monopoly on the market. Their best beer is red horse, 6.9% strong lager, it's OK. Nobody home brews over here unfortunately which was actually surprising to me, you'd think in a developing country they would find ways to make their beer cheaper. Perhaps I just need to search around more.



If I understand this correctly, you would have your own set of objects each doing their own tasks (boil, wait, chill, transfer etc). Then you can organize these objects into a flow. And maybe from there, create a customized flow for each kind of beer you're brewing and save them as recipes. Is that correct?



I'll have to read up on what a HERMS setup is. I hate to admit, but I am actually a bit of a noob when it comes to the all-grain brewing process.

You are correct on each object with its own task, then they get organized into a specific flow. With HERMS its more about creating additional modules so that dfferent styles of brewing can be accommodated. That was all I was thinking of there. Different input, values for it to meet, and relay for it to turn on(such as a pump). Wanting to slowly accommodate all brewing styles.

And that sucks about beer choices. I wonder if it is a little more underground there?
 
You are correct on each object with its own task, then they get organized into a specific flow. With HERMS its more about creating additional modules so that dfferent styles of brewing can be accommodated. That was all I was thinking of there. Different input, values for it to meet, and relay for it to turn on(such as a pump). Wanting to slowly accommodate all brewing styles.

And that sucks about beer choices. I wonder if it is a little more underground there?

Oh ok cool. So that can certainly be done, the web interface part. Easiest way I've found to communicate with the beaglebone through the web is by use a mySQL database. The web interface will update the mySQL database and then the beaglebone will poll the database on regular intervals to check for updated entries, and if there is one then it will perform an action depending on the updated entry. That way you don't have to connect directly to the bone.

The part that may be an issue from setup to setup is the actual controlling of external devices such as your boiler, chiller etc. That all depends on what type of interface your boiler and chiller use.

For example the power supply I used for my setup contained a PS_ON switch. I had to make sure to ground the power supply to my beaglebone and tie the PS_ON pin to a GPIO pin on the board. When I wanted to turn on the power supply I would force the GPIO pin low (PS_ON is active low) and I'd force it high to turn it off. I can imagine a boiler/chiller would be much tougher, but if it has some kind of digital interface it may be easier than I'm thinking now.

I'll try and think of some way to make it universal so that a wide variety of different pieces of equipment can be used with the beaglebone software, it may just have to be up to the user to get the interface between their equipment and beaglebone working though.
 
And that sucks about beer choices. I wonder if it is a little more underground there?

I sure hope so and I hope I can find it. I've heard in the low lands they brew wine from coconuts at least, I'll have to get my hands on some. They actually just sell it as vinegar in the supermarket when it gets old haha.
 
Quick update on my osPID arduino shield. I have built a prototype (~$15) and the basic firmware is done so it works as a standalone. Now I am tweaking the serial interface so that you can control the PID on your laptop while graphing in real time. Should have it all finished by the end of next week.
 
Not that this is a big update but I got my BBB and all the stuff so I can make it work. Next step is getting a handle on working with the GPIO connections. I am trying to figure out what thermometers work with it. Also since its more common with robotics I have a 4 port relay module. What I plan on is first making sure I can do command line based commands to turn on and off the relays. Then get temp readings from the temp sensor. Once this is complete I will work on each module. First will be a manual heating module so it can be put in a basic on and off manual mode, then Heating modules, cooling modules, etc. The biggest thing will be getting it to read all variables from a mysql database as I have done very little with mysql queries. Once some of these basic modules are finished I will start the web interface. My plan is to have a very basic design for programming out the brew day. It will be like a lot of modern software has. On the left you will have a list of "Modules" like "Heat to temp" or "Heat to temp and keep temp for specified time". Obviously shorter names but you get the idea. Alarm options, etc. This has a type of sound card so it can be made to scream as an alarm or activate a relay. But you will be able to copy each item from the list on the left, to the right side which is your brew day. Click each one on the right and hit the edit button. Set variables which will write to mysql. Also want a backup feature in the end. Lots of ideas. Lots. Slowly going to learn the programming.
 
Any sensor that puts out a voltage reading you can use. You just use the BBB's ADC to convert it to the actual temp.

This is what I used:
http://www.atlas-scientific.com/product_pages/sensors/env-tmp.html

As for the web interface, do you know any HTML? You will have to learn PHP/mySQL in order to do the functional stuff, but HTML to do the layout. Perhaps I can help you with that, will try to find some time this week and put together a rough layout. Can't promise anything though.
 
No worries. And its all going to be a learning curve as I had learned a little of each but hadn't used any of it so long that I might as well be starting from scratch. I am starting to wonder in the end if I am going to need a seperate 5power source to be able to run enough temp sensors and outputs for the relays. Need to look up the specs on it and what the max output at the board is to know what the limitation is there. Having it separate isn't a big deal. Just want to iron out those small things before starting. I plan to pick up two of those sensors when I can afford it so I will have it for my own rig and for testing.
 
You will at least need this for the BBB:
http://www.adafruit.com/products/276

The following I'm saying cause I don't know how much electrical stuff you know, don't mean to insult. Also for anyone else looking at this thread.

When thinking about power supplies, make sure to read up on all the power requirements of course for whatever you're connecting. Sensors "SHOULD" not require much power at all. P(power)=I(current)*V(voltage). Normally you only want to pay attention to current consumption unless your voltage requirements are very high. If you look at the BBB System Reference Manual, the max consumption when DC is plugged in is ~350mA. So if you have a 2A supply that still gives you 1650mA to work with. Now, as for the temperature sensor if you look at it's datasheet it can operate as low as 6uA! So even after one sensor you pretty much still have 1650mA to work with. So you can pretty much add as many sensors as you have ADC pins for.

As for GPIO, those shouldn't consume much current either especially if you use a pullup resistor. Let's say you put a 10kohm resistor in series with the GPIO pin, GPIO puts out 3.3V or 0V. V(voltage)=I(current)*R(resistance) so you would only be consuming 0.33mA when your GPIO is high.

So, in conclusion. If you stick to just sensors and GPIO, the BBB will be plenty. Now if you start having to power water pumps, heat exchangers, fridges themselves etc....then that's where you'll want to start investigating into bigger PSUs.
 
Well I would expect all of those will be programmed to work with the temp sensors and different 4/8/16 relay boards. The relay board should be able to be wired to a 12v source for my gas valves or to a SSR to control a 240v connection to a coil or pump. Atleast that was my initial planning. I am new at this so please let me know if I might be heading in the wrong direction. I was looking to it to read temp sensors and turn on basic smaller relays like http://www.sainsmart.com/8-channel-...arduino-pic-arm-dsp-avr-msp430-ttl-logic.html the listed 8 relay or two of them if needed. You get the idea. That relay can be connected to a power source capable of activating a relay more suited for the situation if it is not.
 
And no insult taken. This is both for new and old. My skill set is following instructions to make raspberry pi and pi face use a web interface to turn on and off relay. I did not program it but I can kind of understand it. I am still doing my best to lay it all out and what can be needed and how to integrate, I do not see it being a big deal. I see this as a reason for BCS to step up their game now. Make android products and more configurable ones. We are coming. Not as fast as I want, but coming. And we will be open for anyone that owns a BBB or wants to port this to something else. I love sharing what I make. I turned a $13 propane burner into a natural gas one a few days ago, This unit will control it soon enough. I am sure if that.
 
I have some Linux C++ code I've been working on for my automated brewery project up on Github: https://github.com/vortexau/OpenBrew It's Linux only, and uses GNU tools to build. It'll never be windows. Sorry.

So far it parses a BeerXML export from BeerSmith and generates the required steps as objects in the software and adds them to a 'vessel'. Other than that it doesn't do very much at all right now, certainly no relay control or anything like that. I'm using a BeagleBone (the white one) for the brewery and have some SSRs and a I2C relay board to handle the elements and the pumps. I'm intending to keep this thing semi-automated at best and keep manual valves, with the automation only controlling the temps of steps and the HLT, and adding the ability to have my HLT water at X temp at a time I pre-program into the system. I would like to implement gas boil control however, but that's down the track - I need to just get the HLT control and RIMS tube up and working at the very least!

I haven't done much with it for a while because I've been lazy. I have all the RIMS hardware etc but simply lack the time to get it all configured and working right now.

My other project is a RasPi fermentation fridge controller, which controls two fridges; i've actually just got the basic relay wiring up and running in the past few days.

I've also been working on an Android application that will be the UI for the brewery, and also allow me to monitor the fermentations I have going at that time. REST web services on the BeagleBone brewery and the RasPi fermentation controller serving the data to the Android application for the brewery and the fermenters.
 
i should also mention I wrote some Arduino software to control two fridges, again that code is also on Github, but it's abandoned. https://github.com/vortexau/ArduFerm Feel free to fork or download and do as you please. Consider it public domain.

I did some basic testing with that code and it does 40x4 LCD control too, but Arduino was just too restrictive for me - and once RasPi came out it opened my eyes to a whole world of Linux SBCs - and my Arduino's went in a drawer.

STC-1000's work well enough that i've not really bothered to put much time into these fermentation controller projects recently, but now I need to control a second fridge and I want to graph both of them - so my interest has lifted again.

ArduFerm output example:
ArduFerm Display by auvortex, on Flickr

Was just using rand in Arduino to generate the numbers.
 
Thanks for sharing the code!

From my point of view embedded chips are fine for temp control but the Linux boards are great for IO.

With multiple fridges I would be looking at embedded controllers communicating with a single BB/Raspi/router over RS485.
 
Thanks for the suggestions. RS485 looks like a reasonable solution when the devices are physically separate, in my case the fridges are directly next to each other so to me it makes more sense to keep it simple and just do everything on the RasPi.
 
Oh, Here is an article that talks about the Raspberry PI interfacing to the relay module. The BBB would connect the same way. Depending on if its a pump or what it is and the load that relay module can handle a good load, for more than that I would connect the relay module to a SSR so that it can handle any large load. The relay module can fire the SSR like a PID fires it. It would just need voltage which after thinking about it I would use a separate power source in case of severe malfunction. But below is how I plan to run all the devices. I also want to make it so that in the beginning you can go into a "Setup" and "Add Device" and choose it from a list and basically Map it to which GPIO pin it is. Save it, go to a test screen where it will list all the devices that are inputs with the current reading, and outputs such as pumps and coils, etc, and you can hit a on or off button to have it fire that relay to make sure it is actually turning on and off what you think it should. That way when you tell it to keep a temp you know its turning on a heating element and not a pump, etc. That was my thought on how to handle a lot of it. I hope that made sense.

https://coderwall.com/p/izzsig
 
I had a go at reworking the Arduino PID AutoTune Library over the weekend.

I think I have come up with a better way of detecting the response to the autotune signal, which may finish up faster and give slightly better tunings. I also implemented some new tuning rules which might work better than the default method under certain circumstance, as well as making some other changes under the hood.
 
I had a go at reworking the Arduino PID AutoTune Library over the weekend.

I think I have come up with a better way of detecting the response to the autotune signal, which may finish up faster and give slightly better tunings. I also implemented some new tuning rules which might work better than the default method under certain circumstance, as well as making some other changes under the hood.

Thanks for sharing! I like the comprehensive set of tuning rules that you included. Do you have a favorite?
 
Thanks! I'm still testing them out at the moment.

Heating a big tank of water with an electric element should be a lag-dominant process, so in theory Tyreus-Luybin should do better than the default (Ziegler-Nichols).

Heating up and cooling down are asymmetric processes which seems to trick many PID controllers. (You really don't want to overshoot on a well insulated tank.) I am working on a fix for that, too.
 
So, in my simulations the AMIGOf tuning rule came out best all round for PI controllers. It was slower to complete the auto tune than the other methods of this kind but never gave really bad tunings.

Also I have added a compile option to allow a biased relay, which can help find tunings for non-linear processes, or if there is a load disturbance (i.e. conditions change during the auto tune). I'm still debugging so there might be some fixes to come.
 
Has anyone here written (or do you know where to find) a pid library in Python than can easily be repurposed into new projects? I'm hacking up the raspibrew code I found for my own needs because I haven't tried to figure out how pull just the pid library out.
 
I have had a PI for a couple of weeks and am in the process of figuring out how to make it work. I have a temp gauge and some servos working now to get a led display working and tie them together into one program to read temps turn on a cooler or turn on heat belt and I will be happy for now.
 
I am currently working on a beaglebone black to control my system. Eventually, I plant to add automation functionality, but that is down the line. My setup uses 12v pumps on the hlt, mlt, and rims tube, and a march 120v on the bk for whirlpool and chilling. I have four DS18B20 temp probes which let me monitor the temps (hlt, mlt, rims, and bk). All the pumps have flowmeters coupled to them so I can (eventually, still programming) see flowrates and set totalizers to track transfer volumes. I have ported the arduino pid library to javascript, as I am using bonescript/node.js to run everything. I plan to port the arduino auto tune library at some point too. I use the pid library to run my rims element for maintaining my mash temps, and will use it to let me set specific flowrates for my 12v pumps (for sparging, recirculating, etc). The system has a web front end so I can control everything from a computer or ipad.

Eventually I am going to opensource the code, but am waiting until I have it a little more complete, so it is not laughable.

Right now, this is my web interface (mocked up):
ImageUploadedByHome Brew1399092841.991280.jpg

At some point I will be starting a thread for the system and will be posting updates as I progress, probably once I have the code up on github.


Btw, if anybody from TI is reading this, I would love to talk :)


Sent from my iPad using Home Brew
 
I am currently working on a beaglebone black to control my system. Eventually, I plant to add automation functionality, but that is down the line. My setup uses 12v pumps on the hlt, mlt, and rims tube, and a march 120v on the bk for whirlpool and chilling. I have four DS18B20 temp probes which let me monitor the temps (hlt, mlt, rims, and bk). All the pumps have flowmeters coupled to them so I can (eventually, still programming) see flowrates and set totalizers to track transfer volumes. I have ported the arduino pid library to javascript, as I am using bonescript/node.js to run everything. I plan to port the arduino auto tune library at some point too. I use the pid library to run my rims element for maintaining my mash temps, and will use it to let me set specific flowrates for my 12v pumps (for sparging, recirculating, etc). The system has a web front end so I can control everything from a computer or ipad.

Eventually I am going to opensource the code, but am waiting until I have it a little more complete, so it is not laughable.

Right now, this is my web interface (mocked up):
View attachment 197133

At some point I will be starting a thread for the system and will be posting updates as I progress, probably once I have the code up on github.


Btw, if anybody from TI is reading this, I would love to talk :)


Sent from my iPad using Home Brew

Man I would love some more pics/info on your system!

-G
 
I love sharing what I make. I turned a $13 propane burner into a natural gas one a few days ago, This unit will control it soon enough.

Would you be willing to share more details on this. I've been looking into economic options for getting a NG burner going but it is not exactly straightforward on how to do it, which parts to use, etc. I'd love to know more about how you plan to automate it too.
 
Back
Top