{"id":328,"date":"2021-10-24T21:18:53","date_gmt":"2021-10-24T20:18:53","guid":{"rendered":"https:\/\/www.randomturns.eu\/?p=328"},"modified":"2021-11-18T21:53:36","modified_gmt":"2021-11-18T20:53:36","slug":"sensor-data-on-wordpress","status":"publish","type":"post","link":"https:\/\/www.randomturns.eu\/index.php\/sensor-data-on-wordpress\/","title":{"rendered":"Sensor Data on WordPress &#8211; Practical data monitoring with a cost-effective Raspberry Pi website"},"content":{"rendered":"<div class=\"taxonomy-post_tag wp-block-post-terms\"><a href=\"https:\/\/www.randomturns.eu\/index.php\/tag\/raspberrypi\/\" rel=\"tag\">raspberrypi<\/a><span class=\"wp-block-post-terms__separator\">, <\/span><a href=\"https:\/\/www.randomturns.eu\/index.php\/tag\/sensor-data\/\" rel=\"tag\">sensor-data<\/a><span class=\"wp-block-post-terms__separator\">, <\/span><a href=\"https:\/\/www.randomturns.eu\/index.php\/tag\/wordpress\/\" rel=\"tag\">wordpress<\/a><\/div>\n\n<p>The Raspberry Pi is something of a Swiss army knife, the enormous amount of <a href=\"https:\/\/magpi.raspberrypi.com\/articles\/best-raspberry-pi-4-projects\" target=\"_blank\" rel=\"noopener\">applications<\/a> it has been used is mind-boggling. It is simple math &#8211; make a certain technology wildly versatile, make it cheap and accessible for the masses and soon enough there will be a lot of good ideas in circulation. One of the many things you can check in the Raspberry Pi without the need of additional gear is to read the CPU temperature.<\/p>\n<p>This <a href=\"https:\/\/www.randomturns.eu\/index.php\/raspberry-pi-web-server-become-accessible-in-the-world-stage\/\">website<\/a> is hosted by a <a href=\"https:\/\/www.randomturns.eu\/index.php\/easiest-headless-raspberry-pi-setup\/\">headless<\/a> Raspberry Pi working away in the cold depths of my tool shed. This post will be about how to display sensor data on WordPress collected by the Raspberry Pi, such as the CPU temperature, in the &#8220;Google Charts&#8221; gauge as you can see below.<\/p>\n\n\n<script src=\"https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/3.5.1\/jquery.min.js\"><\/script>\n    <script type=\"text\/javascript\" src=\"https:\/\/www.gstatic.com\/charts\/loader.js\"><\/script>\n    <script>\n        function startRefresh() {\n            setTimeout(startRefresh,500);\n            $.get(\"temp.html\", function (data) {\n                dt = parseInt(data);\n            });\n        };        \n        var dt = 0;\n        $(document).ready(function(){\n\n            $(function() {\n                startRefresh();\n            });\n\n\n            google.charts.load('current', {'packages':['gauge']});\n            google.charts.setOnLoadCallback(drawChart);\n\n            function drawChart() {\n\n                var data = google.visualization.arrayToDataTable([\n                ['Label', 'Value'],\n                ['Temp C', dt],\n                ]);\n\n                var options = {\n                width: 400, height: 120,\n                redFrom: 85, redTo: 100,\n                yellowFrom:60, yellowTo: 85,\n                minorTicks: 5\n                };\n\n                var chart = new google.visualization.Gauge(document.getElementById('chart_div'));\n\n                chart.draw(data, options);\n\n                setInterval(function() {\n                data.setValue(0, 1, dt);\n                chart.draw(data, options);\n                }, 500);\n            }\n\n\n        });\n\n    <\/script>\n  \n  \n\n    <div id=\"chart_div\" style=\"width: 400px; height: 120px;\"><\/div>\n\n\n<p>Running &#8216;vcgencmd measure_temp&#8217; in my headless Raspberry Pi terminal (which also hosts this very website you&#8217;re currently reading) yields &#8220;temp=45.1\u00b0C&#8221; which is the current temperature of the processor. This is good since the shut-down limit is 85\u00b0C and the throttle-down from 1.4GHz to 1.2GHz (soft-limit) happens already at 60\u00b0C which is easily achieved in room-temperatures. Keeping up the performance is good no matter what you decide to do, for example running retropie or maybe hosting a web server even though I doubt that the CPU utilization would peak very often.<\/p>\n<p><em>Work in progress&#8230;<br><\/em><\/p>","protected":false},"excerpt":{"rendered":"<p>This website is hosted by a headless Raspberry Pi working away in the cold depths of my tool shed. This post will be about how to display sensor data on Wordpress collected by the Raspberry Pi, such as the CPU temperature, in the gauge as you can see below.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[15],"tags":[16,21,20],"class_list":["post-328","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi","tag-raspberrypi","tag-sensor-data","tag-wordpress"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.randomturns.eu\/index.php\/wp-json\/wp\/v2\/posts\/328","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.randomturns.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.randomturns.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.randomturns.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.randomturns.eu\/index.php\/wp-json\/wp\/v2\/comments?post=328"}],"version-history":[{"count":118,"href":"https:\/\/www.randomturns.eu\/index.php\/wp-json\/wp\/v2\/posts\/328\/revisions"}],"predecessor-version":[{"id":497,"href":"https:\/\/www.randomturns.eu\/index.php\/wp-json\/wp\/v2\/posts\/328\/revisions\/497"}],"wp:attachment":[{"href":"https:\/\/www.randomturns.eu\/index.php\/wp-json\/wp\/v2\/media?parent=328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.randomturns.eu\/index.php\/wp-json\/wp\/v2\/categories?post=328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.randomturns.eu\/index.php\/wp-json\/wp\/v2\/tags?post=328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}