Help with 2 sensor temp readings

Hello,
i have a script to read from 2 dallas sensors (18d20), i think its reading the data but the app only shows me high or low, how can i dsiplay the temp reading from 2 or more sensors?
im using both esp8266-12 or wemos d1 and have the same error

thank you

define BLYNK_PRINT Serial
include ESP8266WiFi.h>
include BlynkSimpleEsp8266.h>
include SimpleTimer.h>

include OneWire.h>
include  DallasTemperature.h>

#define Pin 3   //One sensor connected on pin 3
#define Pin2 4  //One sensor connected on pin 4



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

char auth[] = "my access";
SimpleTimer timer;

OneWire ourWire(Pin);
OneWire ourWire2(Pin2);

DallasTemperature sensors(&ourWire);
DallasTemperature sensors2(&ourWire2);
float s1;
float s2;

void setup()
{
  Serial.begin(115200);
  delay(10);
  Blynk.begin(auth, "ssid", "pass");
  delay(10);
  sensors.begin();
  delay(10);
  sensors2.begin();
  delay(10);
  sensors.setResolution(10);
  delay(10);
  sensors2.setResolution(10);
  timer.setInterval(1000L, ReadTemp); // Will call the function to measure
  // temperature every 1 second

}

void ReadTemp()
{
  sensors.requestTemperatures();
  delay(10);
  s1 = sensors.getTempCByIndex(0);
  delay(10);
  sensors2.requestTemperatures();
  delay(10);
  s2 = sensors2.getTempCByIndex(0);
  delay(10);
}

BLYNK_READ(V1)
{
  Blynk.virtualWrite(V1, s1);
}

BLYNK_READ(V2)
{
  Blynk.virtualWrite(V2, s2);
}

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

Hello. Please use formatting </> for code.

Please do

Serial.print(s1);
Serial.println();

What does it show?

Hi Demitry, thank you for the reply

it shows all the time -127 , like the sensor is not connected but its working and its online

How it can be connected and working if it shows -127 :slight_smile:?

Did you put the pull up resistors (ex 4K7) at the pins (pin , pin2) the onewire operation required these resistors…

Some DS18B20 sensors will only run at 5V. Are you sure you have the ones that will run at 3.3V?

im using a base ready with resister built in,
on the wemos D1 do have 5V and 3.3, on the esp8266-12 im using 5v from another source.

@logico when you say built in resistors do you mean something like the image below:

From Ebay at http://www.ebay.com/itm/350856347380

Do you have a link to the units you are using?

As @Dmitriy stated a reading of -127 (and +85) is the default for “not wired up right”.

@logico please edit your first post so we can actually read the sketch. Highlight the code and press the </> button and then check the include statements are legible.

What gave you the idea that you can use pin 3?

Pin 3 is the RX pin if I remember rightly. It can be used but obviously it messes up flashing etc so most people use regular pins.

Hello all and thanks for you help,
i update the code in the top so you can see
i will upload the pic for the 18b20 and i will try to use another pin address

ok, update.
first thank you all for your help, i do like blynk as IOT features, this product has a great potential !! :slight_smile:
seems there is a problem using the webos D1 card with the code, switching back to ESP8266-12 solve the issue and now its working great…
still it is strange that on the same port on the wemos D1 it cant work.
and also the sensor work on 3.3V

D1 is GPIO 5 and I haven’t seen any of your sketches with pin 5 referenced.

There should be no problem running this on a WeMos, you are mixing up pin numbers of Dx and GPIOx.

Use GPIOx for everything and forget Dx numbers. The Dx numbers should just be used to make your physical (not software) connections.

So always use the numbers on the right hand side of the table at http://www.wemos.cc/Products/d1_mini.html not the left hand side.

ok, this is strange,
i took out the USB from the nodemcu ESP8266-12 and return it and the device isnt booting, after taking out the sensor from D4 and reset its loading, now when returning the Pin back to the original place i cant get any reading, rebooting the device giving the same error until disconnection the 18B20 pin.
i want to make sure

define Pin D3 //One sensor connected on pin 3
define Pin2 D4 //One sensor connected on pin 4
or i need to set it to:
define Pin 3 //One sensor connected on pin 3
#define Pin2 4 //One sensor connected on pin 4

in both cases its esp8266-12 device

@logico neither of those formats are correct.

Use regular pins, so 4 and 5

define Pin 4 //One sensor connected on GPIO 4 which is physically D2 on a WeMos
define Pin2 5 //One sensor connected on GPIO 5 which is physically D1 on a WeMos

For future reference, these are the pins on the Wemos and how they map to the Pins you use in the Arduino IDE:

thank you very much
this daiagram is for the MINI version, its dff from the Retired old R1.
any way i have decided to go back to the old ESP-8266-12 device that works better :slight_smile:
seems now i have an issue with the sensors that stop responding after a while