Hi! I just received some of the new Arduino Nano Every's for a university project in which i need to regulate temperature using a heater and some DS18B20 sensors. I already made one regulator using the "old" Arduino Nano and there it worked just fine but when i made a second one using the new Nano Every it wouldn't read out the temperature, it just says -127.00 over and over. I'm using the exact same code as i'm using on the "old" Nano and i update the Dallas as well as the OneWire library but i just can't get it to work. Does any of you may have an idea what the problem could be? The code i'm using is attached below, thanks in advance!
Oke, so i changed my code to the one featured on the Arduino project hub for using a DS18B20 sensor located here. Then my code looked like this:
/********************************************************************/
// 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 A0
/********************************************************************/
// 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);
}
(Credits to Konstantin Dimitrov for making this guide)
But this didn't make a difference so i started looking in the OneWire library and there i found something suggesting that it had to do with me using an analog pin instead of a digital one. So i changed the code that it would extract data from a digital pin and reconnected the sensor to the digital pin and... it worked! I'm not quite sure why it won't work on an analog pin but for now i'm oke with it. Thanks for all the help, i really appreciate it!
You need to upgrade to the latest version 2.3.5 of OneWire which just came out. I had the same problem with the Nano Every and this solved it straight away.
I am in the exact same situation, although I first created the circuit using an Arduino UNO Rev3.
I upgraded to the the latest version as you said (2.3.5) and it still does not work...
I think I might be confused with the pinout, I find it a bit confusing.
So the code states this:
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS A0
So I see 2 different information:
pin 2
A0
Could someone clarify which physical pin is being used here?
So I see 2 different information:
- pin 2
- A0
Could someone clarify which physical pin is being used here?
This comment:
// Data wire is plugged into pin 2 on the Arduino
has absolutely no effect on the code. It's unfortunately quite common to find code where the program was changed (e.g., switching from pin 2 to pin A0), but the comment was not updated.
My board is Arduino Nano Sense BLE (one of most problematic board I every used), almost nothing works normally on this board and must be modded. For now I find this board perfect for flashing with LEDs and highlight my ceiling. Forgive me my frustration.
I have connected the temp sensor to 3.3v, GDN and signal pin (tried two, 2 and A0). I have cut the wire on temp sensor to be 50 cm. A resistor of 2.2k attached between 3.3V and signal pin.
All I get is -127 as result. Somebody please can tell me how to make the sensors work on this board? I tried to run it on standard UNO board - works. There is something wrong with nano boards, it is common issue if you will search internet for such topics.
Anybody please? I am in a bit of rush, must finish my project within 4 days and I spent last 3 on fighting with the temp sensors. Insane.