Brewing with Node-RED pt 2: My Dashboard

This post continues my discussion of Node-RED for brewing applications. Read part 1 here.

The most recent information and version of my brewing dashboard can always be found on github. I’ll improve it and add features from time to time, and it’s all there for you to borrow ideas from/copy/modify and otherwise jump start your own process of using Node-RED.

My brewing dashboard is quite specific to my 2 vessel brewery. Node-RED really encourages intensely personalized app/dashboard development. Notable features of my brewing dashboard are:

  • PID temperature control of mash (using RIMS), with output limiting functionality
  • PID temperature control and manual control options of a boil kettle
  • Output blocking to ensure only a single element is used at once
  • Volume sensing (not shown in screenshots below as I had my pressure transmitter disconnected)
  • Looks nice and has mobile friendly buttons and sliders
  • MIT opensource license (any my code anyways, Node-RED itself is licensed under Apache 2.0)

There’s a bit more detail in each of the below screenshots. Please let me know if you have any questions about what I have going on here!

This dashboard has worked incredibly well for me so far. I’ve been using it in some form to brew for the past year or so. Changes I make to my dashboard now have tended towards more aesthetics rather than function. A goal of mine is to eventually incorporate control of my pump VFD (beyond basic on/off functionality), through this dashboard.

This is the main view of my brewing dashboard. Works well on mobile too (using 1 column instead of 2). Ignore the missing temperatures, I took this UI screenshot while all of my sensors were disconnected for brewery modifications…
The mash settings page has all the advanced output and settings in regards to mash temperature control, that you may expect. One somewhat novel feature is that I have an output limiter for my RIMS inline heater. So for heating strike water I may use 100% output, but dial it back to 25% max for mash recirculation and temperature control. Also on this page, a temperature Δ may be specified (mash target vs. rims target). This may be necessary when brewing in situations with high heat loss (e.g. outside in the winter).
The boil settings page is a little simpler. Just basic PID settings and PID related outputs (these are useful for tuning and troubleshooting PID behaviour). A PID on the boil may be used for no-boil beers or kettle sours. Possibly as well for a hop stand, though I think that’d be overkill.

Brewing with Node-RED pt 1: Introduction

Node-RED is a popular framework for visual programming. It is included with Raspbian, the official operating system of Raspberry Pi, and sees wide use for interfacing IoT devices and task automation. Programming in Node-RED is flow orientated – essentially signals or messages propagate through nodes which each deliver some functionality (e.g. directing, modifying, or expanding a message)

These flows are created using a visual editor, and 1000s of user created and maintained nodes exist to do pretty much anything with a simple drag, drop, and route workflow. If the included and contributed nodes are not enough, and you have some basic programming experience, it is easy to write your own function nodes using JavaScript. You can even call code written in some other language if you wanted. Pretty damn flexible.

The messages themselves may be invoked through interaction from a user (e.g. a button click on an associated dashboard), some scheduled regular injection, various input nodes, etc. For example, you can have a node which streams messages from a DS18B20 temperature sensor. You may route that message to a node that provides some kind of smoothing functionality, then to to a UI element that displays the current temperature.

Example flows in which a temperature reading is triggered by regular insertation of a timestamp. This temperature reading is smoothed for display in UI, and it is also routed to a PID algorithm.

While a dashboard is not necessary for a Node-RED project, they are commonly used. Lots of basic UI widgets are included with Node-RED-dashboard, the default dashboard package. These should cover most of what you would want to use, but again, you can also write your own widgets. Elements from Angular Material can be used without any extra setup or configuration, and this makes it relatively easy to create fully customized, modern and attractive widgets. You are not restricted to using Node-RED-dashboard however, and can use essentially any other front end library (e.g. vue.js) that you may want to build your dashboard if you want further flexibility. Check out the short video below for a demo of a custom ui widget I made – the lightning bolts indicate power and ability to power each of my two brewery elements (I prevent powering of both elements simultaneously with my Node-RED dashboard)

From CraftBeerPi to Node-RED

