BrewPi on WiFi

One of the most common “wishes” for BrewPi users is to be able to connect the Raspberry Pi to the Arduino wirelessly. This makes even more sense and is more desirable when you leverage a multi-chamber setup. The Arduino Uno did not have WiFi originally, although the nice folks over there in Italy have a Rev 2 of a WiFi enabled Uno for the low low price of $44.90. I don’t know for sure, but since (I believe) this is a native implementation, I suspect any Uno sketches would need to be re-written for WiFi.

That’s a problem for BrewPi where we are getting close on storage space anyway.

Not to fear though! Back in 2015, @thekraken on HomebrewTalk started talking about how to make an ESP8266 work as a serial bridge. That was really just sort of a technical discussion, and it never quite rose to the level of something that seemed practical for most end users. About four months after that, @day_trippr took a swing at it and came up with a start to finish method of doing it for the courageous, but let me just tell you that dude is “wicked smaht” and what’s easy for him is not generally easy for a guy like me.

People kept pecking at it but rather than me give you the blow by blow, you can read it yourself on HomebrewTalk. BUT, I figure you want to know how to do it, or else, why are you here. Amirite?

So, here’s what you need:

  • A Raspberry Pi (duh!)
  • A combo ATmega328P+ESP8266 card direct from China. The ATmega328 is the guts of an Uno. The ESP8266 is a controller in its own right, but we are using it as a WiFi/Serial bridge. I used this one from Banggood in my project. I don’t have any reason to believe that there are not many others that would work. I paid $6.49 + shipping so I bought a couple just in case one arrived DOA.

To start with, go ahead and install BrewPi Remix if you don’t have it installed already. No need to connect the Arduino just yet. Take the defaults, smile and nod your head if the script tells you there’s no Arduino, and don’t worry about flashing the controller (yet.)

You might need to Google up some drivers for the CH340 chip if you will be using your PC for this (and expect my instructions to work), unless you’ve messed with one of the Uno clones before. The “official” drivers appear to be on this page in Chinese. You can either translate or click on the very obvious download button and throw caution to the wind.

Install those drivers, and find yourself a USB micro cable because this board ditched the HUGE type “B” plug. Before you plug it in, you need to set the DIP switches as follows to let the CH340 talk to the ESP8266:

Switch NumberPosition
1Off
3Off
3Off
4Off
5On
6On
7On
8 (Do Not Use)Off

Go ahead and plug the board in to your PC to hear the pleasing “boing” letting you know that it connected. You’ll need the NodeMCU Firmware Programmer if you have not already downloaded it before. You can get it here. If you don’t know whether you are on a 32 or 64-bit system, just grab the ESP8266Flasher.exe file from the Win32/Release directory.

You will also need some firmware for the ESP8266 side. First, download “ESP-Link” version 3.0.14 from the releases page (read the notes and get the latest stable version.) Previous versions of this article had instructions to use 2.2.3 versions, but the 3.0.14 firmware seems quite stable. Unzip those files somewhere handy and continue.

Go ahead and execute the NodeMCU Firmware Programmer (“ESP8266Flasher.exe”) and set up the following firmware files at the addresses indicated on the “Config” tab:

File NameMemory AddressDescription
boot_v1.6.bin0x00000Bootloader
user1.bin0x01000ESP-Link Firmware v3.0.14
esp_init_data_default.bin0x3FC000Expressif Default BIN
blank.bin0x3FE000Blank WiFi Settings

The numbers are memory addresses so do be careful and don’t select the wrong one. At best things will not work. At worst you will brick your card.

If you are curious about the “Advanced” tab, I did not make any changes. The settings were:

Setting NameSetting
Baud Rate230400
Flash Size4MByte
Flash Speed40MHz
SPIO ModeDIO

On the “Operation” tab, select the proper COM port, then click “Flash”.

When complete, go ahead and close the programmer, unplug the card, and set the switches to connect the CH340 to the ATmega328 (upload sketch to the ATmega328):

Switch NumberPosition
1Off
3Off
3On
4On
5Off
6Off
7Off
8 (Do Not Use)Off

Now flash the BrewPi Remix firmware with whatever tool you like. I just plugged it into my Pi and used “sudo /home/brewpi/tools/updateFirmware.py” since that script downloads the latest firmware automatically. In theory this board will allow flashing the ATmega328 over the air, I’ve just not tried that yet. Once you have the BrewPi firmware loaded, unplug and set the switches to connect the ESP8266 to the ATmega328 (serial bridge mode):

Switch NumberPosition
1On
3On
3Off
4Off
5Off
6Off
7Off
8 (Do Not Use)Off

Power the board up separate from your PC or Pi. Now from your computer, phone, or whatever; search for the access point created by the board. It will be something like ESP_XXXXXX. Connect to it, no password needed. Open your web browser and navigate to 192.168.4.1. After a moment the esp-link page will show up. Go to the “WiFi Station” tab, and follow along. Click the link under “WiFi State” to switch to STA+AP Mode:

Select your desired wireless network (if they do not show up, refresh the page) and provide the proper password. When done click the Connect! button:

After it connects successfully, record the WiFi IP Address under “WiFi State.” For the purposes of demonstration, we’ll assume it’s 192.168.168.143.

Now connect your PC to your normal network and connect to the board again via it’s new address (192.168.168.143). Go to the µC Console tab and set the following:

  • Switch Baud Rate to 57600
  • Click the Reset µC button to commit the change.

Now press the MCU RESET button on the controller (or simply power-cycle by pulling the plug.) If you left it on the µC Console tab, you should see json from the controller in the console window after reset is complete. Success!

The last step is to configure your BrewPi instance for the controller. Assuming you are using a custom config (config.cfg), change the port to point to your board’s IP address and port 23 like this:

scriptPath = /home/brewpi
wwwPath = /var/www/html
port = socket://192.168.168.143:23

This will work on all versions of BrewPi Remix starting with 0.5.2.0. Changes to the python scripts would be necessary to use this with Legacy BrewPi. Re-start your script and you should be connected via WiFi!

One thing I came across which requires a small hardware change: If you are using one of @CadiBrewer’s shields with the LCD you will notice that the LCD does not work. This is because the shield attempts to separate the power for the shift register and LCD from the rest of the board by taking power off the ICSP header. This header does not line up with the ICSP header on the combo board. So, you must jumper 5 volts and a ground (+5V and GND) off the header on the shield to the ICSP header on the shield and all will be well.

Obviously this shows the Arduino and not the shield, but the headers are all in the same place.