Skip to content

ESP32 WiFi Kit

    In this article, I want to follow up on the experiences I have made and the information I have gathered on reading chip information on the ESP32 and present a script for this.

    The ESP_WIKI_kit from Heltec is to be used for this Adventure.
    I have a couch here with the label DIY More, but that’s of no interest here.
    I ordered the board from Aliexpress at some point.

    ESP32 WiFi Kit Front
    ESP32 WiFi Kit Back

    The most important features:

    ESP32, Tensilica LX6 dual-core processor
    clocked at 240 MHz
    520 KB SRAM integrated in the chip, 802.11 b/g/n HT40 Wi-Fi transceiver
    Integrated 4 MByte flash
    Wi-Fi antenna
    blue 0.96-inch OLED display
    CP2102-USB-to-Seriell-Chip
    UDP with a throughput of 135 Mbit/s
    Operating voltage: 3.3 V to 7 V
    Operating temperature range: -40 °C to +90 °C


    Let’s turn to the actual task and see what we can do with the ESP32.h and which functions are available to us without any major tricks.

    I have already explained the individual functions available in ESP.h in more detail in the article “What’s in my ESP“.


    But I would like to explain the last part of the code for determining the MAC address in more detail.
    What does this line do, for example? Serial.print((macAddress >> 40) & 0xFF, HEX); // First byte

    Bit operations for extracting the bytes

    1. macAddress >> 40

    • macAddress is a 64-bit number (uint64_t) that represents the MAC address of the ESP32.
    • >> 40 is a bitwise right shift operator. This operator shifts the bits of the number 40 positions to the right.
    • This shift moves the first byte of the MAC address (the highest 8 bits) to the lowest 8 bit positions of the number. This means that the first byte is now in the position that we can easily extract.

    2. & 0xFF

    • 0xFF is a hexadecimal constant that corresponds to the binary number 11111111. This is 8 ones in binary representation, which corresponds to 255 in decimal form.
    • The bitwise AND operator (&) is used to extract only the last 8 bits of the number. This helps to limit the value to a range from 0 to 255, which corresponds to exactly one byte.
    • Without this step, additional bits could remain in the higher position of the number, which are irrelevant for our purposes.

    3. Serial.print(…, HEX)

    • Serial.print(…, HEX) outputs the resulting number in hexadecimal form.
    • The HEX parameter specifies that the output should be in hexadecimal (i.e. base 16) representation.

    Composition of the entire line

    The line Serial.print((macAddress >> 40) & 0xFF, HEX); works as follows:

    Output: The result is output in hexadecimal form.

    Right shift: The MAC address is shifted 40 bits to the right so that the first byte of the MAC address occupies the lowest 8 bit positions.

    Masking: Bitwise AND with 0xFF means that only the first byte is retained and all other bits are removed.

    And now I don’t want to withhold the output of the code shown above from you.
    For better orientation and reference to the page with the explanations of the functions, I have linked each section.


    rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
    configsip: 0, SPIWP:0xee
    clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
    mode:DIO, clock div:2
    load:0x3fff0030,len:1184
    load:0x40078000,len:13232
    load:0x40080400,len:3028
    entry 0x400805e4

    Data of the heap
    Heap Size: 367 KB
    Available Heap Size: 342 KB
    lowest level of free heap since boot: 336 KB
    largest block of heap that can be allocated at once: 111 KB

    Data of the PSRAM
    PSRAM Size: 0 KB
    Free PSRAM Size: 0 KB
    Min_Free PSRAM Size: 0 KB
    Free PSRAM Size: 0 KB

    Data of the Chips
    Chip Revision: 1
    Chip Model: ESP32-D0WDQ6
    Chip Cores: 2
    Chip Freq: 240 MHz

    Flash memory data
    Flash Size: 4096 KB
    Flash Chip speed: 40000000
    Flash Chip Mode: 2

    Data of the sketch
    Sketch Size: 268 KB
    Sketch Size MD5: 0afef9566b4ff39e40d71f2869165042
    Free Sketch Space: 1280 Kb

    Fuse
    MAC Address: B8:A4:C0:7E:B9:94


    Here we are again at the end of this DIYTechAdventure. I hope you found the trip just as exciting as I did writing it. And remember – comments are always welcome!

    0 Kommentare
    Inline Feedbacks
    View all comments