jueves, 25 de julio de 2024

Generar dos señales de reloj con la ESP32

En los canales se usa el canal cero y el canal dos porque aparentemente los canales vienen en pares y si se usa el cero y el uno tendrán la misma frecuencia.

#define LEDC_TIMER_13_BIT 13
#define LEDC_BASE_FREQ_R1 40  
#define LEDC_BASE_FREQ_R2 80
#define LED_PIN_1 15 // pin for first signal
#define LED_PIN_2 26 // pin for second signal
#define LEDC_CHANNEL_0 0
#define LEDC_CHANNEL_1 2

void setup() {
    pinMode(LED_PIN_1, OUTPUT); // set pin as output
    pinMode(LED_PIN_2, OUTPUT); // set pin as output
   
    ledcAttachChannel(LED_PIN_1, LEDC_BASE_FREQ_R1, LEDC_TIMER_13_BIT, LEDC_CHANNEL_0 );
    ledcAttachChannel(LED_PIN_2, LEDC_BASE_FREQ_R2, LEDC_TIMER_13_BIT, LEDC_CHANNEL_1 );
    // Initiates PWM signals with a 50% duty cycle
    ledcWrite(LED_PIN_1, 4096); // 50% of 2^13 = 4096
    ledcWrite(LED_PIN_2, 4096); // 50% of 2^13 = 4096
}

void loop() {
  // The loop is kept empty or with other commands as needed
}




jueves, 18 de julio de 2024

Get the MAC address of the ESP32

 By using the following code you can obtain the MAC address of the ESP32. It is advisable to use a delay to prevent the obtained MAC address from being 00:00:00:00:00:00.

#include <WiFi.h>

 void setup(){

    Serial.begin(115200);

    WiFi.mode(WIFI_STA);

    delay(500);

    Serial.print("\nDefault ESP32 MAC Address: ");

    Serial.println(WiFi.macAddress());

}

 

void loop(){

  // Do Nothing

}



Result without using delay:



Result using delay: