faulan:
faulan:
Hallo,
ich habe hier ein kleines Problem. Ich musste vor ein paar Jahren meine Heizungssteuerung durch einen Raspberry Pi ersetzen. Das funktioniert fast einwandfrei, nun habe ich den Raspberry durch einen Arduino nano ersetzt, weil man auch noch analoge Eingänge hat und das ganze stabiler läuft.
Es funktioniert soweit alles, bis auf den Aussenfühler. Der Aussenfühler ist ein DS1820 (kein DS18B20) da ich ihn im parasitären Modus betreiben muss, weil die Leitung nur 2-adrig ist. Die DS18B20 lassen sich anscheinend nicht mehr 2-adrig verwenden, zumindest mit dem Arduino nicht.
Zum Auslesen des Sensors verwende ich Teile des Codes von hier:
https://stoffl.info/2015/11/21/4415/
Das Problem ist jetzt, sobald es aussen unter 0 Grad hat, erhalte ich einen Wert von 4095.5.
Evtl. ist nur eine kleine Änderung am Programm nötig? Vielleicht liest ja auch der Autor “stoffl” hier mit?
Danke schonmal.
So, hab jetzt mal mein Programm angehängt, es wird nur der Aussensensor ausgelesen, alles andere habe ich der Übersicht halber rausgenommen
//#include <LiquidCrystal_I2C.h>
//dht22
//#include “DHT.h” //DHT Bibliothek laden
//uhrenmodul
//#include “RTClib.h”
//RTC_DS3231 rtc;
//char daysOfTheWeek[7][12] = {“Sonntag”, “Montag”, “Dienstag”, “Mittwoch”, “Donnerstag”, “Freitag”, “Samstag”};
//bool syncOnFirstStart = false; // true, falls die Zeitinformationen der RTC mit dem PC synchronisiert werden sollen.
// sollte standardm��ig auf false stehen
#include <Wire.h> // Wire Bibliothek hochladen
//#include <LiquidCrystal_I2C.h>// Vorher hinzugefügte LiquidCrystal_I2C Bibliothek hochladen
//LiquidCrystal_I2C lcd(0x27, 20, 4); //Hier wird festgelegt um was für einen Display es sich handelt. In diesem Fall einer mit 16 Zeichen in 2 Zeilen.
#include <DallasTemperature.h>
//für parasitären sensor
#define ONE_WIRE_BUS_1 A0
OneWire oneWire_in(ONE_WIRE_BUS_1);
DallasTemperature sensor_inhouse(&oneWire_in);
//-----------------------------------
//-----------dht22------------
//#define DHTPIN 4
//#define DHTTYPE DHT22
//DHT dht(DHTPIN, DHTTYPE);
OneWire ds(3); //pin für ds1820
//DeviceAddress sensor2 = { 0x10, 0xC6, 0xC9, 0xE7, 0x2, 0x8, 0x0, 0xF1 };//raumtemp
//DeviceAddress sensor3 = { 0x10, 0x6A, 0x5C, 0xB5, 0x1, 0x8, 0x0, 0x8E };//vorlauftemp
//DeviceAddress sensor4 = { 0x10, 0x9D, 0x32, 0xE8, 0x2, 0x8, 0x0, 0x6B };//ruecklauf
//DeviceAddress sensor5 = { 0x10, 0x5D, 0x78, 0xE7, 0x2, 0x8, 0x0, 0x3A };//strgtemp
//DeviceAddress sensor6 = { 0x10, 0xD9, 0x9B, 0xB, 0x2, 0x8, 0x0, 0xC3 };//badtemp
//DeviceAddress sensor7 = { 0x10, 0x59, 0x9B, 0xB5, 0x1, 0x8, 0x0, 0x49 };//wwtemp
//DeviceAddress sensor8 = { 0x10, 0x9A, 0xE6, 0x5F, 0x2, 0x8, 0x0, 0xB8 };//obentemp
//DeviceAddress sensor9 = { 0x10, 0xE7, 0x67, 0x0B, 0x02, 0x08, 0x0, 0xBA };//aussentemp
DeviceAddress sensor9 = { 0x10, 0x65, 0xE5, 0x59, 0x3, 0x8, 0x0, 0x2 };//aussentemp
//DeviceAddress sensor10 = { 0x10, 0x23, 0xE5, 0xE7, 0x02, 0x08, 0x0, 0xEA };//kuehlschrank
void setup() {
// put your setup code here, to run once:
//für parasitären modus
sensor_inhouse.begin();
Serial.begin(9600);
//----------------------
}
void loop() {
float aussentemp = getTemperature(sensor9);
Serial.print(aussentemp);
delay(1000);
}
/******************************************************
Temperatur eines Sensors in Grad Celsius ermitteln *
*****************************************************/
float getTemperature(byte address)
{
byte type_s;
byte data[12];
float celsius;
writeTimeToScratchpad(address);
readTimeFromScratchpad(address,data);
switch (address[0])
{
case 0x10: // DS18S20 oder alter DS1820
type_s = 1;
break;
case 0x28: // DS18B20
type_s = 0;
break;
case 0x22: // DS1822
type_s = 0;
break;
}
unsigned int raw = (data[1] << 8) | data[0];
if (type_s) {
raw = raw << 3; // 9 bit resolution default
if (data[7] == 0x10)
{
// count remain gives full 12 bit resolution
raw = (raw & 0xFFF0) + 12 - data[6];
}
} else {
byte cfg = (data[4] & 0x60);
if (cfg == 0x00) raw = raw << 3; // 9 bit resolution, 93.75 ms
else if (cfg == 0x20) raw = raw << 2; // 10 bit res, 187.5 ms
else if (cfg == 0x40) raw = raw << 1; // 11 bit res, 375 ms
}
celsius = (float)raw / 16.0;
return celsius;
}
/**************************************************************
Hilfsfunktionen zum ermitteln der Temperatur eines Sensors *
*************************************************************/
void writeTimeToScratchpad(byte address)
{
ds.reset();
ds.select(address);
ds.write(0x44,1);
delay(1000);
}
void readTimeFromScratchpad(byte* address, byte* data)
{
ds.reset();
ds.select(address);
ds.write(0xBE);
for (byte i=0;i<9;i++)
{
data[i] = ds.read();
}
}
sorry, ich hoffe ich habe es jetzt richtig reingestellt, ich habe seit Jahren nicht mehr in Foren gepostet