OpenRemote and ESP8266

Hi everyone.

I’m trying to get some data from my ESP8266 weather station over Wi-Fi, but I’m confused. The ESP’s page looks like this:

I need to get Temperature and Humidity readings. For that I’m using HTTP sensor, but I don’t really know, what expression to use. Can anyone please help me? I’ve done well with XML and JSON expressions on Wunderground Weather data, but this one is a bit tricky.

Thank you

It might help the really clever people if you can share the page source for that web page, so that they can suggest the correct coding.

One of the developer tools in Chrome should show you the page source.

Good luck

Didn’t really think about it, good point. Thank you

This is the code from “View Source”:

ESP8266 - Temperature and Humidity

Temperature in Celsius: 22.92 *C

Temperature in Fahrenheit: 73.25 *F

Humidity: 51.40 %


I’ve tried to set HTTP command and use XPath expression which looks (from Chrome Inspection) like



but it didn’t work either.

Do you have the api structure ..
Its generslly available as a webpage might even be your url above followed by /api


Pieter has been in touch to suggest that it looks like your HTML has an error in it, which might be causing a problem.

Apparently, the last <h3> shouldn't be there.

He said that with the <h3> tag removed, the XPath query you created works fine on this test site :-

I also found a page the refers to an option to export XML from your ESP8266 device, is it any use to you?

Hi. Thank you for your response. The original code isn’t mine, it’s generated by ESP8266. I’ll check the second link you gave to me, maybe I’ll find something useful. I’ve some guy been talking about getting JSON response as well, I’ll get in touch with him as well. As OR works fine with JSON and XML. It suppose to work with HTML as well, but I don’t know how to make it work.

Purely going on what Pieter has observed, have you got a way of editing how your device offers up the HTML?

With the aim of removing the redundant <h3> tag?

Does your ESP8266 offer a template that you could edit?

Just out of curiosity...

Is this your weather station?

It works!!! Thank you! Thank you! Thank you!

No, that one is mine:

If someone is interested, later will do a little guide, how to merge ESP8266+OR.

Congratulations :slight_smile:

I'd be interested to know more about your weather station.


I don’t want to create another one post, so I will reply here. Sorry for my English, it is not my mother tongue.

I started to build my smart house about 3 months ago. It’s made on RaZberry+Z-Way Server+OpenRemote. Main target is to create an automated climate control system. I’ve started with temperature and humidity control. For that I’ve got ESP8266 NodeMCU+DHT22 sensor:

I will not post pictures with connection instructions, you always can find them on Internet, as well as a sketch. I’ve just slightly modified the code, to get readings the way I need, thanks to you by the way :wink: It looks like this (and it’s not finished yet):

// Including the ESP8266 WiFi library

#include <ESP8266WiFi.h>

#include “DHT.h”

// Uncomment one of the lines below for whatever DHT sensor type you’re using!

//#define DHTTYPE DHT11 // DHT 11

//#define DHTTYPE DHT21 // DHT 21 (AM2301)

#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321

// Replace with your network details

const char* ssid = “yourWiFiname”;

const char* password = “WiFipassword”;

// Web Server on port 80

WiFiServer server(80);

// DHT Sensor

const int DHTPin = 2;

// Initialize DHT sensor.


// Temporary variables

static char celsiusTemp[7];

static char fahrenheitTemp[7];

static char humidityTemp[7];

// only runs once on boot

void setup() {

// Initializing serial port for debugging purposes




// Connecting to WiFi network


Serial.print("Connecting to ");


WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {





Serial.println(“WiFi connected”);

// Starting the web server


Serial.println(“Web server running. Waiting for the ESP IP…”);


// Printing the ESP IP address



// runs over and over again

void loop() {

// Listenning for new clients

WiFiClient client = server.available();

if (client) {

Serial.println("New client");

// bolean to locate when the http request ends

boolean blank_line = true;

while (client.connected()) {

  if (client.available()) {

    char c =;


    if (c == '\n' && blank_line) {

        // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)

        float h = dht.readHumidity();

        // Read temperature as Celsius (the default)

        float t = dht.readTemperature();

        // Read temperature as Fahrenheit (isFahrenheit = true)

        float f = dht.readTemperature(true);

        // Check if any reads failed and exit early (to try again).

        if (isnan(h) || isnan(t) || isnan(f)) {

          Serial.println("Failed to read from DHT sensor!");


          strcpy(fahrenheitTemp, "Failed");

          strcpy(humidityTemp, "Failed");         



          // Computes temperature values in Celsius + Fahrenheit and Humidity

          float hic = dht.computeHeatIndex(t, h, false);       

          dtostrf(hic, 6, 2, celsiusTemp);             

          float hif = dht.computeHeatIndex(f, h);

          dtostrf(hif, 6, 2, fahrenheitTemp);         

          dtostrf(h, 6, 2, humidityTemp);

          // You can delete the following Serial.print's, it's just for debugging purposes

          Serial.print("Humidity: ");


          Serial.print(" %\t Temperature: ");


          Serial.print(" *C ");


          Serial.print(" *F\t Heat index: ");


          Serial.print(" *C ");


          Serial.print(" *F");

          Serial.print("Humidity: ");


          Serial.print(" %\t Temperature: ");


          Serial.print(" *C ");


          Serial.print(" *F\t Heat index: ");


          Serial.print(" *C ");


          Serial.println(" *F");


        client.println("HTTP/1.1 200 OK");

        client.println("Content-Type: text/html");

        client.println("Connection: close");


        // your actual web page that displays temperature and humidity

        client.println("<!DOCTYPE HTML>");


        client.println("<head></head><body><h1>ESP8266 - Temperature and Humidity</h1><h3> ");


        client.println("</h3><h3> ");


        client.println("</h3><h3> ");






    if (c == '\n') {

      // when starts reading a new line

      blank_line = true;


    else if (c != '\r') {

      // when finds a character on the current line

      blank_line = false;




// closing the client connection



Serial.println("Client disconnected.");




As you can see, client.printIn lines associated with sensor data are empty, I’ve done it on purpose, to get digits only, without any redundant symbols, it will be easier to put them into OR later. To get XPATH we need to Inspect the webpage and select [h3] tag we are looking for. The first one is temperature in Celsius, the second - in Fahrenheit and the third one - humidity:

Then in the Designer we create New Command, Select HTTP and fill the fields as shown below:

After that we create Sensor using this command. The type is “Custom”. And finally just add this sensor to you OR Designer. Mine looks like this:

Later I’will write a rule, which reads humidity value and depending on it activates dehumidifier`s Z-Wave socket. Also I’m thinking to get a descent size and look enclosure to put my weather station in.

If you have any questions do not hesitate to ask


Beautifully done :slight_smile:

I'll definitely add that project to my wish list.

I've been thinking of adding a humidity sensor to my bathroom and linking it to an extraction fan.

Hello, i am very interested in how you get the data from the esp8266 in to openremote sensors. I have got an esp8266 for reading the power usage from my smart meter. (All Dutch household wil have this meter by the end of 2016).
The esp publishes a similar page with current and total power usage. I would like to read out this data and use it in OR.
This is the device I am talking about

Hi Bart,

If you read every part of this thread you should find exactly what you're looking for.

If you run into trouble, post the source from the webpage (as detailed in this thread) and I'm sure someone will come up with something that will help.


Hi Stuart,
don’t know did you get my PM, just will reply eventually here :slight_smile: you probably will be interested in this kind of stuff. It has ESP8266 and 10A relay on board, I’ve got one of this, but just don’t know where I can use it :))

Hi Stuart,

I finally got my smart energy meter and experiment with the esp8266. The smart energy meter has a P1 port, this is a serial port. The ESP8266 is connected to the serial port and converts the serial output to TCPIP. Unfortunately the ESP does not have a fancy web page. The only thing it does is sending the serial outpu to IP every 10 seconds.

I tried the TCP IP option in openremote but it only reads the data once at startup!

I used a tcpip client to test if i can receive any data and this is the data i get;

Any suggestions on how to get the data in openremote?


Hi Bart

I'll confess that I haven't used the TCP/IP commands yet....


There is a polling interval option at the bottom :slight_smile:

So, I suggest you just put a value in there :slight_smile:

You'll have to double check the how-to, but I think the default measurement is seconds.

I saw 'polling interval' referred to in other protocols and I think you can define the interval in milliseconds, seconds, minutes or hours.

Give it a try and let us know how you get on.

Good luck,


Well, i tried the polling interval with different times but nothing is happening. The strange thing is that if i set up a tcpip connection in openremote nothing happens until i use a separate TCPIP client test utility on my laptop to see if the espis sending data, the dat is received by the test program but in openremote as well.
Every time i start the connection on my laptop with the test software the same data is received by openremote. As soon as i stop the test software openremote stops receiving data as well.

Hi Bart. I'm not sure if that will help, but can you please show me your esp8266 sketch and openremote sensor settings includung command window