Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 upgrade? #2

Closed
darkside90a opened this issue Feb 14, 2023 · 26 comments
Closed

ESP32 upgrade? #2

darkside90a opened this issue Feb 14, 2023 · 26 comments
Assignees
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Milestone

Comments

@darkside90a
Copy link

I've successfully built one from this project with a different solution of scale bases. Incredible stable, even with v0.5.0b7 installed. Deviations are just 0.06 and 0.04%.
ESP8266 web interface is a bit slow though. I'd love to see an ESP32 variant, for instance based on ESP32-S2.
As I built the case unit as plug-in modules on a 60x80 experiment PCB (#90664) from Kjell&Co, it's really easy to replace the ESP8266. The whole unit fits snugly into a 120x70x35 case (#89026) from Kjell&Co.
DSC_1678

DSC_1683

@mp-se
Copy link
Owner

mp-se commented Feb 14, 2023

I've successfully built one from this project with a different solution of scale bases. Incredible stable, even with v0.5.0b7 installed. Deviations are just 0.06 and 0.04%. ESP8266 web interface is a bit slow though. I'd love to see an ESP32 variant, for instance based on ESP32-S2. As I built the case unit as plug-in modules on a 60x80 experiment PCB (#90664) from Kjell&Co, it's really easy to replace the ESP8266. The whole unit fits snugly into a 120x70x35 case (#89026) from Kjell&Co.

Nice build. I've used some similar PCB for my builds, once I'm happy with the hardware design I will create a pcb. I have also created a 3d printable case for my board. It looks like the same size board that I used (but I bought mine from electrokit)

I've experience that I get more variation when the scale is in the keezer and the temperature varies. Have you noticed anything around that part ?

I know the Web UI is a little sluggish but I dont think a esp32s2 board would help. The main issue is that reading the scales takes approx 400 ms each so that loop is the problem since that would not be faster on an esp32. So every read cycle (2 seconds) the CPU is blocked for 800 ms reading the scales.

I have been considering an esp32 but in that case it would be better with one that has more than one core like the older ESP32 D1 mini (that have 2 cores) or one of the development boards but then I loose the nice form factor. S2 and C3 only have one core each. But it's not that hard to port this to a esp32 for testing at least. Will do that once I'm happy with the stability.

Another option is to move to a AsyncWebServer which would be much faster and I'm probably going that route once the functionallity is more stable. That option can cause real crashed and reboots if there are issues with the code (can be unstable) and is not that easy to develop and test.

Let me know if you are missing any features.

@darkside90a
Copy link
Author

Thanks, a good explanation for not switching to ESP32-S2/C3.

I had more variations when the scales were outside the keezer. Maybe because of a more uneven surface.
Could your issues be how the load sensors are mounted in the base?
My base is made of 7mm plywood. The load sensor feet are modified versions of thingiverse #309451. The interconnect lid as well.
DSC_1679

I re-designed the "top" of the feet thicker + groove for a larger washer (M5x20).
Theoretically, load from the small notch on the load sensor is now spread over a larger area. The feet are really flexible too.
DSC_1663
DSC_1664

@mp-se
Copy link
Owner

mp-se commented Feb 14, 2023

That's a really god case for the scales. I will have a look at those and see if I can modify my 3d model so they are not exposed as of today.

I will test out both options (async) and (esp32s2) to see what improvements can be made. I getting to a state where I think the basic function are in place so its the next natural step to look at performance improvements.

@mp-se
Copy link
Owner

mp-se commented Feb 14, 2023

There is another option I will try as well, and that is a replacement for the HX711 board (sparkfun board) that uses i2c instead that should be much faster to get data from.

@darkside90a
Copy link
Author

Another theory around scale varations:
Still using your flat Cat6, are you?
I am using a round UTP Cat6 (Kjell&Co #39847).
Could your flat Cat6 be affected by EMI?
According to Sparkfun, YLW (= Ground, like BLK) on HX711 could be connected to the shield in one end of a shielded Cat6 to reduce EMI.
Unfortunately, that kind of cable would be much stiffer.
Maybe connecting the unused Brown/White to YLW reduces EMI as well?

@mp-se
Copy link
Owner

mp-se commented Feb 15, 2023

Yes, im using unshielded cat6 (flat) and i dont have interference outside the keezer. So my therory is that tempersture and compressor is causing the drift/interference. Its not a big deal so it might not be worth to fix…. But it could be worth to test just to know for sure

@mp-se mp-se added the enhancement New feature or request label Feb 15, 2023
@mp-se mp-se self-assigned this Feb 15, 2023
@mp-se
Copy link
Owner

mp-se commented Feb 16, 2023

I've added a firmware_async.bin that you can try out (dev stream). This moves to an async webserver with better response. Let me know what you think.

@darkside90a
Copy link
Author

Tried installing beta9 and beta10 (the async one) via web interface . After 15-20 seconds they both loop back to web portal mode. I also noticed none of them detected the temp sensor during boot.
What I did not try was installing beta9 or 10 from scratch, wiping flash first.

Uptime was long enough for me to reinstall the working beta7, which correctly detects both scales and tempsensor after a cold start.

I managed to catch a raw transcript via USB/minicom when running beta10 if that is of any help:

202302161535.txt

@mp-se
Copy link
Owner

mp-se commented Feb 16, 2023

Looks like it crashes when trying to return data to the ui for the index page.

The stack trace should help to narrow it down to the exact point

@mp-se
Copy link
Owner

mp-se commented Feb 17, 2023

Found the issue, I need to refactor some code so I don't call hardware/IO from the webserver, this is causing the device to crash.

I just did a couple of quick tests without any scale so I didnt see the problem.

@mp-se
Copy link
Owner

mp-se commented Feb 18, 2023

I had to refactor quite some code in order to make this work without issues. I have released a v0.5 now that I have tested the basic functions and calibration flow. That seams to work fine with the async option. I will upgrade my own keezer to this version and start to see if I can find any more issues. Thanks for the input. I will use this to improve the documentation when I have some time.

@mp-se mp-se added the documentation Improvements or additions to documentation label Feb 18, 2023
@mp-se mp-se modified the milestones: v0.5, v0.6 Feb 18, 2023
@darkside90a
Copy link
Author

Installed 0.5.0 async now.
Had to finish off calibration of 3x Gravitymon v1.3.0-b1 units first :-)
Whow, massive speed improvement!
Temperature sensor was shown not detected during a cold boot. But temp/humidity seems to be correct in web interface.
MQTT telegrams are coming through via Mosquitto to HA as well.
Thank you!

@mp-se
Copy link
Owner

mp-se commented Feb 19, 2023

Yes, the pins for scale 1 sometimes needs a hard reset to work. I have the same problems with the iSpindle and a soft reset and connection issues with the gyro. Have not found a solution around that other than doing a hard reset.

Yes, its much more responsive. The async webserver hooks into the internal delay/yield interrupts so it can serve data at any point without waiting for the loop. I'm moving that code to gravitymon as well to speed that up.

@mp-se
Copy link
Owner

mp-se commented Mar 3, 2023

@darkside90a I've done most of the coding for an esp32s2 chip with sync/async support. Still need to do some more testing. Let me know if you want to test that version.

@darkside90a
Copy link
Author

Sure, I can do some testing.
As long as pin compatibility is still similar to the ESP8266, I can easily plug in an ESP32-S2 instead

@mp-se
Copy link
Owner

mp-se commented Mar 3, 2023

It will be pin compatible, i will let you know when i have tested it

@mp-se
Copy link
Owner

mp-se commented Mar 5, 2023

You can try the 0.6 beta 1 version for the esp32s2.

@darkside90a
Copy link
Author

Great work!
Flashed and plugged in ESP32-s2 this morning.
Responsive web interface! You cannot get it better, unless the HX711 is replaced with a much more expensive i2c amplifier, like the NAU7802 mentioned by LBussy.

I have only found one issue(?) so far:
Configuration --> History graph
gives:
"Failed to load level history from device"

For those not very familiar with esptool.py, I found this approach of first-time flashing to work too:

  • Use Brewflasher to flash the ESP32-s2 device variant of Gravitymon
  • Configure WiFi
  • Connect to the Gravitymon web interface and go to Upload firmware.
  • Upload Kegmon ESP32-s2 beta binary firmware and reboot

Initially I tried to upgrade the ESP8266 D1 Mini from 0.5.0 to 0.6.0b1 when it was still in place. Because then I could do a backup, copy data over to the ESP32-s2 backup, and restore. No new calibration needed.
I made a new attempt when the D1 Mini was not connected to the circuit.
Success! No idea why.

@mp-se
Copy link
Owner

mp-se commented Mar 7, 2023

Thanks. I will try the NAU7802 chips as well, I have 2 of them.

The problem with the history graph is probably related to that you dont have any data logged if you switched the board. But I will check to confirm that.

I can confirm that uploading from the 0.5 version didnt work but I found one issue when testing the esp32 async that I fixed, could be that problem that causes it to fail (I guess you used the async 0.5).

I will add the firmware to brewflasher once I have tested it a little more and fixed the main issues.

@darkside90a
Copy link
Author

Yes, async 0.5 on the ESP8266 D1 Mini.
If you are curious, here are my stability statistics so far with the ESP32-s2:
Screenshot-2023-03-07-08-01-49

@mp-se
Copy link
Owner

mp-se commented Mar 7, 2023

Found the issue with the update. The main problem is that the device does not reboot when firmware has been uploaded. I flashed and then did a manual reset and when it reboots it will switch to the new version. Applies to the 0.5 async version. Will check if I managed to fix this in the 0.6 version.

Really nice statistics. Seams really stable.

@mp-se
Copy link
Owner

mp-se commented Mar 8, 2023

Closing this for now, reopen if needed.

@mp-se mp-se closed this as completed Mar 8, 2023
@ribbonofblack
Copy link

Hi Darkside, your covers for the load cells and wiring look slick. Do you mind sharing the stl's for them?

@darkside90a
Copy link
Author

Hi,
Sure, no problems. I have uploaded the stl's to my github repo:
github.com/darkside90a/kegmon-base
I also added a short description and some pictures

@mp-se
Copy link
Owner

mp-se commented Mar 18, 2023

Nice work, I will add a link to your repo in the documentation so its easy to find.

@ribbonofblack
Copy link

Great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants