hi all
i have a problem as my project temperature no accurate with blynk temperature display.(project temperature show 36 deg c but blynk show 30 deg C) is that my code no correct or need to improve?
int sens1; //sensor define
int swA = 12 ; //button input
int val; //val definitation
int tempPin =A0; //pin config
int sensorValue1 ; //initial gas sensor value
#include <Servo.h>
Servo myservo;
#define BLYNK_PRINT Serial //blynk print serial data
#include <ESP8266WiFi.h> //define ESP
#include <BlynkSimpleEsp8266.h> //define Blynk
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] =
//char auth[] =
// Your WiFi credentials.
// Set password to "" for open networks.
const char* ssid = "esp";
const char* pass = "esp888";
// Variable to store the previous state for Button 0.
char previousButton0 = 0;
Servo servo;
BLYNK_WRITE(V3)
{
servo.write(param.asInt());
}
void setup()
{
// Set the pin as output.
pinMode(2, OUTPUT); // Set the pin as output.
Serial.begin(115200); //baudrate
Blynk.begin(auth, ssid, pass); //begin system Blynk
Blynk.virtualWrite(1,0); //set blynk virtual write
Blynk.virtualWrite(2,0); //set blynk virtual write
servo.attach(D4);
digitalWrite(2, HIGH); //off
}
void loop()
{
Blynk.run(); //runt he program
Blynk.virtualWrite(1,1023); //LED Blink High
delay(300);
Blynk.virtualWrite(1, 0); //LED Blink Low
delay(300);
val = analogRead(tempPin); //read temperature analog signal
float mv = ( val/1024.0)*5000; //lm35 calculation
float cel = (mv/10)-20 ; //lm35 calculation
float farh = (cel*9)/5 + 32; //celcius calculation
Blynk.virtualWrite(2,cel); //LED Blink High
Serial.print("TEMPRATURE = "); //print temp char in serial
Serial.print(cel); //print temp value in serial
Serial.print("*C"); //print char c in serial
Serial.println(); //print new line
delay(100);
}