Conflict WiFi with dallas temperature library for ds18b20 ???

lepass7
Posts: 2
Joined: Mon Sep 11, 2017 7:54 pm

Conflict WiFi with dallas temperature library for ds18b20 ???

Postby lepass7 » Sun Apr 15, 2018 5:50 pm

Hi guys,
I am facing a very strange problem with my esp32 module and ds18b20. Please have a look at the following code:

Code: Select all

#if DEBUG
    //TOOD: remove is just for test
    sensors.requestTemperatures();
    Serial.print("Temperature: ");
    Serial.println(sensors.getTempCByIndex(0));
    delay(1000);
  #endif
  #if DEBUG
    Serial.println("** Scan Networks **");
  #endif
    byte numSsid = WiFi.scanNetworks();
    // print the list of networks seen:
   #if DEBUG
    Serial.print("SSID List:");
    Serial.println(numSsid);
    // print the network number and name for each network found:
    for (int thisNet = 0; thisNet<numSsid; thisNet++) {
      Serial.print(thisNet);
      Serial.print(") Network: ");
      Serial.println(WiFi.SSID(thisNet));
    }
    Serial.println("Wifi ssid: " + (String)wifiSSID);
    Serial.println("Wifi pass: " + (String)wifiPASS);
  #endif 
  #if DEBUG
    //TOOD: remove is just for test
    sensors.requestTemperatures();
    Serial.print("Temperature: ");
    Serial.println(sensors.getTempCByIndex(0));
    delay(1000);
  #endif

For some reason the first temperature reading which is before scanning for wifi networks is ok (I get correct results) but after the wifi scan networks the answer from my ds18b20 is always -127. It seems that it cannot find anymore the sensor on the wire.
This is what I have already try:
1. If I remove this line byte numSsid = WiFi.scanNetworks(); the second temperature reading is ok (I get correct results).
2. Add more delay during conversion (no success)
3. Try additional methods for reading temperature from ds18b20 (as shown in the github page) (no success)
4. Try different pins for the temperature sensor (no success)

I am out of ideas. Does anyone had the same problem?

Thank you in advance.

Cellie
Posts: 34
Joined: Sat Feb 27, 2016 9:47 pm

Re: Conflict WiFi with dallas temperature library for ds18b20 ???

Postby Cellie » Mon Apr 16, 2018 12:50 pm

No idea why the network scan would interfere.

I do have some code which should run.

https://github.com/CelliesProjects/dallas-webserver

https://github.com/CelliesProjects/esp3 ... 18B20-task

And check out stickbreakers OneWire repo.
This lib solves a lot of OneWire problems, and the solutions are now part of the 'official' Arduino OneWire lib.

Who is online

Users browsing this forum: rin67630 and 2 guests