Read temperature via web command on D1 with SHT30 installed

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
mattlward
Normal user
Posts: 70
Joined: 24 Jan 2018, 15:20

Read temperature via web command on D1 with SHT30 installed

#1 Post by mattlward » 19 Dec 2018, 22:46

I am running several D1's with the latest nightly build and SHT30's onboard. I need send an HTTP command that will read the temperature... How in the world do I do that?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Read temperature via web command on D1 with SHT30 installed

#2 Post by grovkillen » 19 Dec 2018, 23:45

Please explain more.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

mattlward
Normal user
Posts: 70
Joined: 24 Jan 2018, 15:20

Re: Read temperature via web command on D1 with SHT30 installed

#3 Post by mattlward » 20 Dec 2018, 05:08

I have placed a few of these in network closets for testing at work. The problem is, traditional network monitors do not use MQTT and ESP's do not use SNMP and I need to get the data from the devices. If I can ask the device a question via HTTP that responds with a simple numerical answer, I can directly import that value. I would likely ask the device every minute or so, but not likely an more frequently than that.

I had hoped to use the control?cmd/status for it, but it does not appear to provide more than a question mark for the answer. I could ask for /json, but that is very difficult to break down and out in a probe. Unless I can ask for a very specific variable with an extension to the json command.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Read temperature via web command on D1 with SHT30 installed

#4 Post by grovkillen » 20 Dec 2018, 06:09

You can filter the JSON request but not down to a single value. I guess it could be useful. Please open a new feature request on GitHub.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Read temperature via web command on D1 with SHT30 installed

#5 Post by Domosapiens » 20 Dec 2018, 10:37

How about this:
make an Event in Rules
Event contains a SendToHTTP with the temperature
Someting like (example to Domoticz):

Code: Select all

on testevent do
  SendToHTTP,x.x.x.x,8080,/json.htm?type=command&param=udevice&idx=385&nvalue=0&svalue=[SHT30#Temperature]
endon
Call that Event from outside

Code: Select all

http://x.x.x.x/control?cmd=event,testevent
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

mattlward
Normal user
Posts: 70
Joined: 24 Jan 2018, 15:20

Re: Read temperature via web command on D1 with SHT30 installed

#6 Post by mattlward » 20 Dec 2018, 17:46

I can't run software or remote commands on the system that does the monitoring. I really just need the ESP to generate a web page with the numerical temperature.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Read temperature via web command on D1 with SHT30 installed

#7 Post by grovkillen » 20 Dec 2018, 18:16

mattlward wrote: 20 Dec 2018, 17:46 I can't run software or remote commands on the system that does the monitoring. I really just need the ESP to generate a web page with the numerical temperature.
Please, open a feature request on GitHub.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Read temperature via web command on D1 with SHT30 installed

#8 Post by ThomasB » 22 Dec 2018, 04:02

I really just need the ESP to generate a web page with the numerical temperature.
FanOfHue is developing a plugin that might solve your problem.
See viewtopic.php?f=6&t=6098&p=33332

- Thomas

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Read temperature via web command on D1 with SHT30 installed

#9 Post by Wiki » 22 Dec 2018, 13:04

Just an idea how to solve your task instantly.

Assuming you have a webserver running on your monitoring system just place a small php-script named survey.php on it:

Code: Select all

<?php
isset($_GET['value']) ? $value=$_GET['value'] : $value='';
isset($_GET['ID']) ? $ID=$_GET['ID'] : $ID='';
$now = time();
$date = date("d.m.Y", $now);
$time = date("H:i:s", $now);
$page = "Temperature".$ID.".html";
$handle = fopen($page, 'w');
fwrite($handle,"<html>");
fwrite($handle,"<body>");
fwrite($handle,"<p>".$date."</p>");
fwrite($handle,"<p>".$time."</p>");
fwrite($handle,"<p>".$value."</p>");
fwrite($handle,"</body>");
fwrite($handle,"</html>");
fclose($handle);
?>
Define the webserver as Generic HTTP Controller in ESPEasy with Controller Publish "survey.php?value=%value%&ID=%unit%", enable the controller in device settings.

The php script will generate a neat small individual webpage containing date, time and value of each of your different devices named "TemperatureXY.html" (XY=unit no. of the device). On your monitoring system you're now able to call the individual pages using "http://localhost/TemperatureXY.html".

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

User avatar
iron
Normal user
Posts: 221
Joined: 24 Sep 2016, 08:37
Location: Greece
Contact:

Re: Read temperature via web command on D1 with SHT30 installed

#10 Post by iron » 26 Dec 2018, 10:54

Do not forget the custom web pages.

Just upload an .htm file (http://ip_of_your_device/upload) that returns just the value you want and then call that file within your call url e.g. :

http://<ip of you device/return1.htm

-D
-D

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Read temperature via web command on D1 with SHT30 installed

#11 Post by Wiki » 26 Dec 2018, 14:21

iron wrote: 26 Dec 2018, 10:54 Do not forget the custom web pages.

Just upload an .htm file (http://ip_of_your_device/upload) that returns just the value you want and then call that file within your call url e.g. :

http://<ip of you device/return1.htm

-D
Interesting. I didn't read about this possibility anything. Do you have some links for documentation?

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

User avatar
iron
Normal user
Posts: 221
Joined: 24 Sep 2016, 08:37
Location: Greece
Contact:

Re: Read temperature via web command on D1 with SHT30 installed

#12 Post by iron » 26 Dec 2018, 15:32

Wiki wrote: 26 Dec 2018, 14:21
iron wrote: 26 Dec 2018, 10:54 Do not forget the custom web pages.

Just upload an .htm file (http://ip_of_your_device/upload) that returns just the value you want and then call that file within your call url e.g. :

http://<ip of you device/return1.htm

-D
Interesting. I didn't read about this possibility anything. Do you have some links for documentation?
https://www.letscontrolit.com/wiki/inde ... _Dashboard

but all you have to do is upload your own .htm file that posts the value you wish as a response. and then call that url. That's all.

If you extend your file as .esp the system will be doing some parsing as in the example in the link.
if you extend it as .htm there will be no parsing.

Whichever works the best for you.

-D
-D

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Read temperature via web command on D1 with SHT30 installed

#13 Post by Wiki » 26 Dec 2018, 18:56

Wow, that's cute.

Thank you for this information. I think this is exactly what mattlward was looking for - and at least, me, too.

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 27 guests