Page 1 of 1
What's the best way to differentiate between two custom ESP32 boards?
Posted: Thu Sep 29, 2022 8:24 am
by mzincali
I have two, and maybe more in the future, separate ESP32 custom boards. They are very similar except one is a little newer and has a buzzer attached to one pin via a transistor, and the older one does not. I want to run pretty much the same code on both, but I need to know which board it is. It is difficult to check for the existence of the buzzer/transistor, but it is probably possible. However, I was hoping I could read some sort of single byte ROM or something similar, where I could read a number between 1-255 or 1-65536 (2 bytes). Maybe this is something that is accessible on the I2C bus? Once I read that number then I could differentiate the two boards and run the program differently. I can even use it to decide which new firmware is appropriate for the board (although right now the similarity between the boards makes it less useful to have two entirely different firmware).
If I had some unused GPIO pins, I could force some to Vcc and some to GND in order to make a simple binary number. That's not very elegant.
I figure that this must be something that has been solved elegantly already.
Thank you for your help.
Re: What's the best way to differentiate between two custom ESP32 boards?
Posted: Thu Sep 29, 2022 2:07 pm
by Craige Hales
Similar discussion
https://maker.pro/forums/threads/serial ... ace.32369/ suggested
https://www.allaboutcircuits.com/electr ... ntegrated/
which looks like a $3 serial number.
But if I had several available input pins, I'd use them as an N-bit code and build them into the board design.
Re: What's the best way to differentiate between two custom ESP32 boards?
Posted: Thu Sep 29, 2022 6:40 pm
by mzincali
Thank you. A one to two dollars a chip is a hefty price to pay for this.
Especially when I am paying $1.50 for the ESP32.
I’ll see if I can free up some GPIO for this.
Re: What's the best way to differentiate between two custom ESP32 boards?
Posted: Thu Sep 29, 2022 10:10 pm
by davidzuhn
If you have a point where you know by external means which board it is, you can set a fuse with that ID and then refer to it later. Perhaps a device unique factory app and then you update to a common app via OTA.
Re: What's the best way to differentiate between two custom ESP32 boards?
Posted: Thu Sep 29, 2022 10:14 pm
by chegewara
Re: What's the best way to differentiate between two custom ESP32 boards?
Posted: Fri Sep 30, 2022 8:42 am
by mzincali
That's a good idea. Maybe when I test the assembled devices, I can also set the FUSE!
Re: What's the best way to differentiate between two custom ESP32 boards?
Posted: Sat Oct 01, 2022 1:16 pm
by username
They are very similar except one is a little newer and has a buzzer attached to one pin via a transistor, and the older one does not.
If I had some unused GPIO pins, I could force some to Vcc and some to GND in order to make a simple binary number.
You already do. Presumably you have a pull up or pull down on the base of the transistor. You could then just read the pin state of that GPIO pin to the transistor, and it will be high or low.
Re: What's the best way to differentiate between two custom ESP32 boards?
Posted: Wed Oct 26, 2022 5:45 pm
by mzincali
You already do. Presumably you have a pull up or pull down on the base of the transistor. You could then just read the pin state of that GPIO pin to the transistor, and it will be high or low.
Great idea. Will try it.
Re: What's the best way to differentiate between two custom ESP32 boards?
Posted: Fri Oct 28, 2022 6:44 am
by aid219
Maybe I didn't understand something, but why can't you just compare mac addresses? they seem to be unique, more or less.
#include <WiFi.h>
Serial.println(WiFi.macAddress());
Re: What's the best way to differentiate between two custom ESP32 boards?
Posted: Fri Oct 28, 2022 4:04 pm
by Craige Hales
That could work well if there are only a handful of V1 boards and the CPUs can't be easily swapped and all the V1 mac addresses were recorded or still available. This will typically be the case for me. But keeping a list of more than 5 or so mac addresses in the code starts to be a problem, and if there is a v2 and a v3 it starts to seem like a better solution is needed. If the board can identify the rev number to the CPU seems perfect, especially if planned from V1.