vitotai / BrewPiLess

Use an ESP8266 to replace RPI and Arduino. Running BrewPi without Pi, therefore, BrewPi-Less
357 stars 134 forks source link

Porting to ESP32 #128

Open ferchinas opened 6 years ago

ferchinas commented 6 years ago

Hi Vito: There is so far some work done to port to ESP32? I think there are many advantages as mensions in http://vito.tw/?p=720#comment-25109

I offer to collaborate to the best of my ability Regards

allthepies commented 6 years ago

Hi,

I did start a port attempt some time ago but my lack of C++ expertise made me stop, too many errors!

vitotai commented 6 years ago

I tried my best to make it compiled. However, there seems like some library issue with platformio. ESP32 uses whole different flash layout. I need to study it to make it work. Before that, I am stuck on the LCD display with framework 1.8.0.

You can try if you want. https://github.com/vitotai/BrewPiLess/tree/ESP32Attempt

ferchinas commented 6 years ago

Hello: I tried to compile but as mentioned @allthepies, there are too many errors.

Have you been able to detect which libraries have conflict? I am not familiar with the Brewpiless code, is it possible to isolate parts of the code to be able to correct by parts? Anyway, as soon as I have a time I will try the branch that you just shared with me.

I will return with news, Thank you

El jue., 4 oct. 2018 a las 5:18, vitotai (notifications@github.com) escribió:

I tried my best to make it compiled. However, there seems like some library issue with platformio. ESP32 uses whole different flash layout. I need to study it to make it work. Before that, I am stuck on the LCD display with framework 1.8.0.

You can try if you want. https://github.com/vitotai/BrewPiLess/tree/ESP32Attempt

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vitotai/BrewPiLess/issues/128#issuecomment-426927238, or mute the thread https://github.com/notifications/unsubscribe-auth/AcqFZ4R5vHFFLbo0KkFtvtBM6oPFuxVaks5uhcREgaJpZM4XEkBM .

ferchinas commented 6 years ago

Hi Vito: I was with little time these weeks, yesterday I could compile and load it in my esp32.

This is the serial output:

