Esp 32 → DS18B20

Hello, I just did this code can you tell me the problem. thank you so much

#define BLYNK_PRINT Serial


#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <SimpleTimer.h>

#include <OneWire.h>
#include <DallasTemperature.h> 
#define ONE_WIRE_BUS 2          // Your ESP8266 pin (ESP8266 GPIO 2 = WeMos D1 Mini pin D4)
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

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

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

SimpleTimer timer;

int roomTemperature;            // Room temperature in F

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

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

  sensors.begin();                        // Starts the DS18B20 sensor(s).
  sensors.setResolution(10);              // More on resolution: http://www.homautomation.org/2015/11/17/ds18b20-how-to-change-resolution-9101112-bits/

  timer.setInterval(2000L, sendTemps);    
}

void loop()
{
  Blynk.run();
  timer.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}
void sendTemps()
{
  sensors.requestTemperatures();                  // Polls the sensors.
  roomTemperature = sensors.getTempFByIndex(0);   // Stores temperature. Change to getTempCByIndex(0) for celcius.
  Blynk.virtualWrite(1, roomTemperature);         // Send temperature to Blynk app virtual pin 1.
}

Hi! This is so difficult, what’s the problem?

Try this:
float roomTemperature;

And SimpleTimer instead BlynkTimer

When I check my code, here is the error message

In file included from C:\Users\Gille\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h:17:0,
from C:\Users\Gille\Documents\Arduino\libraries\Blynk\src/BlynkApiArduino.h:14,
from C:\Users\Gille\Documents\Arduino\libraries\Blynk\src/BlynkSimpleEsp32.h:20,
from C:\Users\Gille\Documents\Arduino\ESP32\ESP32.ino:6:
C:\Users\Gille\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: redefinition of ‘class BlynkTimer’
#define SimpleTimer BlynkTimer
^
C:\Users\Gille\Documents\Arduino\libraries\SimpleTimer/SimpleTimer.h:10:7: note: in expansion of macro ‘SimpleTimer’
class SimpleTimer {
^
C:\Users\Gille\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:36:21: error: previous definition of ‘class BlynkTimer’
#define SimpleTimer BlynkTimer
^
C:\Users\Gille\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkTimer.h:41:7: note: in expansion of macro ‘SimpleTimer’
class SimpleTimer {
^
Multiple libraries were found for “WiFi.h”
Used: C:\Users\Gille\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi
Not used: C:\Users\Gille\Documents\arduino-nightly\libraries\WiFi
Not used: C:\Users\Gille\Documents\Arduino\libraries\WiFiNINA
exit status 1
Error compiling for board ESP32 Dev Module.

Remove this line:

And change this line:

to this:

BlynkTimer timer;

Pete.

Thank you @PeteKnight it works perfectly
Thank @Attila2660 for your contribution

1 Like