Hello Guys
I need put the temperature and umidity value in the a display OLED. But the function to do it accept only strings and the temperarute/umidity are float both.
How could I change the floats in strings?
Following the code.
#include <NTPClient.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ESP8266WiFi.h>
#include <SSD1306.h>
#include <DHT.h>
#include "floatToString.h"
SSD1306 display(0x3c, D7, D5);
const char *ssid = "WIFI BASILIO";
const char *password = "34239755";
int16_t utc = -3;
#define DHTPIN 5
DHT dht(DHTPIN, DHT11);
WiFiUDP ntpUDP;
// You can specify the time server pool and the offset (in seconds, can be
// changed later with setTimeOffset() ). Additionaly you can specify the
// update interval (in milliseconds, can be changed using setUpdateInterval() ).
NTPClient timeClient(ntpUDP, "a.st1.ntp.br", utc*3600, 60000);
void setup(){
display.init();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);
Serial.begin(115200);
WiFi.begin(ssid, password);
while ( WiFi.status() != WL_CONNECTED ) {
delay ( 500 );
Serial.print ( "." );
}
timeClient.begin();
}
void loop() {
timeClient.update();
Serial.println(timeClient.getFormattedTime());
float h = dht.readHumidity();
float t = dht.readTemperature();
String hum;
String temp;
floatToString(hum,h);
display.clear();
display.display();
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_10);
display.drawString(0, 10, timeClient.getFormattedTime());
display.drawString(0, 20, dht.readHumidity()); // < Don't accepct the humidity value because is a float
display.drawString(0, 30, dht.readTempearute()); // < Don't accepct the temperatute value because is a float
display.display();
delay(1000);
}
Thank you!