Arduino Uno WIFi board not reading temperature sensors, but other boards do

I'm making a script to use temperature sensors (DS18B20) to capture readings an output them. There are 3 of these connected to the Arduino board via a temperature sensor module on digital pins 4, 5 and 6. I got this working on an Arduino Uno R3. I then bought an Arduino Uno WiFi Rev 2 as I want to program a way to send the data across to a remote location. I expected I could plug in the board and it would read the same way as previously.

But on the Arduino Uno WiFi the reading I am getting for all 3 temperature sensors is -127.00. If I replace the Uno WiFi board with the Uno R3, it works again and reads the temperature fine. All on the same ports too. But with the Uno Wifi it refuses to read anything and I can't understand why.

The library being used in the script DallasTemperature is the library used to read the sensors. Has anyone encountered anything similar before?

I moved your topic to an appropriate forum category @deathpig.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

-127 means no connection. It's a wiring problem.
Bad plugs
Slack soldering
Wrong pins
Forgot the pull-up

Who knows?

Your programming is also suss. You seem to be using the sensors on different pins but with the Dallas library, which is nonsense. In the unlikely event that you really need the sensors on separate pins, you might try googling
DS18B20 sheepdog.

It's working and reading all 3 sensors on the 3 pins perfectly fine on an Uno R3. So the programming can't be too suss. I have 2 boards actually where it's reading just fine, but when I swap in the WiFi board it just refuses to read

And what do you mean using the sensors on different pins with the Dallas temperature library is nonsense? You can use any of the pins you want in theory

Which version of the OneWire library are you using? Older versions will not support the atmega4809 processor.

There are major differences between the UNO WiFi and the UNO WiFi Rev 2 boards, be careful not to mix the references.

It might work, and may even be a coding breakthrough, but it would then be the breakthrough nobody else wants to know about. and it definitely isn't something you would want to tell your mother. Everybody else in this universe uses the Dallas library in conjunction with OneWire, and puts all sensors on one pin.
That said, if you have good reason to use individual pins, the sheepdog guide method uses no libraries and can save a bit of programme overhead. This might be useful with a Uno.

It might be time to come forth with your code - and ensure your libraries are up to date and kosher.

Have a look at running the example code on the wi fi board, also check the schematic to check those pins aren’t used by the Wi-Fi

-always go back to basics , then you will know if it’s code, wiring , library etc .
Also google ds1820 and your board ( which is what I would do next to answer your problem)

/*********
  Reads temperatures from sensors and outputs to LCD display
*********/

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 20, 4); // I2C address 0x27, 20 rows, 4 columns

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(6);
OneWire twoWire(5);
OneWire threeWire(4);

// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);
DallasTemperature sensor2(&twoWire);
DallasTemperature sensor3(&threeWire);

void setup(void)
{
    // Start serial communication for debugging purposes
    Serial.begin(9600);

    lcd.init(); // initialize the lcd
    lcd.backlight();

    // Start up the library
    sensors.begin();
    sensor2.begin();
    sensor3.begin();
}

void loop(void){ 
    // Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
    sensors.requestTemperatures(); 
    sensor2.requestTemperatures(); 
    sensor3.requestTemperatures(); 
    
    lcd.clear();                 // clear display
    lcd.setCursor(0, 0);         // move cursor to   (0, 0)
    lcd.print("Moisture %");        // print message at (0, 0)
    
    lcd.setCursor(0, 1);         // move cursor to   (0, 1)
    String boilerTemperatureReading = (String)"Temp 1: " + sensors.getTempCByIndex(0);
    lcd.print(boilerTemperatureReading); // print message at (0, 1)

    lcd.setCursor(0, 2);         // move cursor to   (0, 2)
    String boilerReturnTemperatureReading = (String)"Temp 2:  " + sensor2.getTempCByIndex(0);
    lcd.print(boilerReturnTemperatureReading); // print message at (0, 2)
    
    lcd.setCursor(0, 3);         // move cursor to   (0, 3)
    String floorTemperatureReading = (String)"Temp 3: " + sensor3.getTempCByIndex(0);
    lcd.print(floorTemperatureReading);  // print message at (0, 3)

    delay(2000);  // display the above for two seconds
}

Nothing revolutionary or breakthrough going on there

Hummm...... Hopefully you are right about "revolutionary", although there is quite a lot of it that is as dumb as it is illogical, but, if it works, it fits in a Uno, and you're happy, who are we to rock the boat?
That said, and after the laughter dies down, you might get some value from here when you need to.

