I have attached a DHT22 to my LoRa WiFi OLED (V3) device using pin 46 which the diagram indicates is GPIO. Now I cannot upload programs, it says
Serial port COM4
Connecting......................................
A fatal error occurred: Failed to connect to ESP32-S3: No serial data received.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
Failed uploading: uploading error: exit status 2
If I disconnect pin 46 it works again. My code is pretty short:
#include "DHT.h"
#include "Arduino.h"
#include "WiFi.h"
#include "LoRaWan_APP.h"
#include <Wire.h>
#include "HT_SSD1306Wire.h"
//#include "heltec.h"
//DHTesp dht;
SSD1306Wire factory_display(0x3c, 500000, SDA_OLED, SCL_OLED, GEOMETRY_128_64, RST_OLED); // addr , freq , i2c group , resolution , rst
// DHT digital pin and sensor type
#define DHTPIN 46
#define DHTTYPE DHT22
float currentTemp;
float currentHumidity;
void displayReadingsOnOled() {
String temperatureDisplay ="Temperature: " + (String)currentTemp + "Ā°C";
String humidityDisplay = "Humidity: " + (String)currentHumidity + "%";
// Clear the OLED screen
factory_display.clear();
// Prepare to display temperature
factory_display.drawString(0, 0, temperatureDisplay);
// Prepare to display humidity
factory_display.drawString(0, 12, humidityDisplay);
// Display the readings
factory_display.display();
}
// init. DHT
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
currentTemp = dht.readTemperature();
currentHumidity = dht.readHumidity();
pinMode(LED,OUTPUT);
digitalWrite(LED,HIGH);
// Heltec.begin(true /*DisplayEnable Enable*/, false /*LoRa Enable*/, false /*Serial Enable*/);
displayReadingsOnOled();
}
void loop()
{
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
if (temperature != currentTemp || humidity != currentHumidity) {
currentTemp = temperature;
currentHumidity = humidity;
displayReadingsOnOled();
}
delay(2000);
}
Any ideas?