Native ESP8266 BrewPi Firmware - WiFi BrewPi, no Arduino needed!

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.

Thorrak

Supporting Member
HBT Supporter
Joined
Feb 7, 2016
Messages
4,009
Reaction score
2,736
Location
New York, NY
Over the course of the past couple of weeks I've been working on a project to convert the BrewPi Arduino firmware to work on an ESP8266 device. This project replaces the Arduino with an ESP8266 -- which means that you can add WiFi capability to a BrewPi without needing any additional hardware. Although it isn't yet 100% complete, I'd love to get feedback from anyone who is interested in trying it out and telling me about their experience.

Features Currently Implemented:
  • WiFi Support
  • Serial Support
  • Temperature Sensing
  • Relay-based Temperature Control
  • I2C LCD Support (Currently address 0x27 only)

Features Currently Missing:
  • Rotary Encoder Support
  • Buzzer Support

In order to both implement WiFi support and support the custom pinout of the ESP8266 device, I had to create a custom version of the brewpi script. I also created a custom version of the brewpi-tools installation tool as well. Both of these are on GitHub and are linked below.

Hardware:
There are a number of ESP8266-based boards out there - I took a look at a few of them, but highly recommend the WeMos D1 Mini if you are interested in picking up a board specifically for this project. In addition to the ESP8266 board you will need the standard hardware for a BrewPi build (Raspberry Pi, SD card, power supply) and a USB cable to connect your ESP8266 board to your Raspberry Pi. This project was designed to integrate with a 2-channel relay board and DS18B20-based OneWire temperature sensors. You will also need a separate power supply for your ESP8266 board if you don't want to leave it powered by the Raspberry Pi itself.

Board Pinout:
  • D1 - I2C SCL
  • D2 - I2C SDA
  • D3 - Cool
  • D4 - Heat
  • D5 - Door Sensor
  • D6 - OneWire Data

Installation Instructions:
Full installation instructions are available here. If you prefer, I've also uploaded videos to YouTube showing how to , , and . If you've already used BrewPi then the process should feel very familiar - the only major difference is a small configuration change to brewpi-script and the fact that you are flashing the firmware through the command line rather than through the BrewPi interface.


As of right now the firmware appears to control temperature as I would expect -- for me, in my environment. Please test the firmware in your environment prior to hooking it up to heating/cooling equipment.

If you have any questions about this firmware or run into any issues, please post here or PM me and let me know. Hopefully you find this project useful and it helps you to make better beer!


Links:
brewpi-esp8266 - GitHub repo for the firmware
brewpi-esp8266/docs - The docs
brewpi-tools - The custom BrewPi tools repo
brewpi-script - The custom BrewPi script repo
YouTube - Playlist of installation instruction videos

Thanks
In working on this project I'd like to first thank ame and his wonderful Fuscus project as it was in working with him that the idea for this arose. I'd additionally like to thank Elco and the other people on the BrewPi team as - obviously - without BrewPi this project wouldn't exist.

Cheers,
Thorrak
:mug:
 
Last edited by a moderator:
That's pretty cool. I have a pi running a chamber with usb and another couple of Instances running on an old pc with Jessie. The ones on linked to the pc are wifi with esp 01 modules on UNOs. I use these for monitoring things like fridges and spaces where I am bottle conditioning. I was going to go the nano with a esp01. But these look even easier and cheaper. I'll see if I can get my hands on one for a play.
 
This is on my list for right after I get the BT minions working .... obviously this would replace the BT but I have to do one thing at a time. :)
 
I think I may be coming in too early and the "moron" instructions are not ready yet.

After flashing the ESP8266 with your Pi ... this completely replaces the Arduino? At first I thought this became a wireless interface for the arduino but reading again it seems like the Arduino is completely out of the equation?

I have a couple WeMos D1 Mini ordered from AliExpress. They should be here in ... a few weeks I guess. Great price though.
 
I think I may be coming in too early and the "moron" instructions are not ready yet.

After flashing the ESP8266 with your Pi ... this completely replaces the Arduino? At first I thought this became a wireless interface for the arduino but reading again it seems like the Arduino is completely out of the equation?

I have a couple WeMos D1 Mini ordered from AliExpress. They should be here in ... a few weeks I guess. Great price though.

Yep - this is a complete replacement for the Arduino. You will need the custom BrewPi script as well to interface with it given that it doesn't hook up via USB, but otherwise it should be pretty much a direct replacement to the controller you know and love.
 
I went and did a little reading on this device ... crazy how much more memory this little guy has! I'm excited to try it out.

I guess it will be limited by the number of I/O pins available then?
 
I went and did a little reading on this device ... crazy how much more memory this little guy has! I'm excited to try it out.