I recognise that slack-arsed code is probably not the cause of your real problem. If there was a problem because you were jamming it into the Uno's memory, the IDE would surely have advised you to that effect.

First of all settle down with the condescending tone and answers thanks. No need for it.

And I don't get what's half-arsed about the logic. I researched how to do it with one sensor, got that reading then hooked in 2 more sensors to 2 more pins and coded for them. I never came across anything on using one pin for multiple temperature sensors. Didn't even know that was possible.

Whether that is the root of my original issue I'm not sure, the fact it works on a non-WiFi board keeps throwing me. I'm planning to make sure the libraries are up to date like other answers were noting first.

I've found a few references to the OneWire library not working properly on the UNO WiFi Rev 2 board. I don't have time to test myself until sometime this weekend.

Very important is that the UNO WiFi Rev 2 uses an atmega4809 processor, which has some significant differences from the UNO or the UNO WiFi which use an atmega328.

Something that might cause a problem is that the processor uses the internal oscillator on the UNO WiFi Rev 2, which is not as accurate as the crystal or resonator used for an UNO.

Using one pin for multiple sensors is the sole purpose of the OneWire library. I guess that is why it is called one wire. Similarly, the DS18b20 is specifically designed to be used that way - part of the "one wire family', but if you only have one sensor on a pin, you are probably better off without the libraries.

I don't know anything about the atamega4809, but ensuring the library is kosher is clearly your first job. If it isn't, I guess there is one that is. If not, and since you clearly have the pins available, dispensing with the libraries altogether is clearly an option.

I guess it is possible that the Dallas software can't see anything because the OneWire isn't working, and therefore is obliged to assume there is no wire, so it returns the -127.

I have no problems running the code from post #8 on a Nano Every, which uses the same processor as the UNO WiFi Rev 2. All three temperature sensors are producing correct results.

As I mentioned, the processor is running off the internal oscillator, so there can be a lot of variation in the timing between different boards. That could possibly be causing problems with the OneWire library.

Hi @deathpig. I suggest you try a simple test of whether the board can read a single DS18B20. This will make it easier to understand whether the problem is at that fundamental level, or caused by one of the other factors that are present in your more complex system (multiple sensors, display).

Try this:

  1. Disconnect the USB cable of your UNO WiFi Rev2 board from your computer.
  2. Disconnect the display and two of the sensors from the board.
  3. Connect the USB cable of your UNO WiFi Rev2 board to your computer.
  4. Select File > Examples > DallasTemperature > Simple from the Arduino IDE menus.
  5. If the data line of your sensor is connected to a pin other than pin 2 on the UNO WiFi Rev2 board, change line 6 of the sketch accordingly:
    #define ONE_WIRE_BUS 2
    
  6. Upload the sketch to your UNO WiFi Rev2 board.
  7. Open Serial Monitor.
  8. Select "9600" from the baud rate menu in Serial Monitor.

The expected result is that you will see a stream of lines like this in Serial Monitor:

Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 17.00
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: 17.50

I just tried it on my UNO WiFi Rev2 board and it works as expected.

Let us know what result you get.

Hi @ptillisch
I tried out that DallasTemperature example with only a single sensor like you suggested. But unfortunately the reading is still off.

Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: -127.00
Requesting temperatures...DONE
Temperature for the device 1 (index 0) is: -127.00

And just to be sure, we tried the same thing swapping out the Arduino Uno WiFi Rev2 board with the original board, and it worked perfectly.
So I'm still not much the wiser where the issue lies. All I know is using the WiFi board breaks it for some reason.
I'm debating using the old board and ordering a WiFi shield to use with the board, and just abandoning the Rev2 board. Because I'm getting nowhere with this right now

This tells us two things:

  • The problem is not caused by something in your full sketch code
  • The problem is not caused by interference from another part of your full circuit

This is useful because it greatly reduces the number of potential causes to be considered.

Unfortunately I don't have any idea about why you got that result. As I mentioned in my previous reply, I tried the same code on my own UNO R4 WiFi board and it worked as expected. Hopefully one of the other forum helpers will have an idea about how to proceed.

Yeah it's frustrating. Only thing I can think of is if it's a faulty board with some of its pins or interfaces. I tested the WiFi with one of the example scripts and it pinged google.com no problem.
But when it comes to these temperature sensors it just lets me down every time.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.