It’s easy to see why Node-RED is so popular across the complete range of programming experience levels and applications. About 18 months ago I think it was, I began playing with Node-RED myself. The programming style was a bit different from what I was used to, but eventually I became somewhat proficient in it and built a dashboard to control my homebrewery.

In comparison to CraftBeerPi, which is probably the most popular software on the Raspberry Pi for brewery control right now, a Node-RED dashboard is certainly more “assembly required”. It does have the benefits of wider use even if that use is not homebrewing specific though. The Node-RED discourse forum has thousands of questions and posts from other hobbyists and makers on how to do specific things with Node-RED, which can be easily related back to homebrewing. In comparison to the CraftBeerPi project, development is much more active, the project is much more stable, and it is also truly opensource (Apache 2.0 license).

For a user wanting custom functionality, endless control, and not afraid to get their hands dirty, Node-RED a good match.

Continue reading Brewing With Node-RED pt 2 here.

ESP8266 Fermentation Controller Build

I’ve been meaning to do a quick write up of the fermentation controller I built that uses an ESP8266 running BrewPiLess, with my ESP8266 PCB. The ESP8266 is a very popular WiFi enabled IoT device. Their most popular commercial use that I know of is in “smart plugs”. They’re used all the time for various home automation tasks.

There’s not much to this build, really. The ESP8266 PCB keeps the connections simple. In a small enclosure, I have an ESP8266 with my PCB, with a pair of relays for heating and cooling outputs. There’s a 5V DC power supply to power the ESP8266. For temperature sensors, the popular and cheap DS18B20 sensors are used. At minimum you need two sensors: one for beer/fermentor temperature, the other for chamber temperature. You could optionally use a third for the “room temperature”. And that’s it!

While the build is pretty simple, I know when planning a project like this, it can be very useful to see finished projects. I’ll include a parts list at the end.

Here are the internals of a completed controller. In the upper left is my ESP8266. In the upper right are some solid state relays. In the bottom left, there is a 5V DC power supply. Connections for temperature sensors and heating/cooling outputs are found on the bottom.

Here’s a better look at just the ESP8266 on my PCB. You’ll notice I use an external antenna. The metal enclosure used for the controller operates essentially as a Faraday cage. So a ~$1 upgrade to include the wireless antenna really helps with the strength of the controller’s WiFi connection, and reliability. Though it continues to work if the WiFi connection is dropped, you can’t do things like change the beer or chamber set points.

Here’s a close up of one of my assembled ESP8266 PCBs. The screw terminals are used for powering the device (5V), temperature probe connections, and heating and cooling outputs. They’re all labelled (which can’t be seen here). There are also 4 pins across the top which are used to connect to an LCD using the I2C protocol. More details on this PCB can in another post, here.

Here’s the bottom of my enclosure – I use XLR connectors for my DS18B20 temperature probes, and cable glands to secure SJOOW for AC inputs and outputs. I personally find these a fair bit easier to install than installing outlets into a controller (which generally involves bringing out the jigsaw if you’re using an enclosure like mine).

This is the LCD I mentioned earlier. It is a 20 x 4 line display. This shows the current controller status, as well as some basic information such as the IP address when booting up. These LCDs are 5V logic whereas the ESP8266 is 3.3V logic, so making this work required a logic level conversion circuit on my PCB (otherwise the PCB would be a bit simpler).

And finally, a shot of it all closed up! I did still need my jigsaw for this project in order to make a cutout for the LCD.

That about covers it. Let me know if you have any questions in the comments.

The parts list below uses Amazon.ca links as it’s what I generally use and I do get a small commission for purchases through my links. These components are generally easily found on other Amazon locales, or can be ordered directly from China (generally cheaper but longer wait) using on eBay or Aliexpress.

LinkQuantityDescription
 1Electrical enclosure for controller and relays. This is the one I use. There are many other options for this – including 3d printing one.
SainSmart 5V 2-Channel Relay Module Shield Control Board for Arduino Raspberry Pi Arduino 8051 AVR PIC DSP ARM ARM MSP430 TTL Logic1

2 channel relay module. One channel for heating and one for cooling. In this build I used a pair of high quality SSRs as it is what I had on hand. Whatever you use, ensure that it is properly rated for the application at hand. For a fridge, or other appliance with a compressor, you should really use HP-rated contactor, that is controlled by this 5V relay module.

RS Components Raspberry Pi 3 Model B+ Motherboard1 (optional)

Raspberry Pi. You can run Fermentrack on this Raspberry Pi to manage many of these fermentation controllers, or if you would like to do without, you can run BrewPiLess directly on each of your ESP8266. Both work great. 

If you are using a Raspberry Pi, you will also require a 5V power adapter and a microSD card – there’s lots of well priced kits available that have everything you need to get started.

1 (optional)2004 LCD (20×4 LCD). This is extra display that will show the activity of the controller. It’s a “nice to have” – not at all necessary to have a working controller. These can be found for cheap on eBay and Aliexpress.
2DS18B20 Temperature probes. 2 are required (one for chamber, one for fermentor). Note that the link provided on the left is for a set of 3. A third can be used to monitor outside ambient temperature.
WEMOS D1 Mini Pro 16MB (128Mbit) ESP8266 comp. WiFi, Arduino Lua NodeMCU, Antenna1

Wemos D1 mini (ESP8266). This is the actual microcontroller used in each controller. It will read our temperature sensors, and based on our settings and temperature history, it will activate the heating or cooling relays. It also has wireless capabilities for connecting to your network.

1An ESP8266 PCB, as well as the necessary components for its assembly.
MEAN WELL RS-15-5 AC to DC Power Supply Single Output, 5V 3 Amp 15W1A 5V DC power supply for the ESP8266. Can also be found on Aliexpress or eBay for cheap.
 VariousMiscellaneous connectors/receptacles are required for:

  • Main power input
  • Outputs for heating and cooling
  • Temperature probe connections (I use XLR)

My CraftBeerPi 3 Plugins

I spent about 2 years using CraftBeerPi 3.0 (CBPi 3.0) as the software running my Raspberry Pi brewery controller. During this time I have written a handful of plugins to enhance or extend the functionality of the software. These have all in turned been made opensource and shared with the CBPi community. What follows is an introduction to each of these plugins.

Note that I’ve since moved away from using CBPi (subject of a future post), but I do still try to maintain these plugins for the many people using them. Feel free to use the comment section here if you have any questions about these plugins. Bugs and issues are best reported directly on the respective Github repository.

Edit: Unfortunately I have discontinued support for these plugins as of May 22, 2019. Their respective repositories have been archived. The plugins can still be used as well as developed on personal forks.

Dependent Actor (cbpi-DependentActor)

source

The motivation of this plugin was to provide a very basic check in the software before activating actors in CBPi, on the basis of the state of some other relevant actors. For anybody unfamiliar with CBPi, actor is the generic term used for of any outputs that are controlled by the software. An Actor could be a heating element, a pump, a mash stirrer, an electrically actuated valve – you get it.

To be specific, this plugin provides, a new actor type called DependentActor in CBPi. A DependentActor is a container for some existing Base Actor, which will only power ON when it is triggered if its Actor Dependency is in a specific state. The Actor Dependency must be already ON if it is set as a prerequisite, and OFF if it is set as a restriction.

Note that checking the state of the actor’s dependency is only done once at time of actor attempted activation. If the actor dependency’s state is changed while base actor is on, the base actor will stay on! One way around this is to make two DependentActors and set them both to have each other as restrictions or dependencies. Once this is done I would suggest hiding the original base actors, and ensuring that it is the DependentActor containers referenced in any kettle or fermentor logic.

The most common use case for this plugin is when somebody does not want two electrical heating elements powered at the same time due to brewery control panel power limitations.

Another common use case is when a brewer only wants to allow a heating element to be on when its associated pump is on, such as in a RIMS brewery. This would be done to prevent settling of mash solids near heater interface which could lead to scorching/burning, as well as to keep mash runnings well mixed to ensure a reliable temperature reading.