I guess it will be limited by the number of I/O pins available then?

Yep. The heaviest version of the firmware I have on GitHub only uses ~30% of the available program space (and there's 3MB of file storage beyond that if there was any reason to want to store log data or something) and ~50% of the RAM. That's including the overhead for WiFi support. Theoretically

As far as GPIO pins go, I figure I need a minimum of 7 to get the majority of the features working (1 for OneWire, 2 for the relays (though I could use OneWire switches and eliminate these), 2 for an I2C LCD screen, 1 for a door switch, and 1 for a buzzer). Given that the board only has ~10, we're slightly short for rotary encoder support unfortunately.
 
This is cool.
I am playing BrewPi and ESP8266 for a while, thinking to eliminate the Pi and the Arduino.
Based on your porting, I think I might be able to make it work.
 
This is cool.
I am playing BrewPi and ESP8266 for a while, thinking to eliminate the Pi and the Arduino.
Based on your porting, I think I might be able to make it work.

So you will log data on the ESP8266 and run the webserver on it too?
 
So you will log data on the ESP8266 and run the webserver on it too?

Yes. I ran a web server on it. I've finished most of the code and am going to test it after setting up the hardware.

My build will only use one ESP8266. no Arduino, no Pi. There are web pages to see the LCD display, like BrewPi, to control the temperature, like BrewPi but without graphics, and to setup the temperature sensors like BrewPi. The BEER profile works too. ( I don't use jQuery for resource issue, so the interface is sort of ugly compared to BrewPi.)

I've tried to log data to GoogleSheet but failed. The test code works, but it doesn't work with other functions. The reason seems like that ESP8266 allows only one connection when using HTTPS. Unfortunately, google service is only available through HTTPS. There are some alternative options, like invoke a user-defined URL with temperature data periodically, by which the data can be processed by other platform. I myself have multiple NAS in my home, but I don't fee like to use mySql. It is too lousy.
 
I sort of made LCD work by porting the IicLcd to ESP8266.

https://doomlab.wordpress.com/2015/03/03/brewpi-i2c-version/

Display.h/Display.cpp have to be modified as described.
Use the IicLcd.h and IicLcd.cpp, and change twi_ interface to Wire interface. Then, it will work.

...and there you go. I need to tweak the backlight management code slightly (remove the auto timeout, add a serial command to toggle the backlight on and off) but other than that it works perfectly.

Thanks! I'll push the updated firmware later today!

esp_lcd.JPG
 
...and there you go. I need to tweak the backlight management code slightly (remove the auto timeout, add a serial command to toggle the backlight on and off) but other than that it works perfectly.

Thanks! I'll push the updated firmware later today!



Thanks to the assistance of pocketmon, I2C LCD support is now added. D1 is I2C SCL, D2 is I2C SDA. For now, this only works with LCD screens with an address of 0x27. Thankfully, that's most of them (at least that I've seen). If you have a screen that has a different address, PM me, and I'll recompile with that address enabled.
 

Man, I remember back when I started playing with Arduinos the WiFi shield was $70, the Arduino was $30, and you barely had any flash or RAM to play with. Now, you have all sorts of choices.

It will be interesting to see where this chip ends up. The Arduino ecosystem seems to support the ESP8266 fairly well (hence why I was able to get this project working without too much work) - If the RTL8710 ends up in the same place, that would be fantastic.
 
Man, I remember back when I started playing with Arduinos the WiFi shield was $70, the Arduino was $30, and you barely had any flash or RAM to play with. Now, you have all sorts of choices.

It will be interesting to see where this chip ends up. The Arduino ecosystem seems to support the ESP8266 fairly well (hence why I was able to get this project working without too much work) - If the RTL8710 ends up in the same place, that would be fantastic.
I didn't read the spec sheet because it is in Chinese -not sure if there is one wire support.
 
fwiw, I'd be surprised if "One-Wire Support" requires much more than a bit-banging driver.
Someone will write one eventually...

Cheers!
 
I have a couple WeMos D1 Mini ordered from AliExpress. They should be here in ... a few weeks I guess. Great price though.
The devices showed up yesterday. Not too bad. I'll probably try to get them connected without devices (and without soldering) before I break anything.
 
A couple of notes on your instructions/process:

Locate the IP address for your Raspberry Pi This can generally be done by executing arp -a | grep raspberry however you can also locate your Raspberry Pi by logging into your router and looking for the device.

All of the images I've used here recently have included support for zeroconf, so as soon as the host is on the network it is accessible by {hostname}.local.

When I was done with the install-esp8266.sh the script output (and your instructions) says:

The next step is to actually flash the firmware to your device. Unhook any other USB-to-serial bridges, hook the ESP8266 device up via a USB cable to your Raspberry Pi, then do the following:

sudo esptool.py --port /dev/ttyUSB0 write_flash -fm=dio -fs=32m 0x00000 /home/brewpi/esp8266/bin/brewpi-esp8266.v0.1.wifi.bin

The version that was just cloned was actually brewpi-esp8266.v0.2.wifi.bin. I changed to v0.2 and it flashed correctly.

Next, for the wirelss configuration:

Connect to this access point and open a web browser. (Some devices may automatically open one)

I was unable to get a browser window to open to the ESP8266 device using a variety of methods. Finally I reset the ESP8266 and I got the access point menu. It went off into la-la land a few more times and I needed to reset it a few more times and finally I got it configured.

When I did get it connected over IP I gott the following in the logs, not sure if this is right or not:

Jul 30 2016 14:48:03 Opening serial port
Jul 30 2016 14:48:13 No serial attached BrewPi found. Trying TCP serial (WiFi)
Jul 30 2016 14:48:13 Connecting to BrewPi ESP2384371.local on port 23
Jul 30 2016 14:48:14 Notification: Script started for beer 'My First BrewPi Run'
Jul 30 2016 14:48:24 Checking software version on controller...
Jul 30 2016 14:48:24 Found BrewPi v0.2.4, running commit 00000000, running on an ESP ESP8266 on port ESP2384371.local:23

Jul 30 2016 14:48:24 Warning: minimum BrewPi version compatible with this script is 0.4.0 but version number received is 0.2.4
Jul 30 2016 14:48:24 Warning: version number of local copy of logMessages.h does not match log version number received from controller.controller version = 1, local copy version = 3

Are those warnings okay?

Next, I'm unable to get the serial connection method to work. The instructions say:

Serial Config

wwwPath = /var/www/html port = /dev/cu.USBXXXXXXX

Note - Replace USBXXXXXXX with the name of the USB device you used when flashing the firmware.

I don't see where there was any name given/specified when flashing the firmware. I don't see anything remotely like that in the /dev/ folder other than the original /dev/ttyUSB0. If I use that I get:

Jul 30 2016 14:21:02 Opening serial port
Jul 30 2016 14:21:02 Notification: Script started for beer 'My First BrewPi Run'
Jul 30 2016 14:21:12 Checking software version on controller...
Jul 30 2016 14:21:22 Warning: Cannot receive version number from controller. Your controller is either not programmed or running a very old version of BrewPi. Please upload a new version of BrewPi to your controller.

So I'm 50% there (not counting devices), depending on the answer about the warnings with the IP setup.
 
The version that was just cloned was actually brewpi-esp8266.v0.2.wifi.bin. I changed to v0.2 and it flashed correctly.
Good catch - I added the LCD support in v0.2, and didn't update the version number in the documentation. I'll get that updated shortly.

I was unable to get a browser window to open to the ESP8266 device using a variety of methods. Finally I reset the ESP8266 and I got the access point menu. It went off into la-la land a few more times and I needed to reset it a few more times and finally I got it configured.
That's odd -- Every time I've reset the configuration & reconfigured, the access point has shown up almost immediately. It should work similarly to how it shows in the video - you connect to the access point, open a web browser, and are redirected to the "connect" page. On macs, it should pop up the "connect" page immediately. Once the ESP8266 connects to your wireless network it will save the configuration details, and default to that network as long as it is available.

When I did get it connected over IP I gott the following in the logs, not sure if this is right or not:
...
Are those warnings okay?
Yep! Those warnings are OK. I need to recheck the code at some point & update the version number. Once that's done, the error should disappear.

Next, I'm unable to get the serial connection method to work. The instructions say:
...
I don't see where there was any name given/specified when flashing the firmware. I don't see anything remotely like that in the /dev/ folder other than the original /dev/ttyUSB0.
That's correct on the serial port - You're using the same device name that you used to flash the microcontroller if you want to connect via serial.

One thing to note - you can only use one connection method - either serial or WiFi. If you use the WiFi firmware, you need to use the WiFi connection method. If you use the serial firmware, you need to connect via serial. Both connection methods support all the same functionality.

I recommend connecting via WiFi, of course (fewer cables!), but serial is an option if you prefer it.

So I'm 50% there (not counting devices), depending on the answer about the warnings with the IP setup.

It sounds like you're a lot further along than 50%! Let me know if you run into any other issues, or have additional feedback.
 
That's odd -- Every time I've reset the configuration & reconfigured, the access point has shown up almost immediately.
It may be something flaky on my side. I'll try the second device and see if I have the same issues.

If you use the WiFi firmware, you need to use the WiFi connection method. If you use the serial firmware, you need to connect via serial.
Doh ... that was my issue. I misunderstood/ignored that part. I was trying Serial with the WiFi firmware. :)

