Where to find this library: ESP32_DEF.h

Hi everyone.
I found this sketch which used ESP32_DEF.h, where is it please?

Thanks
Adam

#include <Arduino.h>
#include <ESP32_DEF.h>
#include <LED.h>
#include <myMQTT.h>
#include <WiFi.h>
#include <Ticker.h>
#include <OneWire.h>
#include <DS18B20.h>
#include <DHT.h>
#include <Wire.h>
#include <SH1106Wire.h>
#include <SSD1306Wire.h>
#include <pctolcd.h>
#include <pins_arduino.h>

boolean res;
boolean led_state = 0;
MyMQTT myMqtt;
Ticker tickerTimer;
Ticker timer_2s;


float temp = 0.0;
float hum = 0.0;
#define DHTTYPE DHT11   // DHT 11
#define DHTPIN 4
#define ONEWIRE_BUS 15
#define IIC_SCL   22 
#define IIC_SDA   21
#define LINE_HIGH 8
OneWire onewire(ONEWIRE_BUS);
DS18B20 ds18b20(&onewire);
DHT dht11(DHTPIN,DHT11);
SH1106Wire oled_display(0x3c,IIC_SDA,IIC_SCL);
SSD1306Wire display(0x3c,18,19);
//
/*************************************************
Function: SysTemInit
 Description: System Initialization (Sensor)
Return: NULL 
Others: NULL
********************************************/
void SysTemInit(void)
{
    LED_init();    
    ds18b20.begin();
    dht11.begin();

    //OLED init
    oled_display.init();
    oled_display.flipScreenVertically();
    oled_display.setFont(ArialMT_Plain_10);

    display.init();
    display.flipScreenVertically();
    display.setFont(ArialMT_Plain_10);
    
}

/*************************************************
Function: oled_displayString
 Description: The string is displayed on the OLED
 Param: fontdata font size 10 16 24
         TEXTALIGN: Alignment 
         X, Y: Display text top left corner coordinates
         TEXT: Display Text
Return:   
Others: NULL
********************************************/
void oled_displayString(int fontdata,OLEDDISPLAY_TEXT_ALIGNMENT textalign,
                                int16_t x ,int16_t y,String text)
{
    // Set the font size, default 10
    if(fontdata == 24)
        oled_display.setFont(ArialMT_Plain_24);
    else if (fontdata == 16)
        oled_display.setFont(ArialMT_Plain_16);
    else 
        oled_display.setFont(ArialMT_Plain_10);

    // Set alignment
    oled_display.setTextAlignment(textalign);

    // Display string
    oled_display.drawString(x, y, text);
}

/*************************************************
Function: dispaly_logo
 Description: Displays LOGO in PCTOLCD.H
Return: NULL 
Others: NULL
********************************************/
void dispaly_logo(void)
{
    oled_display.clear();
    oled_display.drawXbm(8, 10, logo_width, logo_height,logo);
    oled_displayString(10,TEXT_ALIGN_CENTER,64,38,"ESP32");
    oled_display.display();

    display.setTextAlignment(TEXT_ALIGN_CENTER);
    display.drawString(64,38,"ESP32");
    display.display();
}

void display_wifi_config(void)
{
    oled_display.clear();
    oled_display.drawXbm(34, 0, WiFi_Logo_width, WiFi_Logo_height,WiFi_Logo_bits);
    oled_displayString(10,TEXT_ALIGN_CENTER,64, 35,String("SSID:")+wifi_ssid);
    oled_displayString(10,TEXT_ALIGN_CENTER,64, 50,String("WIFI_IP:")+WiFi.localIP().toString());
    oled_display.display();
}


/*************************************************
Function: DS18B20_rd_temperature
 Description: DS18B20 Temperature Read
Return: NULL 
Others: NULL
********************************************/
void DS18B20_rd_temperature(void)
{
    // Accuracy is set to 0.25 ---- 10 0.0625 --- 12
    ds18b20.setResolution(10);
    ds18b20.requestTemperatures();
    Serial.print("DS18B20 is Conversion ...");
    while(!ds18b20.isConversionComplete());
    temp = ds18b20.getTempC();
    Serial.println(temp,2);
}
/*************************************************
Function: tickerCallback
 Description: Timer callback function
Return: NULL 
Others: NULL
********************************************/
void tickerCallback(void)
{
    res = myMqtt.topic_property_post(3.3,temp,hum);
    Serial.println(res);
    led_state = !led_state;
    led_state?LED_ON:LED_OFF;
    DS18B20_rd_temperature();
}

/*************************************************
Function: timer_2s_callback
 Description: Timer callback function
Return: NULL 
Others: NULL
********************************************/
void timer_2s_callback(void)
{
    hum = dht11.readHumidity();
    // // Read temperature as Celsius (the default)
    // float t = dht11.readTemperature();
    // // Judgment is an illegal number
    if(isnan(hum))
    {
        Serial.println("Failed to read from DHT11 sensor!");
    }

    Serial.print(F("Humidity: "));
    Serial.print(hum);
    // Serial.print(F("%  Temperature: "));
    // Serial.print(t);
    // Serial.print(F("°C "));
}

/*************************************************
Function: setup
 Description: Initialization
Return: NULL 
Others: NULL
********************************************/
void setup() 
{
    
    SysTemInit();
    Serial.begin(115200);
    Serial.println();
    dispaly_logo();
    delay(3000);
    WiFi.begin(wifi_ssid,wifi_psd);
    
    while (WiFi.status() != WL_CONNECTED) // Waiting for the network connection success
    {
      delay(500);
      Serial.print(".");
    }
    Serial.println("WiFi connected!");

    Serial.println("IP address: ");
    Serial.println(WiFi.localIP()); // Print Module IP
    display_wifi_config();
    delay(3000);
    if(myMqtt.connect_to_MQTT_Server())      
        Serial.println("connect MQTT Server Success!");
    tickerTimer.attach_ms(1000,tickerCallback);
    timer_2s.attach(2,timer_2s_callback);
}

/*************************************************
Function: loop
 Description: Circulation
Return: NULL 
Others: NULL
********************************************/
void loop() 
{
    myMqtt.call_to_callback();
    if(!myMqtt.connected_status())
        myMqtt.reconnect();
}

Hi,
This library looks like it doesn't exist on google.
What happens if you compile your code with the line "#include <ESP32_DEF.h>"
commented? (// #include <ESP32_DEF.h>);

PS:
I think I get it, the author of the code must have created a ESP32_DEF.h
where he writes his wifi definitions like wifi_ssid,wifi_psd and others.

I use this feature, but I use the setting,h name for my credentials file.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.