Another 'Serial" does not name a type Problem needing help with

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "ESP32 Dev Module, Disabled, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), DOUT, 80MHz, 4MB (32Mb), 115200, Core 1, Core 1, None, Enabled"

I'm making a simple temp and humid sensor and being that I'm new and learning, this has me miffed.

Not used: C:\Users\Danny\Documents\Arduino\libraries\Adafruit_Unified_Sensor

exit status 1

'Serial' does not name a type

Here's the current code I'm tryin to upload that needs someone's help to find......


#include <WiFi.h>
#include <Wire.h>
#include "DHT.h"
#define DHTTYPE DHT11 // DHT 11
uint8_t DHTPin = 4;
DHT dht11(DHTPin, DHTTYPE);
const char* ssid = "xxxxxxxx"";
const char* password = "xxxxxxxx";
const char *host = "maker.ifttt.com";
const char *privateKey = "dQRiVJqbMSU1V5WU2Kmfmy";

WiFiServer server(80);

Serial.begin(115200);
pinMode(DHTPin, INPUT);
dht.begin();
Serial.print("Connecting to Wifi Network");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("Connected to WiFi.");
Serial.println("IP address of ESP32 is : ")]; <--------line that causes the halt

void loop()
// put your main code here, to run repeatedly:
Temperature = dht.readTemperature();
Humidity = dht.readHumidity();
WiFiClient client = server.available();
if (client)
{
Serial.println("Web Client connected ");
String request = client.readStringUntil('\r');
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 10"); // update the page after 10 sec
client.println();
client.println("html { font-family: Cairo; display: block; margin: 0px auto; text-align: center;color: #333333; background-color: ##f3ffee;}");
client.println("body{margin-top: 50px;}");
client.println("h1 {margin: 50px auto 30px; font-size: 50px; text-align: center;}");
client.println(".side_adjust{display: inline-block;vertical-align: middle;position: relative;}");
client.println(".text1{font-weight: 180; padding-left: 15px; font-size: 50px; width: 170px; text-align: left; color: #3498db;}");

  client.println("<div class=\"side_adjust text1\">Humidity:</div>");
  client.println("<div class=\"side_adjust data1\">");
  client.print(Humidity);
  client.println("<div class=\"side_adjust text1\">%</div>");
  client.println("</div>");
  client.println("<div class=\"data\">");
  client.println("<div class=\"side_adjust text2\">Temperature:</div>");
  client.println("<div class=\"side_adjust data2\">");
  client.print(Temperature);
  client.println("<div class=\"side_adjust text2\">*C</div>");


  if ( Temperature >= 20) {
    send_event("TempRising");
  }

}

The setup() function is missing (void setup()) in your code.

All of this must be inside setup().

Here wrong dht.begin(); right dht11.begin();

Your code does not compile, it has many errors.

You can hide you private credentials in a separate file and then include them with a line like:

#include "private_credentials.h" // defines SSID, PASSWORD, HOST,PRIVATEKEY

const char* ssid = SSID;
const char* password = PASSWORD;
const char *host = HOST;
const char *privateKey = PRIVATEKEY;
...


1 Like

Agreed, no doubt I'm a first time caller. I'm one of those jump in the deep end types. But the part y ou said is missing....that's the same void line that is there in a blank sketch isn't it? I'm going to go back and start on square one day one. The other issues is that I am not of a full understanding of the libraries and thought I would have whatever I loaded by default on all future sketches unless I remove them. Guess it's not how I thought. So Imma go study up all brand new cuz then I'll find out all the little things I know i missed by my urgency. Thanks Rilvlana

Omg, #faceplant.... If that doesn't say first day kinda stupid, IDK how else to feel any more duh about it. Then again, it's just a WiFi pass, not banking info or launch codes. But that's not the way to think either. a minor slip today breeds a huge WHOA OMG NO life changing problem tomorrow. Hope anyone that saw got a good belly laugh out of it cuz I sure did reading your msg. Won't happen...no.... I'll try my best not to do such stupid things publically in regards to security and that of my clients... Thanks Dave, good talk.. lol Danny

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