Hi.
Im trying to send probe temperatures with the Etherevent as payload.This sends the temperatures to eventghost for futher processing
Im a newbee that mostly cut and past but progress is beeing made every day.
This problem is probably only a newbees problem.
I suspect it is that easy, but I am stuck.
Everything else seems to work fine.
#include <SPI.h>
#include <Ethernet.h>
#define ETHEREVENT_NO_AUTHENTICATION //this line must come before #include "EtherEvent.h"
#include <EtherEvent.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS_PIN 6
OneWire oneWire(ONE_WIRE_BUS_PIN);
DallasTemperature sensors(&oneWire);
DeviceAddress Probe01 = { 0x28, 0xE7, 0x0A, 0x5C, 0x02, 0x00, 0x00, 0x8A };
DeviceAddress Probe02 = { 0x28, 0x6A, 0x54, 0x5C, 0x02, 0x00, 0x00, 0x1D };
DeviceAddress Probe03 = { 0x28, 0x4D, 0x8D, 0x40, 0x04, 0x00, 0x00, 0x78 };
DeviceAddress Probe04 = { 0x28, 0x9A, 0x80, 0x40, 0x04, 0x00, 0x00, 0xD5 };
DeviceAddress Probe05 = { 0x28, 0xE1, 0xC7, 0x40, 0x04, 0x00, 0x00, 0x0D };
byte MACaddress[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //this can be anything you like, but must be unique on your network
const IPAddress deviceIP = IPAddress(192,168,1,177); //IP address to use for the device. This can be any valid address on the network as long as it is unique. If you are using DHCP then this doesn't need to be configured.
const unsigned int port = 1001; //TCP port to receive events
const unsigned int sendEventInterval = 60000; //(ms)Delay between sending the test events.
const IPAddress targetIP = IPAddress(192, 168, 1, 104); //The IP address to send the test events to.
const unsigned int targetPort = 1001; //The port to send the test events to. This will also be used as the default port to send events to.
EthernetServer ethernetServer(port); //TCP port to receive on
EthernetClient ethernetClient; //create the client object for Ethernet communication
unsigned long sendTimestamp; //used by the example to periodically send an event
void setup() /****** SETUP: RUNS ONCE ******/
{
// start serial port to show results
Serial.begin(9600);
Serial.print("Initializing Temperature Control Library Version ");
Serial.println(DALLASTEMPLIBVERSION);
Ethernet.begin(MACaddress, deviceIP); //use static IP address
ethernetServer.begin(); //begin the server that will be used to receive events
if (EtherEvent.begin() == false) { //initialize EtherEvent
Serial.print(F("ERROR: Buffer size exceeds available memory, use smaller values."));
while (true); //abort execution of the rest of the program
}
// Initialize the Temperature measurement library
sensors.begin();
// set the resolution to 10 bit (Can be 9 to 12 bits .. lower is faster)
sensors.setResolution(Probe01, 10);
sensors.setResolution(Probe02, 10);
sensors.setResolution(Probe03, 10);
sensors.setResolution(Probe04, 10);
sensors.setResolution(Probe05, 10);
}//--(end setup )---
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
delay(10000);
Serial.println();
Serial.print("Number of Devices found on bus = ");
Serial.println(sensors.getDeviceCount());
Serial.print("Getting temperatures... ");
Serial.println();
// Command all devices on bus to read temperature
sensors.requestTemperatures();
Serial.print("Probe 01 temperature is: ");
printTemperature(Probe01);
Serial.println();
Serial.print("Probe 02 temperature is: ");
printTemperature(Probe02);
Serial.println();
Serial.print("Probe 03 temperature is: ");
printTemperature(Probe03);
Serial.println();
Serial.print("Probe 04 temperature is: ");
printTemperature(Probe04);
Serial.println();
Serial.print("Probe 05 temperature is: ");
printTemperature(Probe05);
Serial.println();
EtherEvent.send(ethernetClient, targetIP, targetPort, "C: ", "payload");
}//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
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));
}
}// End printTemperature
//*********( THE END )***********