Skip to content

Instantly share code, notes, and snippets.

@likeablob
Created February 14, 2022 14:14
Show Gist options
  • Save likeablob/1eafa67c0995c188ff6fb507ddbd237f to your computer and use it in GitHub Desktop.
Save likeablob/1eafa67c0995c188ff6fb507ddbd237f to your computer and use it in GitHub Desktop.
ESP32 ESP.getChipId() alternative
#include <Esp.h>
#include <byteswap.h>
// Get the lower 3 bytes of 6 byte MAC
// aa:bb:cc:dd:ee:ff -> dd:ee:ff
// (3 byte shift, byte-swap and 1 byte shift)
uint32_t partialMac = __bswap_32(ESP.getEfuseMac() >> 24) >> 8;
String clientId = String("eee-") + String(partialMac, HEX);
uint32_t getChipId(){
return __bswap_32(ESP.getEfuseMac() >> 24) >> 8;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment