# How I made my Brewpi wifi with esp8266



## Mattrox (30/1/16)

I thought I'd document what worked for me here rather than in the multi-chamber thread as to keep discussion about that topic there.



I am running Wheezy on an old computer connected to the home network. I installed the LAMP server as per instructions in point 1 here : 
http://docs.brewpi.com/index.html

I did a manual install (point 3) except you need to do these two commands instead of the ones listed as Brewpi via arduino is not the current version. But it works and is proven and so far still supported. 

At section 4. "Using Git for BrewPi", after running 


> $ sudo apt-get install git-core


use this command instead of the command at 4.2.1




> $ sudo -u brewpi git clone -b legacy https://github.com/BrewPi/brewpi-script /home/brewpi


Then




> $ sudo rm /var/www/*


and at 4.3.1



> $ sudo -u www-data git clone -b legacy  https://github.com/BrewPi/brewpi-www /var/www


to install the legacy version of BrewPi




I got the pictured Arduino compatible wifi board from ebay.







From the esp-link github page I followed the directions.

https://github.com/jeelabs/esp-link/releases/tag/v2.1.7



I just followed the instructions verbatum to install esptool.py



1)install ez_setup.py





> $ wget https://bootstrap.pypa.io/ez_setup.py
> 
> $ python ez_setup.py








2)install esptool.py




> $ git clone https://github.com/themadinventor/esptool.git
> 
> $ cd esptool
> 
> ...










The instructions to flash the esp8266 board are as follows: 



> $ curl -L https://github.com/jeelabs/esp-link/releases/download/v2.1.7/esp-link-v2.1.7.tgz \tar xzf -
> 
> 
> 
> ...





Now, I actually had to install "curl" 1st

I used this as a guide

http://www.jasom.net/how-to-install-curl-command-manually-on-debian-linux





> $ cd /usr/local/src
> 
> 
> 
> ...






Then I ran 





> $ curl -L https://github.com/jeelabs/esp-link/releases/download/v2.1.7/esp-link-v2.1.7.tgz \tar xzf -
> 
> 
> 
> $ cd esp-link-v2.1.7






then plugged in the wifi unit and used the command






> $ esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash -fs 32m -ff 80m \0x00000 boot_v1.4\(b1\).bin 0x1000 user1.bin 0x3FE000 blank.bin


----------



## Mattrox (30/1/16)

I found the esp-link web interface. I think I found the IP from looking on my smart phone, can't remember. but typed the IP into the browser on my computer to configure the esp settings


On the wifi tab I logged I set my ip to fixed and chose 10.1.1.15 to be consistent with the home network addressing and I selected my home network SSID and entered the password.



I then went to the modem/router web interface and made sure I found the esp device and set it as a static IP on the network too.



On the home tab on the esp-link interface

View attachment 86449


I used the pin assignments

reset - gpio12

conn led - gpio0

serial led - gpio14

UART - normal

rx pull up tick-box ticked



Then I did:





> $ sudo nano /home/brewpi/BrewPiUtil.py


 
and changed 

"ser = serial.Serial(port, baudrate=baud_rate, timeout=time_out, write_timeout=0)"



to 





> ser = serial.serial_for_url(port, baudrate=baud_rate, timeout=1, write_timeout=0)


 


and then 






> $ sudo nano /home/brewpi/settings/config.cfg






and changed

"port = /dev/ttyACM0" (mine was actually port = /dev/ttyUSB0)

to





> port = socket://10.1.1.15:23


 




I then wired the esp board to the arduino and started the python script again.





> $ sudo -u brewpi python /home/brewpi/brewpi.py


 


Wiring from Arduino to esp8266 board.

5V --> VIN

GND --> GND

tx --> rx

rx --> tx 

RES --> D12

View attachment 86448


To flash the Arduino you have to go to uC Console tab on the esp web interface and change the baud from 57600 which is what is required to run Brewpi to 115200. After flashing change it back to 57600.

I was able to flash the Uno with the hex this is the command I used




> $ sudo /usr/share/arduino/hardware/tools/avrdude -F -e -p m328p -c arduino -b 115200 -P net:10.1.1.15:23 -U flash:w:/home/brewpi/Downloads/brewpi-arduino-uno-revC-0_2_10.hex -C /usr/share/arduino/hardware/tools/avrdude.conf





note the m328p is slightly different than others used in this thread, but that is what my version of avrdude needed.

You get the HEX file from here.
https://github.com/BrewPi/firmware/releases

For the Uno you want to download the file with this file name, make sure you are under the 0.2.10 release
*brewpi-arduino-uno-revC-0_2_10.hex*


If you don't have the wifi running to flash the Arduino Uno, you will probably need to download and use Xloader to flash the hex file from a Windows machine.


It wouldn't let me do this in one post because of too many quotes....


----------



## Benn (30/1/16)

That's just crazy man 
..is there a "TV Repair" van parked across the road from your house at the moment?


----------



## Benn (30/1/16)

If there is, I'd say your under surveillance.


----------



## Mattrox (30/1/16)

Benn said:


> If there is, I'd say your under surveillance.


If there is, he can smell my super hoppy APA with Columbus and Simcoe wafting out of the kitchen from the kits and bits I just put together with way too many IBUs for a 5.2% beer.


----------



## Tex N Oz (30/1/16)

Wow!! That's awesome. 
I'm ordering 6 tonight!! 
Can't wait to get this up and running too.


----------



## Mattrox (30/1/16)

Tex N Oz said:


> Wow!! That's awesome.
> I'm ordering 6 tonight!!
> Can't wait to get this up and running too.


The best bit is "Imnotevenworriedmeme.jpg" about the 5V Arduino and 3.3V esp chip and having to build up circuitry so they can talk. It is easy as.

And I knew sweet FA about linux systems before November/December.


----------



## Tex N Oz (31/1/16)

Mattrox said:


> The best bit is "Imnotevenworriedmeme.jpg" about the 5V Arduino and 3.3V esp chip and having to build up circuitry so they can talk. It is easy as.
> 
> And I knew sweet FA about linux systems before November/December.


I'm impressed it's all hardware driven (on the Arduino at least).
The temptation is there to give the blue-tooth a go as well but I'm thinking it's not that easy and might have to load libraries. That's impossible to do on with a HEX flash.
I'll have to research it up a bit.


----------



## Mattrox (31/1/16)

Tex N Oz said:


> I'm impressed it's all hardware driven (on the Arduino at least).
> The temptation is there to give the blue-tooth a go as well but I'm thinking it's not that easy and might have to load libraries. That's impossible to do on with a HEX flash.
> I'll have to research it up a bit.


Here is how to do it Bluetooth.
http://www.homebrewtalk.com/showthread.php?t=508151


----------



## CmdrRyekr (1/2/16)

That's far too complex for what it should be. Most of that could be eliminated by eliminating the Arduino; if only the BrewPi project would realise that a RasPi is actually stable enough to not need the Arduino, when it's powered by proper power.


----------



## MastersBrewery (1/2/16)

CmdrRyekr said:


> That's far too complex for what it should be. Most of that could be eliminated by eliminating the Arduino; if only the BrewPi project would realise that a RasPi is actually stable enough to not need the Arduino, when it's powered by proper power.


Yes but 3 or four chamber could get a bit costly.


----------



## Tex N Oz (1/2/16)

CmdrRyekr said:


> That's far too complex for what it should be. Most of that could be eliminated by eliminating the Arduino; if only the BrewPi project would realise that a RasPi is actually stable enough to not need the Arduino, when it's powered by proper power.


I don't think I'd trust a Raspberry Pi to do the job of a controller. They are just too unstable. There are not many micro-processors I would trust. Why risk your brew over $20 in gear that will be rock solid for years and years? Elco Jacobs, the original programmer and designer of the Brewpi completely dismissed using a micro-processor for just that reason. Each unit stand-alone and independent of what the other controllers or the RPi is doing.


----------



## Mattrox (1/2/16)

CmdrRyekr said:


> That's far too complex for what it should be. Most of that could be eliminated by eliminating the Arduino; if only the BrewPi project would realise that a RasPi is actually stable enough to not need the Arduino, when it's powered by proper power.


It's really a moot point. This is the way the designers thought best. And it's proven and stable.

And even if a RPi solution were more elegant, I don't think there is one I've seen around the traps that is widely available and supported by the developer. And I couldn't develop one myself.

Being able to run it from a Linux machine has meant it was really cheap to set up. 

The computer was free, Chinese Uno $6, relay $3, one wire probes $10 for 5 or something. The optional wifi was $15. The rest is going to be the same as the STC 1000 eg Box, power points, etc. Pretty good for PID control of a ferment, remotely accessable. Even if it is clunkier than it could be.


----------



## fraser_john (1/2/16)

All I can say is well done Mattrox, stepping into Linux is a great choice, I only use Windoze at work now and run three Ubuntu boxes at home. Plus for the price you have spent and what you have learned, it is a great project.


----------



## CmdrRyekr (1/2/16)

Tex N Oz said:


> I don't think I'd trust a Raspberry Pi to do the job of a controller. They are just too unstable. There are not many micro-processors I would trust. Why risk your brew over $20 in gear that will be rock solid for years and years? Elco Jacobs, the original programmer and designer of the Brewpi completely dismissed using a micro-processor for just that reason. Each unit stand-alone and independent of what the other controllers or the RPi is doing.


They are absolutely not unstable when powered correctly, as the BrewPi 'developer' seems to think. We use RasPis in our house for delivering media to our TVs with Kodi. Kids watch for hours during the day, then we watch content at night. They run 24x7 and are never shut down. After the initial couple of months (mentioned below) I could count perhaps 5 occasions where it's been what I would call unstable in the past 4 years we've been using them.

When they first came out, we used a Samsung phone charger to power them as was the suggestion at the time - and yest it was kind of flaky. Needed a reboot occasionally. Phone chargers are not designed to run constantly day in day out, and if you're doing that - then of course you're going to have issues.

With a dedicated 5v supply, we've had no issues for years.

Also, you're aware Arduino is micro-controller based too, yeah?


----------



## CmdrRyekr (1/2/16)

Anyway, moving on. Sorry for the spam. Fairplay Mattrox, Linux is great, keep it up!


----------



## Mattrox (5/10/16)

I decided that when I FINALLY get this into a box, having the LCD option to look at when I open the fridge would be useful.

I followed the instructions to build a DIY shield.... (and while the parts were on thier way from china someone designed a PCB which would have been far easier)... but anyway, I got time today to complete the build.


----------



## ame (5/10/16)

I have been working on a native Python version of the BrewPi controller, which basically replaces the Arduino with a Python script (so, no Arduino needed).

If you are interested you can follow the thread here:
http://www.homebrewtalk.com/showthread.php?t=575724

There have also been some interesting developments using the ESP8266 modules to implement the BrewPi functionality with and without a Pi.


----------

