kloon / OpenBeerFiller

An opensource beer filling line microcontroller
GNU General Public License v3.0
39 stars 13 forks source link

Add support for the esp32 #17

Closed N3MIS15 closed 4 years ago

N3MIS15 commented 4 years ago

POC - Needs Testing. This adds initial support for ESP32 devices. I have tested with a standard dev module. I have not tested again with an UNO though. If I get a chance I will knock up another breadboard for testing both devices.

Getting the timer working was just a guessing game for me. I have to admit I don't actually know if it is working correctly. Any input would be grateful.

Cheers.

kloon commented 4 years ago

Hi @N3MIS15, thanks for taking a shot at this. I am also in the process of adding ESP8266 support and have run into a couple of issues that might affect this as well.

  1. I am not sure if using the hardware timer would work, at least it is not suggested on the ESP8266 since it controls the wifi and other critical functionality. This might be different on the ESP32 since the architecture is different. Another solution would be to use non-interrupt millis for this instead of an interrupt timer. We need to be mindful here as to not break the AVR compatibility.
  2. The use of the board constant while it reads easier it can cause issues for people trying to compiling, hence why I used the AVR definition, that is built into the Arduino platform and will be true for all AVR chip boards like the UNO, there are other definitions we can use of ESP boards like ESP_PLATFORM https://docs.espressif.com/projects/esp-idf/en/v3.1.5/api-guides/build-system.html#preprocessor-definitions
  3. For the config file, let's create a separate config file for the ESP boards and then include those with the precompiled definition instead.
  4. There are no real analog pins on the ESP8266 but it seems the ESP32 does have, which is a plus, we just need to check how it behaves to measure the voltage that triggers the fill sensors. From what I have read the analogRead on an ESP32 delivers a value between 0 and 4095 while on AVR chips it delivers a value between 0 and 1023.

That is all feedback I have, for now, I have an Uno test rig set up so will give it a test a bit later when I get a chance.

Thanks again for the pull requests, really appreciate it.

N3MIS15 commented 4 years ago

I have very little knowledge about timers, interrupts and microcontroller development in general so a little insight is very much appreciated. I had a look at the ESP8266 and decided that ESP32 was a better candidate due to the analog inputs. You are correct about the analog values. ESP32 does in fact go up to 4095.

I will close this request and continue poking around getting wifi working, if anything it has at least been a learning experience.

kloon commented 4 years ago

@N3MIS15 Feel free to keep this PR open and we can get this working together,