Arduino Expanded IO Serial Connection - Possible?

I have a DIYBrewPi setup using an RPi 3 and an Arduino Uno. I am building a “smart keezer,” based off of this guide and planned to use the SmartKegerator program in conjunction with BrewPi. My original intent was to use BrewPi as a fridge temperature controller/monitor and to use SmartKegerator for dispensing & monitoring of the beer, along with a tap list, and to have everything running on one system.

My first thought was that I could let the RPi focus on the touch screen interface running BrewPi and SmartKegerator programs, and I could use the Uno to do the data collection and dumb, heavy lifting since it communicates with the Pi via USB. I thought it’d be as simple as modifying a few files here and there, duplicating/modifying some variables to expand the number of sensors I had to work with, and bam I’d have a hybrid of the two that worked together beautifully. Given my extreme lack of experience and short sight, I am now in over my head and am hoping for some help.

-BrewPi successfully uses the Uno to interface with the LCD, temperature sensors, and relay. It does this with a USB serial connection, and from what I gather uses its own code to accomplish the serial communication–or maybe PiSerial?
-SmartKegerator is already setup to collect data from (2) flowmeters, and a temperature sensor. It does this via the WiringPi library.

I want to add a decent number of sensors to be read in by Smartkegerator, including an additional flowmeter, (4) load cells w/ amplifiers, and Wheatstone bridge pressure sensor w/ amplifier. My thought process was that adding these sensors to the Arduino pins and sending that data back to the Pi over the USB connection as well would be ideal. I assumed that it would help on Pi system resources and made more sense overall to connect all sensors to the Arduino. Because SmartKegerator uses WiringPi, it also conveniently has fairly direct access to the included Serial Library, which treats the Arduino IO pins as extensions of the normal PI GPIO pins called using WiringPi.

I tried to implement some basic tests last night to see if something like this was even possible, and was unsuccessful. It got me thinking if what I was trying to do was in fact possible, and if it even made sense. With that, I have a number of related question.

1.) Since BrewPi opens the serial connection to the Arduino, would I need to do so in SmartKegerator as well–could I piggy back that open connection into separate programs, do I have to open in both programs, or will trying to have two programs talking to the same Arduino cause issues?

2.) Along the same vein, SmartKegerator looks for a temperature sensor normally connected to a Pi GPIO. I originally thought that I could access the same temperature probe information that BrewPi uses just to eliminate a sensor and some more code, but the more I think about it the more I am convinced that calling the onewire temperature probe information from the serial connection while BrewPi is also doing so would be complex and might cause issues. I am now leaning towards just getting another temperature sensor to read temperature at the same area in the fridge as the BrewPi probe since sensors so cheap, but am wondering if using the existing probes as mentioned is easily doable.

3.) As I mentioned, I assumed that it made sense to have the Arduino handle all the data collection instead of the Pi so as to help free up Pi system resources for it to run the GUI’s and do other stuff. Is this a false assumption? Would simply connecting all the sensors to the Pi and using WiringPi as-is, directly, be slower and eat a noticeable amount more of system resources than trying to have it go through the Arduino/serial connection instead?

BrewPi is certainly a more complex program and looking at the code is daunting for a complete noob like myself. On the other hand, SmartKegerator is much more straightforward and would prevent me from having to worry about the issues I mention above. I could just copy/paste/modify the existing code to expand it for the additional sensors I want to add to SmartKegerator, however that only makes sense to do if it won’t bog down the Pi or be too much to handle.

Thanks in advance for your help.

What you propose sounds like a lot of changes to the Arduino software. If you want to do them yourself, no one is stopping you. We stopped using Arduino altogether and will not release any software update for it or offer support for it.

Our Arduino software was completely filling up the Arduino. If you want to fit extra stuff in there, you will have to remove some other stuff. This is one of the reasons we stopped with Arduino. Our codebase outgrew it. You will probably run into the same issue.

The WiringPi and serial extension just makes it treat the Uno as an IO extension of the Pi, I think, and adds only a minimal amount of code to the Arduino itself. The Uno pins are called, set, etc. from the C/Python side, so if I interpreted it correctly that wouldn’t be an issue if I could modify the existing Kegerator code to suit my needs.

Anyway, assuming that is true and assuming that space isn’t an issue, can you offer any input to my questions #2 and/or #3? I think the answer to those will help me determine which route to take moving forward. I know I have a lot of learning and coding to do, so figuring out the path of least resistance will at least help me learn in the most efficient way possible.

  1. No idea. I have never looked into that code so I cannot comment. Probably easier to just use it as designed and wire a sensor to GPIO.

  2. Anything the Arduino can do will be peanuts for the pi in terms of processor load.

I’m not familiar with WiringPi but it must use code on the Arduino to receive commands from the Pi over the serial port and send responses back. The problem is, this is exactly what BrewPi is doing. So you have two problems. Firstly, the Arduino is already running the BrewPi firmware. It’s not a multitasking system so you can’t just run two programs on the Arduino. Secondly, even if you could run two programs at once, they would both be wanting to use the same serial port. Only the first program would actually be able to open the serial port. Even if both programs could open the serial port they would interfere with each other. You would need to define a new protocol that would encode both sets of messages and write software both for the Arduino and for the Pi to handle this protocol and send the message to the right program. So it’s possible but it’s not a trivial exercise. You might also run out of space on the Arduino.
So the easiest solution is just to connect another temperature probe to the Pi for the SmartKegerator. The Pi is perfectly capable of running two programs at once. It’s a much more powerful system than the Arduino and connecting the probe directly is actually going to use less resource than going via the Arduino.