gordonturner / arduino-webserver-temperature-sensor

Arduino web server using an Ethernet Shield and 1-Wire temperature sensor to output XML, JSON, JSONP or Prometheus (prom format) response.
5 stars 2 forks source link

OneWire Server code #1

Open ka5zci opened 4 years ago

ka5zci commented 4 years ago

Hi,

I have been playing with your code, and with limited skills was able to add additional 1wire sensors...However, have NOT been able to get them to output as xml as original code...only the first 1wire is outputted. My goal was to have ability to monitor 4 sensors ideally via the simple xml or JSON to monitor a Brewing process more easily.

Am I flailing at something that just wont't work?

Thanks!

GordonTurner-ICFNext commented 4 years ago

Hey, so I am clear, you added three more devices and addresses like:

DeviceAddress outsideThermometer = { 0x28, 0x85, 0x95, 0x3A, 0x04, 0x00, 0x00, 0xB7 };
DeviceAddress outsideThermometer1 = { 0x28, 0x85, 0x95, 0x3A, 0x04, 0x00, 0x00, 0xB7 }; //Second
DeviceAddress outsideThermometer2 = { 0x28, 0x85, 0x95, 0x3A, 0x04, 0x00, 0x00, 0xB7 }; //Third
DeviceAddress outsideThermometer3 = { 0x28, 0x85, 0x95, 0x3A, 0x04, 0x00, 0x00, 0xB7 }; //Forth

Plus all the void setup() for the extra sensors?

Did you update the sendXmlResponse() to include the additional sensors values?

ie sendXmlResponse(client, celsius, fahrenheit, error); is for a response with one sensor, you could, in theory, add the others in the one call:

sendXmlResponse(client, celsius1, fahrenheit1, celsius2, fahrenheit2, celsius3, fahrenheit3, celsius4, fahrenheit4, error);

Gord.

ka5zci commented 4 years ago

Thanks Gord,

I had this as you described with one exception.....the code would not compile when endXmlResponse was populated as in your example. I forget the exact error, but was a failure to convert FLOAT to String...and sending them as individual endXmlResponse statements were accepted without error.

I am still plugging away at this and will eventually figure it out. Really just wanted some confidence that it was at least "Possible" in your estimation to get 4 onewires to output same as the single device does in your original code.

Thanks! Bob

gordonturner commented 4 years ago

Hey Bob,

Sure it should be, the code is pretty procedural, maybe start with 2 wires and build up from there?

There should be no float conversion, as the print statements are independent (sort of avoiding the whole conversion thing).

E.g.

    client.print("<celcius>");
    client.print(celsius);
    client.print("</celcius>");

Unless there is a change in the library or something?

Gord.