I uploaded the same code as I'd been using to two ESP-WROOM-32E modules (Arduino version 2.3.3)
(at the bottom of this post)
I can still get the code to upload on each module, and can erase the flash with pytool. I have switches on GPIO and EN.
Code: Select all
esptool.py --chip esp32 --port /dev/tty.usbserial-D30GPHQW --baud 460800 erase_flash
Code: Select all
12:04:40.189 -> rst:0x8 (TG1WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
12:04:40.189 -> configsip: 0, SPIWP:0xee
12:04:40.189 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
12:04:40.221 -> mode:DIO, clock div:1
12:04:40.221 -> load:0x3fff0030,len:4916
12:04:40.221 -> load:0x40078000,len:16436
12:04:40.221 -> load:0x40080400,len:4
12:04:40.221 -> ho 8 tail 4 room 4
12:04:40.221 -> load:0x40080404,len:3524
12:04:40.221 -> entry 0x400805b8
12:04:41.078 -> ets Jul 29 2019 12:21:46
Code: Select all
#include <Wire.h>
#include "LCD-SOLDERED.h"
#include <driver/adc.h> // Include this library to use ADC functions directly
LCD lcd(16,2); // Define LCD object with the correct number of columns and rows
const int batteryPin = 35; // GPIO35 to read battery voltage
const float referenceVoltage = 3.3; // ESP32 ADC reference voltage
const int resolution = 4095; // 12-bit resolution (0 to 4095 for ESP32)
const float dividerFactor = 2.15; // Divider factor for the 470k/470k setup
const int ledPin = 10; // Hello World LED
void setup()
{
Wire.setClock(100000); // in Hertz
Wire.begin(21, 22); //SDA, SCL
lcd.begin(); // Initialize LCD
lcd.backlight(); // Turn the backlight on
lcd.clear();
// Set up serial communication for debugging
Serial.begin(115200);
pinMode(ledPin, OUTPUT); // Set GPIO10 as an output for the LED
// Configure the ADC
analogReadResolution(12); // Set ADC resolution to 12 bits (0-4095)
analogSetPinAttenuation(batteryPin, ADC_11db); // Set attenuation for full-scale voltage of ~3.6V
lcd.print(" Hello QSP32!"); // Prints Hello on the LCD
// lcd.setCursor(5, 1); // set cursor to 5th character in line 1
// delay(5000);
}
void loop()
{
// Read the analog value from GPIO35
int adcValue = analogRead(batteryPin);
if (adcValue < 2500){
Serial.println("Charging");
}
// Calculate the battery voltage based on the ADC reading
float batteryVoltage = (adcValue * referenceVoltage) / resolution * dividerFactor;
// Display the battery voltage on the serial monitor (for debugging)
Serial.print("adcValue: ");
Serial.print(adcValue);
Serial.println();
Serial.print("Battery Voltage: ");
Serial.println(batteryVoltage, 2); // Print voltage with 2 decimal places
// Display the battery voltage on the LCD
/*lcd.clear(); // Clear the previous display on the LCD
lcd.setCursor(0, 0); // Set cursor to the first column of the first row
lcd.print("Battery Voltage:");
lcd.setCursor(0, 1); // Set cursor to the first column of the second row
lcd.print(batteryVoltage, 2); // Display voltage with 2 decimal places
lcd.print(" V");*/
// Blink the LED on GPIO10
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(250); // Wait for 250 ms
digitalWrite(ledPin, LOW); // Turn the LED off
delay(250); // Wait for 250 ms */
// Delay before reading again
//delay(500);
}