Can code identify olimex esp32 board type?

Started by joopheuvel, December 07, 2023, 12:26:26 AM

Previous topic - Next topic

joopheuvel

Hi.
I have an extensive codeset running op either a couple of esp-evb or esp-poe. I am now working with a compile-time option to set right pins etc and either enable realays or not. Having two codesets is cumbersome. Can a piece of code identify the board type, either evb or Poe, so that on that basis, I can set all specifics dynamically further on,? This would be a great help and porting SW and compatibility much easier.
Hope question is clear. Thanks.
Joop van den Heuvel
Netherlands

LubOlimex

#1
It can be done probably. The default versions of the boards use the same ESP32 module (ESP32-WROOM) and these have same ID, so you have to search for other hardware differences. Specifics depend on your exact setup.

The basic idea is that you use one hardware set pin (GPIO) and your code reads its state and depending if that GPIO is high or low determines which is the board. If you can find such pin that fits all three requirement you might be able to do it out-of-the-box:

1) One board has that pin set low level (connected to GND)
2) The other board has the same pin set to high level (connected to 3.3V)
3) Your software doesn't use that pin for other purposes

If you can't find such pin, you can use a free GPIO to create it (it should be the same GPIO on both boards) - connect the free GPIO of one board to 3.3V, connect the same pin on the other board to GND, read that GPIO in your code and depending on what you get determine which board it is. You set that GPIO the same state on all ESP32-EVB boards, and the opposite way on all ESP32-POE boards.

Another idea for future is to buy ESP32-EVB and ESP32-POE boards with different ESP32 module (this way your code can just read the ID of the module and set the required settings). What I mean is that instead of ESP32-POE, to get ESP32-POE-WROVER since it uses other chip with different ID, but notice one important thing ESP32-POE-WROVER has two GPIOs less and your code might need slight change since WROVER has Ethernet clock on GPIO0 (instead of GPIO17) and GPIO16 is replaced by GPIO33.
Technical support and documentation manager at Olimex

joopheuvel

Hi and thanks

Looking at the pins to check for discrepancies between the 2 boards (evb and Poe), I probably need to check 32, 33 and 39. For evb, 32 and 33 as input will be low as grounded with resistor and base transistor connection. For Poe, 32 and 33 are open and will float to any value. For Poe, 39 should indicate presence of 5v and should be high. 39 on evb has ir-receive, will check what it is when measured as input. Would this be the best or a good strategy?
Thanks.
Joop

LubOlimex

GPI39 will be high on both locations without hardware modifications. Not suitable.

Playing with GPIO32 and GPIO33 might trigger the relays, and as far as I understood you need the relays. Also both pins doesn't seem to be used for anything in ESP32-PoE design.

Good news is I have another idea - the Ethernet clock source pin is different between the boards.  In ESP32-EVB - GPIO0 is used, while in ESP32-POE GPIO17 is used. Meaning, in your software scan one of those pins for the clock signal and determine the boards.
Technical support and documentation manager at Olimex

joopheuvel

#4
Thanks.
In the meantime I have created code that indeed scans at startup 32 and 33 with analogue read. If both lower than 10 (should be zero) I have an EVB. Afterwards I define the pins for output to use relays. On the POEs 32 and 33 will float so if both are over 10, It will very probably be a POE. Seems to work sofar. Will do more and longer check and if okay, will use this moving forward.
Thanks again
Joop

joopheuvel

Hi.
One more thing.
If I (also) decide to check gpio17, which is a good idea, for the POE, this pin would have a signal going low and high at a frequency. I need to sample a few times with the right interval to see these changes. What is the approx clock frequency of the eth clock?

Thanks.
Joop

LubOlimex

Technical support and documentation manager at Olimex