This plugin is not a substitute for physical electrical safety devices such as breakers and fuses providing overcurrent protection where needed, and properly rated components throughout your panel, flow switches, etc., rather it provides some convenience in the software and an extra level of safety.

1wire Advanced (cbpi-OneWireAdvanced)

source

This plugin was built to provide some advanced functionality for the popular DS18B20 1wire temperature sensors, in comparison to the basic 1wire plugin included with CBPi.

This plugin allows you to set the precision of your 1wire sensors (different sensor precision has different sampling rates).

It provides functionality for sensor calibration (simple offset at this time).

It offers exponential moving averages for these sensors.

It can filter high and low values, and provide notification of their occurrence. Erroneous values are often encountered due to intermittent connection issues, etc.

You can set the update interval for your temperature sensors (e.g. 1.5 sec instead of 3.0 sec default for a system parameter that must be closely controlled such as a RIMS tube), and longer where frequent updating is not required.

Pretty useful stuff! Use it in place of the included 1wire plugin.

Settings for using my OneWireAdvanced CBPi plugin

On at Startup (cbpi-OnAtStartup)

Source

This is a simple one. Allows you to set an actor to come on automatically with start up of CraftBeerPi. I used this for turning on some lights and a system fan. Who knows what purpose you may find for it.

Cascade PID (cbpi-CascadePID)

Source

I wrote a plugin to implement a Cascade PID – which is just as it sounds: one PID controlling the set point of a second PID. Why would anybody want this? Well in RIMS and HERMS breweries, brewers often manually set a temperature differential between their RIMS tube or HLT and their target mash temperature. This can lead to pretty slow temperature control, and the required differential is often dependent on the brewery’s environment (e.g. winter brewday in a garage ≠ climate controlled indoor brewday). If you have ever lamented about slow ramp times with these systems with this control method, a CascadePID actor in CBPi MAY be for you.

Cascade PIDs are pretty difficult to tune honestly, best used for RIMS or HERMS types of systems as mentioned. If using this algorithm for mash temperature control, you must ensure consistent flow characteristics (which may be overly optimistic in a brewing application). To use it you must have a sensor for both the inner loop (e.g. RIMS tube, or HLT in HERMS) and the outer loop (actual mash temperature). You should probably have some sort of additional safety mechanism in case you run into a stuck recirculation too (e.g. flow switch). Read the README in the github repository for more details on Cascade PIDs.

And while I developed the plugin to try out this idea of CascadePID, what it is actually most popular for is the basic PID algorithm that I include in it, SinglePID. It has some extra parameters you can set in it in regards to controlling the integrator and integrator wind up. It seems to be the most reliable PID plugin for CBPi currently.

Edit: This plugin was renamed to Cascade Control, and also includes hysteresis functionality (including an advanced PID-controlled hysteresis).

Closing

CBPi software appeals to many homebrewers using Raspberry Pis due to its simplicity to set up. It can be used for hot side brewery process control, or cold side. For those that want more control over the exact algorithms being used, they’ll need to do things like write their own plugins (not that difficult for someone with any programming experience), or turn to other software. CBPi 4.0 is currently in development, and I expect that the plugin system will once again be one of its shining points. I do not expect however any of these will be compatible with it (fine by me 🙂). Until then, I hope these plugins make your CBPi controller a little more powerful.

Homebrewing PCBs Part 2: ESP8266

Carrying on from my recent post on some PCBs for Raspberry Pi I designed…

I also designed some PCBs to use with ESP8266 devices, which I now use as the brains of my fermentation controller. These devices can be used with brewpiless (design to operate as a standalone device), or brewpi-esp8266 which can be managed by Fermentrack, which can run on pretty much any Linux machine, including virtual options such as Docker containers, Virtual Boxes, and Vagrant Boxes, in addition to Raspberry Pi.

ESP8266s are cheap WiFi enabledInternet of Things devices ($5-10), commonly found in “smart plugs” and other things. They can also be bought on their own with breakout boards for DIY projects such as the the one detailed here.

Inspiration

These PCBs for ESP8266 were based pretty closely on designs by @thorrak, the developer behind Fermentrack and maintainer of the ESP8266 fork of BrewPi project. His PCBs can be found here.

Purpose

The purpose of the PCBs is to:

  1. Interface DS18B20 1wire temperature sensors, including providing the necessary pull up resistor to support multiple sensors on a single ESP8266 data pin
  2. Provide bi-directional logic level converters such that 5V I2C 20×4 LCDs can be interfaced with the ESP8266, which only has 3.3v IO
  3. Amplified heating/cooling outputs (3.3V to 5V) to be used to control relay modules and SSRs with increased reliability. Note that SOME relay modules and SSRs will work fine without this. There is also concern that certain configurations may draw more current than the ESP8266 can provide through its GPIO.
  4. Decoupling capacitors on 3.3v and 5v to improve power quality, big ground plane to reduce EMI.
  5. Screw terminals for outputs and sensor connections (@thorrak’s PCBs use some RJ connections, which are not my preference)

Top view: Transistors used to amplify heating and cooling outputs, MOSFETs for the bidirectional logic level converter, a few resistors and capacitors…

If I make another version of this there are a couple changes I would make. For one, I would use larger screw terminals – both in size and number of channels. Just to help keep things a bit neater.

I may also do away with LCD circuitry – I reference the LCD on my controller less often that I figured I would (though it has been handy for troubleshooting when I was having some issues with network connectivity).

I would considering doing a version with opto-isolated relays right on the PCB. In some cases these could be used directly (e.g. with resistive loads, like those commonly involved in heating), in others they may have to be used in conjunction with a contactor that is HP-rated for the compressor of the fridge, freezer, glycol chiller – whatever is being used for cooling.

Lastly, I would consider having my boards built for me. PCBway assembly costs seem quite reasonable. I like designing the boards, and using the boards, but not so much soldering them. I have some credit to use from people ordering my boards (they give a 10% commission to those that share boards on there), so why not?

The design files and BOM for these can be found on github, and downloaded or ordered from PCBway as well.

I will do another post in the near future regarding the build of my actual fermentation chamber controllers.

Want to support this blog?

Here’s some affiliate links related to this post. I receive a small commission on purchases made through these, helping to fund my future brewery projects 🙂.

Amazon.ca

PCBway

Homebrewing PCBs Part 1: Raspberry Pi

Motivation

Sometime in 2017 I gained an interest in basic Printed Circuit Board design. I had been using a Raspberry Pi to control my homebrewery for some time with various software, and was growing tired of trying to arrange components and solder wires on prototyping boards every time I wanted to make a system change. Messy and not that fun. PCB design on the other hand could be perfected on a computer, and ordered/printed for cheap. They are also easy to share with others.

PCB Goals

The first board I made would do a couple things:

  1. It would use a transistor array (ULN2803) to increase the effective voltage and current I could output from a Raspberry Pi. The purpose of this is to reduce current draw on Raspberry Pi GPIO, and increase reliability when using Solid State Relays and Relay Modules to control elements, pumps, etc in my brewery.
  2. It would have circuitry to enable the reading of many 1wire temperature sensors – that is, a pull up resistor on GPIO 4 (Data or DQ pin typically used for interfacing DS18B20 temperature sensors with Raspberry Pi), and 5V and GND break outs.
  3. A decoupling capacitor, and a big ol ground plane, intended to improve the quality of the 5V power supplied to the Raspberry Pi and reduce electrical interference respectively.
  4. Screw terminals for everything to simplify installation.

Design software

My initial PCB designs were done using Fritzing software, which is very user friendly, and opensource, but development on it has dropped off – the last release was in 2016. As I gained more experience I’ve switched to using KiCad software which offers more advanced features.

Closing

I’ve gone through a couple revisions of this to minimize the footprint and implement small improvements. I’ve been using this board for over a year now quite happily. The full design (and history of the design), as well as bill of materials can be found on github here. The design can also be downloaded and ordered from PCBWay here.

Want to support this blog?

Here’s some affiliate links related to this post. I receive a small commission on purchases made through these, helping to fund my future brewery projects 🙂.

Amazon.ca

PCBWay

PCBs.io