Setup () SPIFFS.being () Success. Init LCD ... LCD Initialized .. syscfg: 0, timeinfo: 156, gdc: 168, tempSchedule: 204, brewStatus: 300, logFileIndexes: 320, remoteLogginInfo: 636, autoCapSettings: 1080, parasiteTempControlSettings: 1092 Starting WiFi ... AP SSID: BrewPi pass: BrewPi AP Mode WiFi Donate! Load saved time: 36910 HTTP server started {"" W "," SPIFFS space: 1347040 start volatiel log mode ␀ => or startVolatileLog, mode = o, beerteemp = 32767

Start as AP, I can connect to the network from my cell phone but I can not access 192.168.4.1

Do you have any suggestion?

vitotai commented 6 years ago

It crashed when connected. I tried to decode the stack dump, and it seems like issues in WString.cpp. If the string library or use of it is a problem, there will be a lot of work to do. Not only I use it, but most of the libraries use it. I hesitated to use STRING for being not comfortable about memory management but ended up using it because of convenience. Now we have it.

zorce commented 5 years ago

Also interested in an esp32 port. And will gladly help out.

exige81 commented 5 years ago

I also plan on digging into this with the ultimate goal of integrating the tilt hydrometer

vitotai commented 5 years ago

Hi all, I made some progress. (Honestly, upgrading to 1.9 framework seems to be the biggest one.) Please check here: https://github.com/vitotai/BrewPiLess/tree/ESP32.test

The way to make ESP32 save network information seems to complicated for general user, or to me. Therefore, I coded to manually save it. There are some issues in the WiFiSetup Class, too. I found Auto Reconnect doesn't behavior as what I've thought.

The next step is defining PIN usage. What do you think?

allthepies commented 5 years ago

Great stuff Vito! What does it do so far ?

vitotai commented 5 years ago

螢幕快照 2019-09-12 下午5 02 08

There seems to be issues related to AsyncTcp library, and WebSocket doesn't work as expected. I am investigating this issue.

lbussy commented 5 years ago

There's a ton of potential there with the ESP32, however, so far I've not found it as stable. Whether it's the core or the supporting libs, it just doesn't seem to be as dependable as the ESP8266. That's a damned shame.

I'm hoping the ESP32-S2's arrival will re-spark the community around these chips and they will get some additional love.

exige81 commented 5 years ago

@vitotai regarding AsyncTCP i assume you are getting the issue where the wifiscan data isn't being returned properly? At least that's where i've hit trouble in my own efforts. Scan results are being generated but the response is not being sent. Interestingly enough, every once in a while it works just fine.

Regarding pins, in my config.h i've avoided pins 12-15 as they are the hardware debug pins on the dev board i'm using (nodemcu-32s). Recently found the inexpensive ESP-prog JTAG debugger which works with PIO, and got it up and running using this tutorial perhaps that might be useful to those working on this.

vitotai commented 5 years ago

@vitotai regarding AsyncTCP i assume you are getting the issue where the wifiscan data isn't being returned properly? At least that's where i've hit trouble in my own efforts. Scan results are being generated but the response is not being sent. Interestingly enough, every once in a while it works just fine.

Regarding pins, in my config.h i've avoided pins 12-15 as they are the hardware debug pins on the dev board i'm using (nodemcu-32s). Recently found the inexpensive ESP-prog JTAG debugger which works with PIO, and got it up and running using this tutorial perhaps that might be useful to those working on this.

Thank you for the head-up about PIN usages. It is what I am looking for. I too buy a JTAG debugger because I don't have any idea about the WString exception, which disappears after upgrading to 1.9 framework. I haven't setup the debugger, and thank you for the information, too.

If you turned on the debug message, you can see some "Too Many Message..." message, which is printed by WebSocket plug-in. My guts tells me that it might be the same cause of not-sending data and it might be something related to the "GreetingInMainLoop" option, which is a work-around for a design flaw I found in ESPAsyncTCP library. We'll see after I return home.

vitotai commented 5 years ago

I was wrong. It's wasn't what I have thought, but I make it work by workaround without knowing the exact cause of issue.

The problem now is that the sensor cannot be detected.

ithinkido commented 5 years ago

https://github.com/brettbeeson/esp32/tree/master/brew32

vitotai commented 5 years ago

Some update:

  1. DS18B20 doesn't work on certain PINs, like 25 and 26. I am not sure if it is just my board.
  2. My latest push seems to work fine, although there are still some issues.
  3. Working on Rotary Encoder now, but I need JTAG to work for an crash.
exige81 commented 5 years ago

Happy to see all of the positive progress on this, thanks so much for your effort.

I can report that PIN 25 and 26 are working with the DS18B20 both in BPL and simple test programs on my board. I'm using the NodeMCU-32S devkit. Pins 25 & 26 are DAC pins but that really shouldn't matter so not 100% sure what would cause it not to work.

I've noticed a little bit of instability with the latest push, including a seemingly random crash/reboot, and the wifiscan is still giving problems, but at least everything seems to be generally working. I need to order some more hardware and may be able to help diagnose some issues in the coming weeks when I can find the time.

Thanks again

vitotai commented 5 years ago

Basically, the rotary encoder works. However, I am stuck at a exception:

Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)

Mine works fine. At least it survived through 24 hours if I don't touch anything. Do you using "local logging"? I am guessing something wrong with FLASH writing.

vitotai commented 5 years ago

https://youtu.be/B2wUG_49lAk

The rotary encoder is working now!

I went to wrong directions because of not familiar or ignoring Harvard architecture of ESP32.

vitotai commented 5 years ago

