I’m hoping some kind person will spare me a moment to answer what I think, for the right person, will be a straightforward question. I have tried searching the forums (and done a big Google search) but to no avail. I’m probably searching using the wrong keywords…
So, I have an emoncms.org account with various temperature feeds, etc. I want to take just ONE of these and display it on a web page. I don’t need a graph or anything fancy (although, ironically, I think I have found out how to do that!) To be absolutely clear, all I want to do is have a sentence on my (external) website that says "Current Pool Temperature is: " X, where the value of X is pulled from an Emoncms.org feed using my API keys.
This surely must be a simple task, but clearly not a popular one as I cannot find out how to do it…
Many thanks for your time and understanding
A very basic way of doing this with PHP:
<meta http-equiv="refresh" content="10">
$json = file_get_contents('https://emoncms.org/feed/value.json?id=FEEDID&apikey=READAPIKEY');
$feed = json_decode($json);
echo "Current use is ".$feed;
More info on Emoncms feed API here.
That is fab. Thank you so much! I didn’t realise it could be that simple.
One more quick question: my DS18b20 chips all read temperature to hundredths of a degree, hence the feed is to two decimal places. Is there an easy/quick way to round it to one d.p., please? Sorry for asking such a numpty question, but my main experience of programming was back in the 1980s with BASIC and Fortran…
Best regards, Stuart.
For PHP you could try:
$number = 2.7890;
$newnumber = number_format($number, 1);
stackoverflow.com is a good place to look for these things, amongst others.