/*
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C LCD = LiquidCrystal_I2C(0x27, 20, 4);
int analogValue;
const float BETA = 3950; // Deve corresponder ao coeficiente beta do termistor
float celsius;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Hello, ESP32-S2!");
LCD.init();
LCD.backlight();
}
void loop() {
// put your main code here, to run repeatedly:
analogValue = analogRead(34);
celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
LCD.clear();
LCD.setCursor(0, 0);
LCD.println(celsius);
delay(100); // this speeds up the simulation
}
*/
#include "driver/i2c.h"
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp LCD;
float celsius;
int analogValue;
const float BETA = 3950; // Deve corresponder ao coeficiente beta do termistor
int i2c_master_port = 0;
i2c_config_t conf = {
.mode = 1, //I2C_MODE_MASTER
.sda_io_num = 21, // select SDA GPIO specific to your project, I2C_MASTER_SDA_IO
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = 20, // select SCL GPIO specific to your project, I2C_MASTER_SCL_IO
.scl_pullup_en = GPIO_PULLUP_ENABLE,
//.master.clk_speed = 10000, // select frequency specific to your project, I2C_MASTER_FREQ_HZ
//.clk_flags = 0, // optional; you can use I2C_SCLK_SRC_FLAG_* flags to choose i2c source clock here
};
conf->master.clk_speed = 10000;
conf->clk_flags = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S2!");
int status = LCD.begin(20, 4);
if(status){
hd44780::fatalError(status); // does not return
}
LCD.print("Hello, World!");
}
void loop() {
// put your main code here, to run repeatedly:
analogValue = analogRead(34);
celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
LCD.clear();
LCD.setCursor(0, 0);
LCD.print(celsius);
delay(100); // this speeds up the simulation
}
/**/
Loading
esp32-s2-devkitm-1
esp32-s2-devkitm-1