Hi All!
I have a small “issue” with my little test project, i want to move a servo when the temp. of the DH11 is above or equal to 26 degrees.
But when the sensor gives a value of 23 of 24 the servo also turns now and then
Can someone tell me what’s wrong with my code?
[code]/**************************************************************
- Blynk is a platform with iOS and Android apps to control
- Arduino, Raspberry Pi and the likes over the Internet.
- You can easily build graphic interfaces for all your
- projects by simply dragging and dropping widgets.
- Downloads, docs, tutorials: http://www.blynk.cc
- Blynk community: http://community.blynk.cc
- Social networks: http://www.fb.com/blynkapp
-
http://twitter.com/blynk_app
- Blynk library is licensed under MIT license
- This example code is in public domain.
- This example shows how to use ESP8266 Shield via Hardware Serial
- (on Mega, Leonardo, Micro…) to connect your project to Blynk.
- Note: Ensure a stable serial connection to ESP8266!
-
Firmware version 1.0.0 (AT v0.22) or later is needed.
-
You can change ESP baud rate. Connect to AT console and call:
-
AT+UART_DEF=115200,8,1,0,0
- Change WiFi ssid, pass, and Blynk auth token to run
- Feel free to apply it to any other example. It’s simple!
**************************************************************/
//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266_HardSer.h>
#include <BlynkSimpleShieldEsp8266_HardSer.h>
#include <Servo.h>
#include <DHT.h>
#include <SimpleTimer.h>
#define DHTPIN 12 //Set PIN for DH11
#define DHTTYPE DHT11 // DHT 22 Change this if you have a DHT11
DHT dht(DHTPIN, DHTTYPE);
// Set ESP8266 Serial object
#define EspSerial Serial
SimpleTimer timer;
// Set ESP8266 Serial object
#define EspSerial Serial
ESP8266 wifi(EspSerial);
Servo servo;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “xxx”;
void setup()
{
// Set console baud rate
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(9600);
delay(10);
Blynk.begin(auth, wifi, “xxx”, “xxx”);
servo.attach(11);
delay(500);
timer.setInterval(5000, sendData);
}
BLYNK_WRITE(V3)
{
servo.write(param.asInt());
}
void sendData()
{
//Read the Temp and Humidity from DHT
float h = dht.readHumidity();
float t = dht.readTemperature();
//Write values to V04 and V05
Blynk.virtualWrite(4, h);
Blynk.virtualWrite(5, t);
}
void loop()
{
Blynk.run();
timer.run();
if (dht.readTemperature() > 25)
{
servo.write(0);
delay(1000);
servo.write(120);
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
Blynk.notify("Temperatuur is boven de 25 graden!);
}
}
[/code]