• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Co jest nie tak ?
#1
Lightbulb 
Hej staram się uruchomić termometr DS18B20 :

Kod:
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire temp(7);
DallasTemperature DS18(&temp);

void setup()
{
Serial.begin(9600);
DS18.begin();
}
void loop()
{
DS18.requestTemperatures();
Serial.print("DS18 numer 1: ");
Serial.println(DS18.getTempCByIndex(0));
Serial.print("DS18 numer 2: ");
Serial.println(DS18.getTempCByIndex(1));
Serial.print("\r\n");
delay(2000);
}


i ciągle mi wyświetla -127.00 co mam nie tak ?
 
Odpowiedź
#2
Czy masz rezystor 4k po między data a vcc.
[Obrazek: banerelektronika.jpg]



Jeśli pomogłem podziękuj punktem reputacji Wink
 
Odpowiedź
#3
(13-08-2017, 13:45)adix napisał(a): Czy masz rezystor 4k po między data a vcc.

Tak, i ciągle to samo
 
Odpowiedź
#4
Kod:
// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 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);

/*
* The setup function. We only start the sensors here
*/
void setup(void)
{
  // start serial port
  Serial.begin(9600);
  Serial.println("Dallas Temperature IC Control Library Demo");

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

/*
* Main function, get and show the temperature
*/
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 temperatures
  Serial.println("DONE");
  // After we got the temperatures, we can print them here.
  // We use the function ByIndex, and as an example get the temperature from the first sensor only.
  Serial.print("Temperature for the device 1 (index 0) is: ");
  Serial.println(sensors.getTempCByIndex(0));  
}
z prubuj to.
[Obrazek: banerelektronika.jpg]



Jeśli pomogłem podziękuj punktem reputacji Wink
 
Odpowiedź
#5
A na pewno wszystko dobrze masz podłączone? (pokaż zdjęcie układu)
Sprawdzałeś adresy czujników?
Jeśli masz problem z kodem lub sprzętem, zadaj pytanie na forum. Nie odpowiadam na PW, jeśli nie dotyczą one spraw forum lub innych tematów prywatnych.

[Obrazek: SsIndaG.jpg]
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości