I want make a ESP8266 webserver but I can only send char* format. I need convert double type to char type.
Code:
#include <ESP8266WebServer.h>
#include <SFE_BMP180.h>
#include <Wire.h>
const char* ssid = "TTNET_ZTE_2NPS";
const char* password = "mJmZuN6Uwq";
bool success = false;
double T, P;
char status;
ESP8266WebServer server(80);
SFE_BMP180 bmp;
void setup () {
Serial.begin(115200);
//BMP180
bool success = bmp.begin();
if (success) {
Serial.println("BMP180 init success");
}
else{
Serial.println("BMP180 FAIL");
}
//WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println("Bağlandı ");
Serial.println("IP adresi: ");
Serial.println(WiFi.localIP());
//Server
server.on("/pressure", pressureUpdate);
server.begin();
Serial.println("HTTP başladı");
}
void loop() {
//BMP180
bmp.startTemperature();
bmp.getTemperature(T);
bmp.startPressure(3);
bmp.getPressure(P, T);
//Server
server.handleClient();
delay(1000);
Serial.print("Basınç:");
Serial.println(P);
}
void pressureUpdate(){
char *html = to_chars(P);
server.send(200, "text/html", html);
delay(100);
}