DS18B20 returning -127 when using new Blynk and MKR 1010

I’m writing code to read values from the DS18B20 sensor using Arduino MKR 1010 WiFi and send them to Blynk in intervals. My wiring is correct and the sensor is returning correct values if used without Blynk (just printing in the serial monitor). But when I add code to connect with the new Blynk I get a value of -127 every time. Is there maybe a conflict between OneWire and Blynk library?

Details :
• Hardware model + communication type: Arduino MKR 1010 WiFi
• Smartphone OS (iOS or Android) + version: iOS 14.6
• Blynk server, Arduino IDE
• Blynk Library version: 1.0.0

Minimal code:

#include <OneWire.h>
#include <DallasTemperature.h>
// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID ""
#define BLYNK_DEVICE_NAME ""

#define BLYNK_FIRMWARE_VERSION        "0.1.0"

#define BLYNK_PRINT Serial
//#define BLYNK_DEBUG
#define ONE_WIRE_BUS 0

#define APP_DEBUG

#include "BlynkEdgent.h"

OneWire oneWire(ONE_WIRE_BUS);  

DallasTemperature sensors(&oneWire);

BlynkTimer sensorTimer;

void setup()
{
  sensors.begin(); 
  sensors.setWaitForConversion(false);
  Serial.begin(115200);
  delay(100);
  BlynkEdgent.begin();
  sensorTimer.setInterval(5000L, requestTemperature);
}

void loop() {
  BlynkEdgent.run();
  sensorTimer.run();
}

void requestTemperature(){
  sensors.requestTemperatures();
  Serial.print(sensors.getTempCByIndex(0));
  Serial.print("°");
  Serial.println("C");
  Blynk.virtualWrite(5, sensors.getTempCByIndex(0));
}

I assume that this tells the board to use GPIO0 as the data pin for your sensor.

It you take a look in settings.h you’ll see…

  // Example configuration for MKR1010 Board
  #define BOARD_BUTTON_PIN            0                     // Pin where user button is attached

So you seem to have a conflict.

Pete.

Yes, this was the problem. Thank you very much @PeteKnight ! I’ve been stuck on this one for two days…

1 Like

Hello. I have same problem. I have a Blynk local server with a Mkr1010. I use the GPIO10.
If i don’t use Blynk, I read value of ds18b20
If i use Blynk, the value is -127 :frowning:

No, you don’t have the same problem.

This was an issue with the Edgent example sketch on Blynk IoT. If you’re running a local server then you’re running Blynk Legacy, not Blynk IoT, and you certainly aren’t running Edgent.

I’d suggest you create a new topic and fully explain your issue, your hardware, your software and any other relevant info.

Pete.