The WiFi scanning issue should have something to do with "WiFi Auto Reconnect", which will causes disconnection in AP mode. It might because that WiFi library uses all resource to search lost network. Try this branch. (My git tree are a mess now, and I can't push to previous branch.) https://github.com/vitotai/BrewPiLess/tree/ESP32.trial

exige81 commented 5 years ago

Just uploaded that branch and I can confirm the WiFi issue seems to be resolved and is working properly. Good job!

Did notice that the latest doesn't seem to be detecting my onewire temp sensors, but that could be an issue on my end. I'll look into it deeper once i get some more time.

vitotai commented 5 years ago

Try the latest push, which includes an OneWire library. The discussion: https://github.com/espressif/arduino-esp32/issues/1335

I've tried back and forth, with and without this OneWire library. Sometimes it makes differences, sometimes it doesn't. It should depends on the run-time condition of I-CACHE.

exige81 commented 5 years ago

That seems to have solved it for me. Thanks!

allthepies commented 5 years ago

Compilation errors on ESP32.trial:

src/TempControl.cpp: In static member function 'static void TempControl::increaseEstimator(temperature*, temperature)':
src/TempControl.cpp:500:55: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type {aka double}' and 'int' to binary 'operator
>>'
  temperature factor = 614 + constrainTemp(abs(error)>>5, 0, 154); // 1.2 + 3.1% of error, limit between 1.2 and 1.5
                                                       ^
src/TempControl.cpp: In static member function 'static void TempControl::decreaseEstimator(temperature*, temperature)':
src/TempControl.cpp:510:55: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type {aka double}' and 'int' to binary 'operator
>>'
exige81 commented 5 years ago

@allthepies This is an issue with the latest version of arduino-esp32 (v1.0.3), which is now used in the latest version of platform-espressif32 (1.10.0). I've submitted the issue with espressif here.

For now you can fix the issue in your platformio.ini by setting platform = espressif32@1.9.0

allthepies commented 5 years ago

Thanks, compiles with that workaround.

vitotai commented 5 years ago

I've experienced compiling errors, unexpected exceptions, and etc. Upgrading to framework 1.9.0 seems to solve most of the problems.

Now that all functions I've thought of are working, I am thinking the next step. BLE has been tried, but it takes too much memory to work with. I will wait until NimBLE library is available. HTTPS seems not yet supported on ESP32. What do you have in mind?

exige81 commented 5 years ago

Eventually i'd like to get the Tilt Hydrometer working which will require BLE. I'm sure you've seen the tiltbridge project. Hydrometer data doesn't need to be checked continuously so maybe it would be possible to poll for data every 15 minutes so that might be a viable way to work around the memory issues?

Maybe a next step would be to abstract out the gravity code so that in the future it would be easier to switch devices since everything is tightly integrated around the iSpindle.

vitotai commented 5 years ago

Frequency doesn't matter in this case. It's about memory, not computing power.

It's easy to integrate Tilt. The problem is that I don't have a Title to test.

Naesstrom commented 5 years ago

Saw the vid that you got the potentiometer rotary encoder to work, great job! Have you decided on a pinout yet? Was thinking of making a few PCB's for the ESP32 version!

stefschin commented 5 years ago

Hi, I can help to make a PCB design for this project. Let me know if you're interested

vitotai commented 5 years ago

Saw the vid that you got the potentiometer to work, great job! Have you decided on a pinout yet? Was thinking of making a few PCB's for the ESP32 version!

It's a rotary encoder, not potentiometer. They look alike, but different. BTW, the one I am using is KY-040 module.

Hi, I can help to make a PCB design for this project. Let me know if you're interested

Any help is welcome. I don't have the ability to design PCBs, neither can I know how good or bad the design is.

So far, the PIN allocation is listed in the table. https://github.com/vitotai/BrewPiLess/blob/ESP32.trial/doc/ESP32Pins.md

stefschin commented 5 years ago

Ok, no problem, I will use ESP32 Kit V1, ok? Optional external Supply input, and which connectors you prefer? For sensors and buttons I like Terminal Blocks. For display and Relay Board we can use same pins as modules, or did you prefer On board Relay?

vitotai commented 5 years ago

I don't know the differences between ESP32 boards. I just picked what I can get from the vendor.

allthepies commented 5 years ago

Regarding the PCB. My idea scenario would be for a similar board to this one:

http://vito.tw/brewmaniacex-brewshield/

I use this board for my brewfridge controlled by BrewPiLess and a friend uses the same board to control his brewing kit using BrewManiacEx. With ESP32 it could probably be simplified as the port expander may not be required.

Edit: Looks like a lot of the links have broken on Vito's new blog

Hwerow commented 4 years ago

I have built the hardware to try out the ESP32 and rotary switch and have modified the IO in config.h #define rotarySwitchPin 25 to 27 as it was double allocated. I built it in VSC and tried to upload to the ESP32 but got a load of what looked like software error messages. Then I tried to upload the bin file v4.0a2.esp.bin using the ESP Download Tool V.3.6.8 and Win7 to see if that worked but with no success. I ended up with this - see screen shot - but I don't know what I am doing! Please could you help. image

vitotai commented 4 years ago

I never used ESP Download Tool V.3.6.8 and can't help.

Hwerow commented 4 years ago

OK . Please could you tell me what you did to upload and then how did you access BPL on the ESP32

vitotai commented 4 years ago

I use PlatformIO with VSCode to upload.

Hwerow commented 4 years ago

I have been using VSCode and PlatformIO but am getting errors with 4.0Pre when building for ESP32 like below

Processing esp32 (platform: espressif32@~1.9.0; board: esp32dev; framework: arduino)

Verbose mode can be enabled via -v, --verbose option CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html PLATFORM: Espressif 32 1.9.0 > Espressif ESP32 Dev Module HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa) PACKAGES:

Terminal will be reused by tasks, press any key to close it.

vitotai commented 4 years ago

Something wrong with your platform, IMO. Manually Delete ".platformio" directory under the project directory and try again.

Hwerow commented 4 years ago

After many attempts, I have got the ESP32 and rotary Encoder working. The encoder switch push button is on pin 27. I did what you suggested but I could not get the 4.0pre to build and upload on my Win7 PC yet other sketches worked. So I used my Ubuntu laptop and it built, albeit with errors (see attached). I could only get it to upload by commenting out ; upload_port = /dev/cu.SLAB_USBtoUART in the platformio.ini file.

Seems to be functioning OK. Next step solder it up and put it into a box Thanks for all your great work Cheers PS I could not get the classic interface to work

upload details.docx 2020-01-10 13 30 45sm

vitotai commented 4 years ago

The classic frontend was broken. It is temporarily fixed now. I am going to drop classic frontend at some time.

Naesstrom commented 4 years ago

Quick question, finally got around to assemble all the parts for the esp32 version. Should I use the esp32 branch or the v4 one?

vitotai commented 4 years ago

v4.0pre branch. Maintaining multiple branches is a PITA.

Naesstrom commented 4 years ago

v4.0pre branch. Maintaining multiple branches is a PITA.

hehe yeah I know... hate it! I'll flash it and try it out then! Just starting with the rotary, lcd, 2xds18b20 and a double relay. Ordered a 5V pressure sensor that I'll connect later!

Checking the pinout I see that the 2 remaining actuators can be used for fan & door but can't find the functions described anywhere. The fan is for circulation and door to?

BPL_32_schem

appi1 commented 4 years ago

is there a PCB for the ESP32 available? I want to swap from brewpiless esp8266 to ESP32 Version.

exige81 commented 4 years ago

Concerning BLE, it looks like plaformio-espressif32 released version 1.12 which added support for ESP-IDF 4.0, so that means that nimBLE should now be available to use. I haven't had time to try it out yet.

vitotai commented 4 years ago

v4.0pre branch. Maintaining multiple branches is a PITA.

hehe yeah I know... hate it! I'll flash it and try it out then! Just starting with the rotary, lcd, 2xds18b20 and a double relay. Ordered a 5V pressure sensor that I'll connect later!

Checking the pinout I see that the 2 remaining actuators can be used for fan & door but can't find the functions described anywhere. The fan is for circulation and door to?

BPL_32_schem

Sorry to miss your question. As far as I know, the door sensor is used to activate light, if assigned, and add annotations to chart. However, BrewPiLess doesn't show it on the chart, the display of LCD should show, though.

vitotai commented 4 years ago

is there a PCB for the ESP32 available? I want to swap from brewpiless esp8266 to ESP32 Version.

I don't know. A friend sent me one for reviewing, but I don't have the ability to review.