Now I guess it's time to bust out the soldering iron and try not to destroy the little bugger.
 
Okay now for what may be the most important question :p ... which way to solder on the headers? Using female Dupont blocks seems best for the wiring so I figured male headers are best. Which side is "up?"

IMG_5331.jpg


IMG_5332.jpg
 
An additional thought: I went looking for features of the ESP8266 and was unable to find out if this is possible BUT ... it would be nice to be able to rename the device (i.e. "Old_Fridge", "Keezer", "Chamber_1") during the setup. That would also require support for configuration after initial setup when it's already in station mode.

I have been trying just about all the different BrewPi variants out there and I think this one is the easiest so far to get running (aside from the original USB/serial-attached Arduino). The price point is right and the size of this is phenomenal. Thank you for your work on this.

Regarding additional functionality, I did find this article about using a rotary encoder with one one analog pin. Not sure if you have seen it:

http://hackaday.com/2015/06/15/king-of-clever-reads-4-pin-rotary-encoder-with-one-analog-pin/
 
An additional thought: I went looking for features of the ESP8266 and was unable to find out if this is possible BUT ... it would be nice to be able to rename the device (i.e. "Old_Fridge", "Keezer", "Chamber_1") during the setup. That would also require support for configuration after initial setup when it's already in station mode.

