Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By rwkiii
#44602 gerardwr, yes I did consider using the chip id and MAC address, but these particular devices are landscaping and deck lights. Their linear positioning is important to my code and so I would like to specify a value of 0 to 31 for this. It kills two birds with one stone for me - a unique client id that indicates the position of the device within the group of devices.
User avatar
By martinayotte
#44612
rwkiii wrote:Martinayotte,

Thank you for the code example. I am using GPIO16, GPIO5, GPIO4, and GPIO14 (D0, D1, D2, and D5 respectively).

Code: Select all  int boardid = (digitalRead(16) << 3) | (digitalRead(5) << 2) | (digitalRead(4) << 1) | digitalRead(14);
  Serial.print("Pinned ID: "); Serial.println(boardid);


Connecting all 4 to GND returns a value of 0.

Connecting all 4 to 3.3V returns a value of 15.

Perfect! Thank you.


Well, Welcome !

For Gerardwr suggestion, I though about that too, simply the MAC Addr, but I understand that EndUsers DIP switch is also more convenient (such as RS485 ModBus where there is no MAC involved) ...
User avatar
By gerardwr
#44667
martinayotte wrote:For Gerardwr suggestion, I though about that too, simply the MAC Addr, but I understand that EndUsers DIP switch is also more convenient (such as RS485 ModBus where there is no MAC involved) ...


More convenient, yes! But I always try to avoid avoid extra components and soldering, that's why I prefer the software solution.

Nevertheless the dipswitch solution is nice, especially considering the requirement for sequence from 0..31.