Hi
I am using a DS18B20 waterproof temperature sensor in my project. I am also using other sensors which work fine with blynk but the temperature sensor wont seem to work. When i run the below code the serial monitor shows that it is connected to blynk but it wont run the getTemperature command every 5 seconds. Is there anyone who has used this sensor with Blynk before? I am using an Arduino Uno rev3 board with an ESP8266 wifi shield.
// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID "TMPL7mLWZCzi"
#define BLYNK_DEVICE_NAME "Quickstart Device"
#define BLYNK_AUTH_TOKEN "SQKj9qqAVwTsrLHimtkkdvSPMFuj8Ss_"
// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Tenda_3165"; //"VODAFONE-6360"; //"Tenda_3165";
char pass[] = "JDwRadYk"; //"tYsx6nsxx946KAKf"; //"JDwRadYk";
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial
// or Software Serial on Uno, Nano...
#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2,3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
BlynkTimer timer;
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float Celcius=0;
int DesiredTemperature = 25;
BLYNK_WRITE(V1)
{
DesiredTemperature = param.asInt();
}
void getTemperature()
{
sensors.requestTemperatures();
Celcius=sensors.getTempCByIndex(0);
Serial.print(" C ");
Serial.println(Celcius);
Serial.print("Desired Temp ");
Serial.println(DesiredTemperature);
}
void setup()
{
sensors.begin();
// Debug console
Serial.begin(9600);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(BLYNK_AUTH_TOKEN,wifi, ssid, pass);
timer.setInterval(5000L, getTemperature);
}
void loop()
{
Blynk.run();
timer.run(); // Initiates BlynkTimer
}