I'm trying to integrate a DS18B20 waterproof temperature sensor with the Nano Every, however i don't get any meaningful values (just -127 as others report). I am using the most simple sketch example provided, with only a single temperature sensor being read and no other activities. When i run it on an Uno it works fine, but switch over to the Every and i get nothing. I have tried it on two Every's and neither have worked. I am left thinking that it must be compatibility issue with the Every and the DS18B20. I wondered if anyone had any ideas on what might be the issue, or if anyone even has successfully had the two working together?
I've spent a long time creating a much larger sensor setup (involving the Every, DS18B20 and a bunch of other sensors), and have nearly finished the PCB design. But the last thing to test was the DS18B20 integration, and I hadn't figured the most issues I would have would be with a simple temperature probe, so the frustration is mounting!
My connections:
GND to GND
VCC to 5V
SIG to D2
I have tried separately using a 4.75K resistor on a breadboard, and Dfrobot plugable resistor terminal v2 just to see if that would make any difference. I'm certain its not a wiring issue as I literally move the headers over from the Every to the uno and it works.
My code:
/********************************************************************/
// First we include the libraries
#include <OneWire.h>
#include <DallasTemperature.h>
/********************************************************************/
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
/********************************************************************/
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
/********************************************************************/
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
/********************************************************************/
void setup(void)
{
// start serial port
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
// Start up the library
sensors.begin();
}
void loop(void)
{
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
/********************************************************************/
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures(); // Send the command to get temperature readings
Serial.println("DONE");
/********************************************************************/
Serial.print("Temperature is: ");
Serial.print(sensors.getTempCByIndex(0)); // Why "byIndex"?
// You can have more than one DS18B20 on the same bus.
// 0 refers to the first IC on the wire
delay(1000);
}
DallasTemperature version (Miles Burton): 3.9.0
Onewire version (Paul Stroffregen): 2.3.7
Yes, I saw that response as well. As stated, I'm running 2.3.7 of OneWire which i would imagine would include any changes that 2.3.5 incorporated. I could always try reverting back to 2.3.5, but i would be sceptical that would achieve anything
Agreed, but you might as well while you noodle on what the root issue is. It might also be worth examining the 2.3.5 code to see what was changed to get a clue about where the difficulty is.
I see that the library was edited in 2018 to add support for the ATMega4809, which is indeed the 2.3.5 library. That change is still there in the latest version, so it's odd that there seems to be a problem with it after so long.
You might want to verify that the version you have has this in it:
You might want to verify that the version you have has this in it:
#if defined(__AVR_ATmega4809__)
I can confirm that this line is present.
As I understand, the problem is not that the library does not support ATMega4809 at all, but that the support is not works properly.
So to clarify, they did alter the library to support the Every, but that modification doesn't work? I notice on the OneWire github page that the Nano BLE is confirmed not supported, but there is no mention of the Nano Every, and their architectures are different. Perhaps I will raise it as an issue there to see if it has been confirmed.