This section describes the code, how to upload the code to the ESP-12, and how to configure and calibrate the BeerBoi.
For writing and deploying the code, I use:
The Arduino IDE is used for compiling the code and uploading it to the ESP-12. It's decent for what it does, but it isn't the best code editor by a long way. It does have an option to use an external editor (File - Preferences - check "Use external editor"), so I set that and use the excellent jEdit for actual coding (disclaimer, maybe? I've been contributing to jEdit for years and am a project admin). The Arduino IDE provides a serial monitor, which is good for watching messages from BeerBoi as it runs. Of course, you don't have to use these tools, the Arduino IDE by itself is enough.
Since this project is using an ESP8266 based board, you'll need to add an additional URL to the Arduino Board Manager. Start up the Arduino IDE,
then go to File - Preferences, then enter this line in the "Additional Boards Manager. URLs:" box:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
This will put the appropriate board definitions in the "Tools" menu. Select the appropriate board, in my case, I've got the
"LOLIN (WEMOS) D1 mini (clone)" selected, since that is what I have. Any of the ESP boards should be able to run this code, just be sure to pick the one
you actually have.
The project source code is arranged like this:
beerboi |- beerboi.fzz (fritzing file for the beerboi circuit) \- arduino libraries \- ArduinoJson (json library for reading and writing the configuration files) \- HX711-master (library for the weight scale) \- NTPClient (library to connect to an NTP server for the current time) \- WiFiManager (ESP8266 wifi connection manager) \- src |- beerboi.ino (the Arduino sketch for the boi) \- data (web pages and images for beerboi.local) |- about.html (an about page, some info about BeerBoi) |- calibration.html (web page to assist in calibrating a boi) |- configuration.html (web page for how often to read the gravity, time zone for reports, etc) |- d3.min.js (javascript to parse the boi data files for the chart) |- favicon.ico (cute icon, looks like BB) |- index.html (home page to read the gravity) |- style.css (style sheet for the web pages) \- sf (web pages and images for beerboi.org) \- images (images for beerboi.org) |- about.html |- assembly.html |- bootstrap.min.css (stored here so the ESP-12F doesn't have to serve it) |- chart.js (stored here so the ESP-12F doesn't have to serve it) |- code.html |- d3.v7.min.js (stored here so the ESP-12F doesn't have to serve it) |- faq.html |- favicon.ico |- index.html |- parts.html |- setup.html |- style.css
bootstrap.min.css is a style sheet that works nicely for big and little browser screens.
chart.js and d3.v7.min.js are javascript files that are used by the index.html page served
from the ESP-12F. I'm putting them on beerboi.org so that the ESP-12F doesn't have to serve
them. The ESP-12F is a low power device and isn't very speedy, so having the browser pull
these files from beerboi.org is much faster than letting the ESP serve them.
Everything in the src and data folders gets uploaded to the ESP-12.
Here is a direct link to beerboi.ino. It's heavily commented, so it should be pretty easy to understand.
The 'ESP8266 LittleFS Data Upload" will look for a 'data' directory in the same folder as the .ino file, and upload the
contents of that folder to the ESP-12F. Really what it does is make a binary file system image on the Arduino IDE side, then uploads that image
to the ESP-12 flash memory, which overwrites anything you previously had there, so you'll have to redo your configurations afterwards.
You can create a default configuration by creating a file named "configuration.json" in your 'data' directory like this:
{ "wifiSSID": "your_network_name", "wifiPassword": "your_network_password", "readFrequency": "60", "timeZone": "-6", "timeServer": "your_router_IP_address", "fsPercent": "85", "calibrationFactor": "1920", "boiWeight": "200.00", "m": "0.00900" }
The values for the configuration file can be found by clicking the link on the Configuration page, or by going to http://beerboi.local/configuration.json. Now when you upload the data directory, you'll already have a configuration file with the proper values. You can see your current configuration file at http://beerboi.local/configuration.json.
Creating BIN file "/tmp/arduino_build_XXXXXX/beerboi.ino.bin" (... lots more on that line)This line is up about 20 lines from the end. XXXXXX is a 6 digit number. This is the binary for the firmware.
[LittleFS] upload : /tmp/arduino_build_XXXXXX/beerboi.mklittlefs.binThis is the binary for the file system. XXXXXX is the same 6 digit number.
For the libraries that are in SVN, copy the complete folders to your Arduino libraries folder.
All of the code is in the BeerBoi project at SourceForge.
You can get a copy of the code by going to https://sourceforge.net/p/beerboi/code/HEAD/tree/trunk/
and clicking the "Download Snapshot" link.