collected data with DS1820 temperature 1-wire sensors on the Arduino to FHEM

Hey all,

I need help with building a sketch to get temperature data (collected with DS1820 temperature 1-wire sensors on the arduino) to an instance of FHEM. (see Home of FHEM)
If s.b. build a similiar project or can help please advise.

Thanks a lot.
Regards,
Alex

Hardware & Software:
•Arduino Ethernet (WizNet W5100 TCP/IP-Ethernet-Controller)
•Temperatur-Sensor Hygrosens Temp.-Sensor DS 1820-BT
•Fhem 5.2 (DEVELOPMENT), $Id: fhem.pl 1996 2012-10-20 07:11:56Z
•FritzBox 7390

Here is what I already got:

#include <SPI.h>
#include <Ethernet.h>
#include "time.h"
#include "OneWire.h"
#include "DallasTemperature.h"

#define ONE_WIRE_BUS 3
OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer = { };
DeviceAddress outsideThermometer = { };

const byte MaxArrayElement=252;

byte mac[] = { MAC };
byte ip[] = {IP};
const byte bPort = 80;

EthernetServer server(80);

char c,cMstRecentCmnd='/';

char cLineBuffer[MaxArrayElement];
byte bPlaceInBuffer;

void setup()
{
Ethernet.begin(mac, ip);
server.begin();

Serial.begin(9600);
sensors.begin();
sensors.setResolution(insideThermometer, 10);
sensors.setResolution(outsideThermometer, 10);
}

void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00) {
Serial.print("Error getting temperature");
} else {
Serial.print("C: ");
Serial.print(tempC);

//Serial.print(" F: ");
//Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}

void loop()

{
delay(2000);
Serial.print("Getting temperatures...\n\r");
sensors.requestTemperatures();

Serial.print("Inside temperature is: ");
printTemperature(insideThermometer);
Serial.print("\n\r");
Serial.print("Outside temperature is: ");
printTemperature(outsideThermometer);
Serial.print("\n\r\n\r");

EthernetClient client = server.available();
if (client) {//2
boolean currentLineIsBlank = true;//3
bPlaceInBuffer=0;
char cCmnd='H';
cMstRecentCmnd='H';

while (client.connected()) {//4
if (client.available()) {//5
c = client.read();//6
if ((c!='\n') && (c!='\r')){
cLineBuffer[bPlaceInBuffer]=c;
if (bPlaceInBuffer<MaxArrayElement) {bPlaceInBuffer++;};
}
client.println();//10
client.println("");
client.println("");
client.print("ArduinoTemperatur-1Wire");
client.println("");
client.println("");
client.println();
client.println("");
client.println("");
client.print("

Temperatur: Messergebnisse");
client.println("

");
client.println("");
client.println();
client.println("
");

DeviceAddress insideThermometer = { 0x10, 0x55, 0xF2, 0x56, 0x02, 0x08, 0x00, 0xF3 };
DeviceAddress outsideThermometer = { 0x10, 0xB5, 0xDB, 0x56, 0x02, 0x08, 0x00, 0xD1 };
float tempI = sensors.getTempC(insideThermometer);
float tempA = sensors.getTempC(outsideThermometer);

client.println("");
client.print("
Temperatur, innen C: ");
client.print(tempI);
client.print("
");
client.println("");
client.print("
Temperatur, aussen C: ");
client.print(tempA);
}
client.println("");
client.println("");

break;//15
}
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}

You haven't asked a question. Which module of the FHEM do you plan to use? Do you write your own FHEM module? Do you emulate an existing one?

Use code tags (the "#" button in the form) around all code, else the parser might ruin it.

Hey Pylon,

I would like to get the temperatures to FHEM in any way possible. I just want to have them in a log file so I can show them in in graphical chart in FHEM.
One possible solution I found in the FHEM google forum was using two modules:
18_WBS.pm and 99_CGI_RAWMSG.pm

So I would use this web based sensors method to import the data to FHEM.
Post (german):
https://groups.google.com/forum/?fromgroups#!searchin/fhem-users/web$20based$20sensors/fhem-users/hYfsCOw837E/BcPU_OHCCdgJ

If there is a better solution ... would be great, too. :slight_smile:

Regards,
Alex

You opened a topic in the german forum, so I will answer you there.

OK.
Thank you very much!

german forum - topic can be found here:
http://arduino.cc/forum/index.php/topic,129112.0.html