Arduino UNO + ESP8266 + DS18B20

Hello!

I have an Arduino UNO with ESP8266 and 2 DS18B20 to take readings from 2 fridges.

Can’t get any readings. Gauges stay in -127.
Login timeout and heartbeat timeout.

`

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#define ONE_WIRE_BUS 10
#define TWO_WIRE_BUS 11

#include <OneWire.h>
#include <DallasTemperature.h>
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <TimeLib.h>
#include <SimpleTimer.h>



OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);

OneWire twoWire(TWO_WIRE_BUS);
DallasTemperature DS18B20B(&twoWire);

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "token";
SimpleTimer timer;

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

// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1

// 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);

void setup()
{
  // Set console baud rate
  Serial.begin(9600);
  delay(10);
  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
  DS18B20.begin();
  DS18B20B.begin();

  timer.setInterval(1000L, sendTemps); // Temperature sensor polling interval (5000L = 5 seconds)
  
}
float tempCong;
float tempResf;

void sendTemps()
{
  DS18B20.requestTemperatures(); // Polls the sensors
  DS18B20B.requestTemperatures();

  tempCong = DS18B20.getTempCByIndex(0); // Gets first probe on wire in lieu of by address
  tempResf = DS18B20B.getTempCByIndex(0);

  Blynk.virtualWrite(4, tempCong);
  Blynk.virtualWrite(5, tempResf);
}

void loop()
{
  if (tempCong >= -8) 
    {
      //Blynk.notify("Temperatura alta!");
      Blynk.email("rodrigo.cavalheiro@gmail.com", "Alerta de temperatura", "Câmara de congelados acima de -8C!");
      delay(100000);
     }

  if (tempResf >= 11) 
    {
      //Blynk.notify("Temperatura alta!");
      Blynk.email("rodrigo.cavalheiro@gmail.com", "Alerta de temperatura", "Câmara de resfriados acima de 11C!");
      delay(100000);
    }
  Blynk.run();
  timer.run();
}

`

Many thanks!
Rodrigo

Did you think of a resistance between the DS18B20? This should be ca R = 2.5k in size and comes between DATA pin and VCC.

Hey SleXx. Thanks for answering.

I put a 4.7k resistance between DATA and VCC for each of the DS18B20’s.

Thanks!

Did you read something regarding delays or sofware serial?
If not, please check the forum. There are lots of posts regarding these items…:wink:
Try to remove everything from the main loop, leave only Blynk.run(); and timer.run();

Hey psoro. Sorry for the late answering.
I made it work without the delay!

Thanks!

1 Like