Unfortunately, the chamber settings are done in the BrewPi script/web interface, and not on the firmware. Of course, nothing's preventing either from being adapted (but its not quite in scope for this specific project).

I have been trying just about all the different BrewPi variants out there and I think this one is the easiest so far to get running (aside from the original USB/serial-attached Arduino). The price point is right and the size of this is phenomenal. Thank you for your work on this.

Thanks! Once I got everything working, I thought so as well. Run a few scripts, plug the device into the Raspberry Pi, and you're off to the races. Oh, and you also get WiFi support. Can't forget that!

Regarding additional functionality, I did find this article about using a rotary encoder with one one analog pin. Not sure if you have seen it:

http://hackaday.com/2015/06/15/king-of-clever-reads-4-pin-rotary-encoder-with-one-analog-pin/

I hadn't seen that one, actually. Ame - the guy who created the python version of the BrewPi firmware - actually sent across a couple of suggestions for how to get the rotary encoder working as well. I'm still thinking that we're short a few pins, but we'll see. It's not a feature I use too frequently - I figure that one of the main advantages of BrewPi is the web interface, so why not use that.

I'm actually thinking I might try to get some kind of LCD backlight toggle added instead of full rotary encoder support. That's one feature I will miss from not having rotary encoder support!
 
Unfortunately, the chamber settings are done in the BrewPi script/web interface, and not on the firmware. Of course, nothing's preventing either from being adapted (but its not quite in scope for this specific project).
Sorry, I was unclear.

I mean rename the actual ESP8266 network device in case there are multiples so that you can tell them apart more easily.

I'd actually vote for the second pic, but only because I have this plugged into a breadboard. All in how you use it, I suppose!
There are headers included that will allow pins above and below too for breadboard use.

It was more tongue in cheek really ... but if all of us do it similarly, when it comes time to do a "hey what the heck did I do wrong?" it might make it easier for you all to help me. :)
 
Sorry, I was unclear.

I mean rename the actual ESP8266 network device in case there are multiples so that you can tell them apart more easily.

Oh. Yeah, that makes sense. I can probably do that by adding a custom command to the firmware (you'd connect to the ESP8266 device via telnet, give it a custom command, and it would rename it's mDNS hostname), but it's going to feel hackish given that the BrewPi script/website don't support it natively.

Still though - hackish and working, is better than polished but useless!
 
[...]Still though - hackish and working, is better than polished but useless!

Words to live by, imo ;)

But I get the request, as I have four BrewPi "instances" running, one over USB but the others over wireless/serial adapters, and keeping track of all the dongles would be a pita if I hadn't been able to change their hostnames...

Cheers!
 
Words to live by, imo ;)

But I get the request, as I have four BrewPi "instances" running, one over USB but the others over wireless/serial adapters, and keeping track of all the dongles would be a pita if I hadn't been able to change their hostnames...

Cheers!

Now that I think about it, there actually may be a way to request a new mDNS name at the time of initial setup. I'll have to do some digging. Projects!
 
Full disclosure - I've been having some weird issues with my "experimental" controller which lives on my desk. After doing some digging, I don't think that my MicroUSB power supply is providing enough power to run the LCD, Relay, and ESP8266. It was fine before I added the LCD, but now...

In any case, the fix is pretty simple - Hook up a beefier power supply. I've got one on my desk, now I just need to solder on some leads and try it out. Projects!
 
Back
Top