get rid of the "A"

Hi All
Im trying to get rid of the A next to temp and cant see in the code where its saying to put the A in there in the first place.
See the screen shot for the display

#include <WiFi.h>
#include <WebServer.h>
#include "DHT.h"

// Uncomment one of the lines below for whatever DHT sensor type you're using!
//#define DHTTYPE DHT11   // DHT 11
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321

/*Put your SSID & Password*/
const char* ssid = "Pattos Place";  // Enter SSID here
const char* password = "MVrocks2020";  //Enter Password here

WebServer server(80);

// DHT Sensor
uint8_t DHTPin = 4; 
// Initialize DHT sensor.
DHT dht(DHTPin, DHTTYPE);                

float Temperature;
float Humidity;
void setup() {
  pinMode(DHTPin, INPUT);


  Serial.println("Connecting to ");

  //connect to your local wi-fi network
  WiFi.begin(ssid, password);

  //check wi-fi is connected to wi-fi network
  while (WiFi.status() != WL_CONNECTED) {
  Serial.println("WiFi connected..!");
  Serial.print("Got IP: ");  Serial.println(WiFi.localIP());

  server.on("/", handle_OnConnect);

  Serial.println("HTTP server started");

void loop() {

void handle_OnConnect() {

 Temperature = dht.readTemperature(); // Gets the values of the temperature
  Humidity = dht.readHumidity(); // Gets the values of the humidity 
  server.send(200, "text/html", SendHTML(Temperature,Humidity)); 

void handle_NotFound(){
  server.send(404, "text/plain", "Not found");

String SendHTML(float Temperaturestat,float Humiditystat){
  String ptr = "<!DOCTYPE html> <html>\n";
  ptr +="<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n";
  ptr +="<title>ESP32 Weather Report</title>\n";
  ptr +="<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n";
  ptr +="body{margin-top: 50px;} h1 {color: #444444;margin: 50px auto 30px;}\n";
  ptr +="p {font-size: 24px;color: #444444;margin-bottom: 10px;}\n";
  ptr +="</style>\n";
  ptr +="</head>\n";
  ptr +="<body>\n";
  ptr +="<div id=\"webpage\">\n";
  ptr +="<h1>ESP32 Weather Report</h1>\n";
  ptr +="<p>Temperature: ";
  ptr +=(int)Temperaturestat;
  ptr +="°C</p>";
  ptr +="<p>Humidity: ";
  ptr +=(int)Humiditystat;
  ptr +="%</p>";
  ptr +="</div>\n";
  ptr +="</body>\n";
  ptr +="</html>\n";
  return ptr;


Not 100% sure but my ESP8266 weather station does not show that. Howevere there IS a difference.
My code has

ptr += "<body>\n";
  ptr += "<div id=\"webpage\">\n";
  ptr += "<h1>ESP8266 Weather Station</h1>\n";
  ptr += "<p>Temperature: ";
  ptr += temperature;
 [b] ptr += " &deg;C</p>";[/b]
  ptr += "<p>Humidity: ";
  ptr += humidity;
  ptr += " %</p>";

Yours has

ptr +="°C</p>";

So I reckon its just because ""° is not valid html. Change it to " °

That indeed looks like charset mismatch. I don't see anywhere in your code where this is set, so the browser is left guessing.

that worked perfectly John
Thank you

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