[SOLVED] Reading Sensatronics E4 with HttpClient lib on Photon

I’m trying to read temperature data from a Sensatronics E4 temperature monitor using HttpClient on a Photon.

My code here:

is copied from this thread: Spark Core Http Client Library
When I call
I expect to get a string back like this:

Probe 1|74.2|Probe 2|71.4|Probe 3|-99.9|Probe 4|-99.9

and when I read the sensor from Firefox, Matlab, or curl, that’s exactly what I get. But when I run this Photon program all I get is

Application>    Response status: -1
Application>    HTTP Response Body:

Application>    Start of Loop.
Application>    Response status: -1
Application>    HTTP Response Body:

Application>    Start of Loop.
Application>    Response status: -1
Application>    HTTP Response Body:

Apparently, the HttpClient library croaks because the E4 did not return an HTTP result code (eg. 200), just the data string. Unfortunately, Sensatronics is no longer with us so a firmware upgrade is out of the question.

Now I’d be happy to play with this myself but when I included the library directly into my code to make some changes, it wouldn’t compile, complaining something about multiple class definitions or some such C++ mumbo jumbo.

So does anyone know either:

  • how to get HttpClient to return a result when the provider doesn’t give a result code,
  • or how to get the HttpClient library to compile
  • or some other low-cost temperature sensor that provides a network REST API I can query successfully?


You could use TCPClient and construct the HTTP request yourself instead of using HTTPClient.

That’s probably because both the imported and the locally included libraries still exist in your project.
Try removing the imported version by hitting the (x) icon next to the library name
If that doesn’t help, create a new project where you never imported the library but only add your local copy of the lib.

1 Like

Ah ha - once again you gave me the answer. TCPClient worked just fine. Thank you so much. For the benefit of anyone else who might want to read a Sensatronics temperature server, here is some code that works:

#include "application.h"

char resultstr[64];
char buffer[64] = {" "} ;
char sub[12] ;
int nextTime = 0;
int bytesRead ;
int c = 0 ;

TCPClient client;
byte server[] = { 192, 168, 0, 117 };
void setup()
  // Make sure your Serial Terminal app is closed before powering your device
  // Wait for a USB serial connection for up to 30 seconds
  waitFor(Serial.isConnected, 30000);


  if (client.connect(server, 83))
    client.println("GET /temp HTTP/1.0");
  //  client.println("Host:");
  //  client.println("Content-Length: 0");
    delay (1000) ;
    Serial.println("connection failed");
  if (client.available())
  //  char c = client.read();
    bytesRead = client.read ((uint8_t*)buffer, 64);
    Serial.print ("buffer=") ;
    Serial.println (buffer);
      while (c < 4)
         sub[c] = buffer[9+c-1];
    Serial.print ("sub=") ;
    Serial.println (sub);       

  if (!client.connected())

void loop() {

This produces the following output:

buffer=Probe 1|74.9|Probe 2|72.1|Probe 3|-99.9|Probe 4|-99.9
1 Like