Issue DS1820

Hi, first post here!

I’m trying to use my arduino nano as a data logger for temperature over time but it’s not going as expected. I tested the circuit and code on an arduino uno that I use for prototyping and it worked like a charm but switching to the arduino nano seems to bring some issues up.

Here is my code:

[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

OneWire oneWire(ONE_WIRE_BUS);
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)
{

  int count = sensors.getDS18Count(); //get number of sensor connected
  Serial.print("number of sensors connected: ");
  Serial.println(count);
  Serial.print(" Requesting temperatures...");
  sensors.requestTemperatures(); // Send the command to get temperature readings
  Serial.println("DONE");
  Serial.print("Temperature is: ");
  Serial.println(sensors.getTempCByIndex(0));
  delay(1000);
}

[/code]

Running the code on the arduino uno works, giving the temperature and the number of sensors connected (1). Trying the same with the arduino nano on the other hands returns 0 sensors connected and a nonsense temperature. The arduino nano comes from aliexpress but it runs other simple codes link blink, therefore I don’t think there is a problem with the board. Maybe i’m using the wrong pin numbers?

it worked like a charm

Meaning, it didn’t really work at all?

blablablablabla:
Trying the same with the arduino nano on the other hands returns 0 sensors connected

One very good possibility is that this is true - they aren't.

and a nonsense temperature. The arduino nano comes from aliexpress but it runs other simple codes link blink, therefore I don't think there is a problem with the board. Maybe i'm using the wrong pin numbers?

If the so-called "nonsense temperature" you are secretive about is 127, that confirms they aren't. You are probably right about the board.

Uno, Nano, and Pro Mini, and perhaps some others are essentially the same device in different packages, and use the same code.

TheMemberFormerlyKnownAsAWOL:
Meaning, it didn't really work at all?

It worked on the arduino uno, but it didn't work on the arduino nano.

Nick_Pyner:
One very good possibility is that this is true - they aren't. If the so-called "nonsense temperature" you are secretive about is 127, that confirms they aren't. You are probably right about the board.

The temperature is -127.
So board and code should be fine. I'll post a photo of the circuit later, maybe we can find the error there. I'm new and inexperienced with arduino...
thank you for your replies!

blablablablabla:
So board and code should be fine.

Correct. It's just a matter of a bad connection. This isn't so easy to see in a photograph, unless it is the wrong connection rather than a bad one!

Thank you for your help. Soldering the connections solved the problem!

Glad to hear it... Proper plugs or screw terminals often suffice!

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