BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

ESP8266, DS18B20 and Blynk 2.0

Hello, Is there a simple way to connect a DS18B20 to Blynk 2.0 mobile dashboard app with a ESP8266 and have the temp readings in Fahrenheit ?

Thanks,Adam

//************************* DallasTemperature *****************************//
#include <DallasTemperature.h>
#include <OneWire.h>
#define ONE_WIRE_BUS 4                          //D2 pin of nodemcu
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);            // Pass the oneWire reference to Dallas Temperature.
float Temp ;


void dallas() {
sensors.requestTemperatures();                // Send the command to get temperatures
Temp = sensors.getTempCByIndex(0);

}

This command is used to get the temperature in Celsius, to get the temperature in Fahrenheit you should use sensors.getTempFByIndex(0);

Hello, would this work in Blynk 2.0


  This example shows how value can be pushed from Arduino to
  the Blynk App.

  WARNING :
  For this example you'll need Adafruit DHT sensor libraries:
    https://github.com/adafruit/Adafruit_Sensor
    https://github.com/adafruit/DHT-sensor-library

  App project setup:
    Value Display widget attached to V5
    Value Display widget attached to V6
 *************************************************************/

// 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           "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_AUTH_TOKEN            "YourAuthToken"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

#define DHTPIN 2          // What digital pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  dht.begin();

  // Setup a function to be called every second
  timer.setInterval(1000L, sendSensor);
}

void loop()
{
  Blynk.run();
  timer.run();
}```

Are you using the DHT11 or DHT22 sensors ?
you said that you’re using the DS18B20.

Oops, Yes I was planning on using the DS18B20 sensors. I saw this on the sketch builder page and I also have the dht22 sensors as well. This would work for me as well if it works in Blynk 2.0.

Thanks,Adam

1 Like

Yes it’s gonna work just fine, no problem.

Yeah, I can’t send DS18B20 to Blink 2.0
In any way, everything works in the monitor, ESP8266 is connected, and the sensors are not visible on the website.
Help pliz…

//* ESP & Blynk *
#define BLYNK_TEMPLATE_ID           "0000"
#define BLYNK_DEVICE_NAME           "0000"
#define BLYNK_AUTH_TOKEN            "0000"
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_PRINT Serial

//* Blynk Данные *
char auth[] = BLYNK_AUTH_TOKEN; //"Код аутентефикации с приложения blynk

//* WiFi WiFi Данные *
char ssid[] = "00000"; //"имя сети вай-фай"
char pass[] = "00000000"; //"пароль от вай-фая"

BlynkTimer timer;

void myTimerEvent()
{
  // вы можете отправить любое значение в любой момент.
  // Пожалуйста, не отправляйте больше 10 значений в секунду.
  Blynk.virtualWrite(V1, millis() / 20000);
  Blynk.virtualWrite(V2, millis() / 20000);
  Blynk.virtualWrite(V3, millis() / 20000);
}

//* DS18B20 Температурный датчик *
#include <OneWire.h>
#include<DallasTemperature.h>
#define ONE_WIRE_BUS D3 // DS18B20 подключаем на D3 на плате (4 верху, правая сторона) 
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
float temp_1;
float temp_2;
float temp_3;

void setup()
{
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  DS18B20.begin();
  timer.setInterval(35000L, getSendData);
  DS18B20.setResolution (11); // При максимальной точности вермя срабатывания 2 секунды если не указана точность
  // 12 точность 0.06
  // 11 точность 0.12
  // 10 точность 0.25
  // 9 точность 0.5
  // 6 точность 0.5
  Serial.println(" ");
  Serial.println("Тестирование данных датчиков в Мониторе порта");
  timer.setInterval(10000L, myTimerEvent);
}

void loop()
{
  timer.run(); // Initiates SimpleTimer
  Blynk.run();
}

//***************************************************
//* Отправить данные датчика в Blynk *
// **************************************************
void getSendData()
{
  DS18B20.requestTemperatures();
  temp_1 = DS18B20.getTempCByIndex(0); // Sensor 0 показания для датчика 1 в цельсиях
  temp_2 = DS18B20.getTempCByIndex(1); // Sensor 0 показания для датчика 2 в цельсиях
  temp_3 = DS18B20.getTempCByIndex(2); // Sensor 0 показания для датчика 3 в цельсиях

  Serial.print("Temp_1: ");
  Serial.print(temp_1);
  Serial.print(" oC . Temp_2: ");
  Serial.print(temp_2);
  Serial.print(" oC . Temp_3: ");
  Serial.print(temp_3);
  Serial.println(" oC");

  Blynk.virtualWrite(V1, temp_1); //выврд данных на виртуальный пин V1
  Blynk.virtualWrite(V2, temp_2); //вывод данных навиртуальный пин V2
  Blynk.virtualWrite(V3, temp_3); //вывод данных навиртуальный пин V3
}

How did you configure your datastream ?

Goes to the port monitor - everything works here.
And it goes to Blink 2.0. The board is visible in the control panel, but the sensors do not want to earn in any way. I wanted to switch from Blink 1.0 to Blink 2.0, but it doesn’t work out.

You need to answer John’s question about how you’ve configured your V1, V2 and V3 datastreams in Blynk.
We especially need to know about the data type and minimum and maximum values that you’ve defined for each datastream.

Pete.

I’m sorry in advance, I’m communicating with you with a dictionary :frowning:

It’s not about the control panel settings in the office, I was able to figure it out there.
If there was information in BLANK 2.0. that the data is coming or they are not correct :frowning:
Apparently, I can’t find the correct syntax of the sketch in any way, there’s probably an error somewhere.

I’m not sure what is your problem exactly but I recommend you to read the documentation first before start using blynk IOT
https://docs.blynk.io/en/

Yes, I’ve been studying for two days.
There is only one example of a temperature sensor only DX 11, and there is not a word about the DS18B20.

You are using the same virtual pins for uptime and temperature.

Pete.

Check this example

or search the forum

Thanks, apparently I’m not smart :slight_smile:
Everything has worked, who needs it, take it :slight_smile:
Three sensors DS10B20

//* ESP & Blynk *
#define BLYNK_TEMPLATE_ID           "111111111111111"
#define BLYNK_DEVICE_NAME           "222222222222222"
#define BLYNK_AUTH_TOKEN            "3333333333333333333333"
//* Blynk Данные *
char auth[] = BLYNK_AUTH_TOKEN; //"Код аутентефикации с приложения blynk

//* WiFi WiFi Данные *
char ssid[] = "0000000"; //"имя сети вай-фай"
char pass[] = "000000000"; //"пароль от вай-фая"

#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS D4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
BlynkTimer timer;


float temp1, temp2,temp3;  

   
    void setup()
    {
     Serial.begin(115200);
     sensors.begin();
     Blynk.begin(auth, ssid, pass);
     timer.setInterval(30000L, sendTemps);
         
    }
  
void sendTemps()
  {
  sensors.requestTemperatures(); // Polls the sensors
  temp1  = sensors.getTempCByIndex(0); // Gets first pr
  temp2  = sensors.getTempCByIndex(1); // Gets first pr
  temp3  = sensors.getTempCByIndex(2); // Gets first pr
  Serial.println(temp1);
  Serial.println(temp2);
  Serial.println(temp3);
  Blynk.virtualWrite(V1, temp1); //вывод значений влажности в БЛИНК
  Blynk.virtualWrite(V2, temp2);
  Blynk.virtualWrite(V3, temp3);  
  }
  
    void loop()
    {
       Blynk.run();
       timer.run();    
    }
1 Like