[ETA: In order to "Future-Proof" this post, I've made a version on the BrewPi Remix website which I will be able to update as needed.
Please see it here.]
I wanted to be able to support BrewPi Remix over WiFi, and this thread gave me some great ideas. The script support for this has been in BrewPi Remix since 0.5.1.2 I think, it's definitely in the current 0.5.2.0 release. Here's how to pull it off:
Buy yourself one of these fancy UNO R3 (ATmega328P) + WiFi (ESP8266) cards currently priced at $6.49 ... get a couple just in case. I expect any of the others out there will work as well with some changes but you are on your own if you go a different direction:
UNO+WiFi R3 ATmega328P+ESP8266 Module 32Mb Memory USB-TTL CH340G Compatible For Arduino
You might need to Google up some drivers for the CH340 chip if you are using your PC, 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 to let the CH340 talk to the ESP8266.
Switch configuration to allow CH340 to connect to ESP8266 (upload sketch to the ESP8266):
- Off
- Off
- Off
- Off
- On
- On
- On
- Off (Do Not Use)
Go ahead and plug the board in to your PC to hear the pleasing "boing" showing you that it connected. Now 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.
Now you will need some firmware for the ESP8266 side. First, download
"esp-link" version 2.2.3 from the releases page. I should point out that this is not the most current and right now I can't tell you WHY I used this version. I'll probably try one of the 3.x versions later on but for now, I know this works.
You will also need the
esp_init_data_default.bin file from the Expressif Systems GitHub.
Go ahead and execute the NodeMCU Firmware Programmer and set up the following firmware images at the addresses indicated on the "Config" tab:
- boot_v1.5.bin @ 0x00000
- blank.bin @ 3FE000
- esp_init_data_default.bin @ 0x3FC000
- user1.bin @ 0x01000
If you are curious about the "Advanced" tab, I did not make any changes. The settings were:
- Baudrate: 230400
- Flash size: 4MByte
- Flash speed: 40MHz
- SPIO mode: DIO
On the "Operation" tab, select the proper COM port, then click "Flash".
When complete, go ahead and close, unplug, and set the switches to connect the CH340 to the ATmega328:
Switch configuration to allow the CH340 to connect to the ATmega328 (upload sketch to the ATmega328):
- Off
- Off
- On
- On
- Off
- Off
- Off
- Off (Do Not Use)
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 it 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.
Switch configuration to allow the ESP8266 to connect to the ATmega328 (normal operation):
- On
- On
- Off
- Off
- Off
- Off
- Off
- Off (Do Not Use)
Unplug from your Pi and 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.) 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:
Code:
port = socket://192.168.168.143:23
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 it off the ICSP header. This header does not line up with the combo board. So, you must jumper 5v and ground off the header on the shield to the ICSP header on the shield and all will be well.