Want to ask, why the serial monitor is not showing the reading/results for esp32 board

When the serial monitor is open, it shown :

Rebooting... ets Jun 8 2016 00:22:57 rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:1324 ho 0 tail 12 room 4 load:0x40078000,len:13480 ho 0 tail 12 room 4 load:0x40080400,len:3604 entry 0x400805f0

Welcome to the forum

Do you have a question ?

What do you think should be printing on the Serial monitor ?

Please post a sketch that illustrates any problem that you have

This my code :

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <LiquidCrystal.h> // includes the LiquidCrystal Library
#include <DHT.h>
#include <Adafruit_Sensor.h>
#define BLYNK_PRINT Serial

#define WIFI_SSID "-"
#define WIFI_PASSWORD "-"

// You get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char host[] = "KGK6boy4kCS9ZTW915FV5YmVT9hV12uN";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "xxxxxx";
char pass[] = "xxxxx";
#define DHTPIN 4
#define DHTTYPE DHT11

LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

char pumpon [] = "ON";
char pumponmanual [] = "ON MANUAL";
char pumpoff [] = "OFF";

int solenoidPin = 4; //This is the output pin on the Arduino we are using
int temperature;
int humidity;

void pushswitch_button_Sensor()
{
Blynk.run();
float humidity = dht.readHumidity();
float temperature = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
Blynk.virtualWrite(V5, temperature);
Blynk.virtualWrite(V6, humidity);

if (temperature >= 24 && humidity <= 60) {
Serial.println(" - Surrounding is HOT");
digitalWrite(solenoidPin, HIGH); //Switch Solenoid ON
Blynk.virtualWrite(V10, pumpon);

}
else if (temperature <= 24 && humidity >= 60) {
Serial.println(" - Surrounding is COLD");
digitalWrite(solenoidPin, LOW); //Switch Solenoid OFF
Blynk.virtualWrite(V10, pumpoff);

}
}
void setup() {
lcd.begin(16, 2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display
// put your setup code here, to run once:
pinMode(solenoidPin, OUTPUT); //Sets the pin as an output
// Debug console
Serial.begin(9600);
Serial.println("DHT22 Output!");
dht.begin();

Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

timer.setInterval(1000L, pushswitch_button_Sensor);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Blynk.begin(host, ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}

Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}

BLYNK_WRITE (V8)
{
int pinValue = param.asInt ();
if (pinValue == 1) {
digitalWrite(solenoidPin, HIGH); //Switch Solenoid ON
Serial.println ( " SOLENOID ON FROM MANUAL CONTROL" );
Blynk.run();
Blynk.virtualWrite (V10, pumponmanual);
float humidity = dht.readHumidity();
float temperature = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
Blynk.virtualWrite(V5, temperature);
Blynk.virtualWrite(V6, humidity);
int pinValue = 0;
Blynk.syncVirtual (V8);
}
else {
pushswitch_button_Sensor();
}
}

void displayData_LCD() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();

lcd.setCursor(0, 0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("Temp.: "); // Prints string "Temp." on the LCD
lcd.print(temperature); // Prints the temperature value from the sensor
lcd.print(" C");
Serial.print("temperature = ");
Serial.print(temperature);
Serial.print("C ");

lcd.setCursor(0, 1);
lcd.print("Humi.: ");
lcd.print(humidity);
lcd.print(" %");
Serial.print("Current humidity = ");
Serial.print(humidity);
Serial.print("% ");
delay (1000);
}

void sendData_MYSQL() {
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
Serial.print("connecting to ");
Serial.println(host);

if (isnan(humidity) || isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
}

// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 5555;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}

// This will send the request to the server
client.print(String("GET http://your_hostname/iot_project/connect.php?") +
("&temperature=") + temperature +
("&humidity=") + humidity +
" HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 1000) {
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}

// Read all the lines of the reply from server and print them to Serial
while (client.available()) {
String line = client.readStringUntil('\r');
Serial.print(line);

}

Serial.println();
Serial.println("closing connection");
}

void loop() {
Blynk.run();
timer.run();
displayData_LCD();
pushswitch_button_Sensor();
sendData_MYSQL();
}

But the reading of DHT is not show in serial monitor......

Thank you for posting the sketch but please edit the post and add code tags to it

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

When you posted your code without code tags did you receive a warning message ?

These need to match...

image

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