{"id":4073,"date":"2023-08-10T01:08:16","date_gmt":"2023-08-09T23:08:16","guid":{"rendered":"https:\/\/www.benecomunecernusco.it\/wordpress\/?page_id=4073"},"modified":"2026-11-09T01:23:42","modified_gmt":"2026-11-09T00:23:42","slug":"sensore-000","status":"publish","type":"page","link":"https:\/\/www.benecomunecernusco.it\/wordpress\/sensore-000\/","title":{"rendered":"Sensore 000"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Posizione (+ e &#8212; per modificare lo zoom):<\/p>\n\n\n\n<iframe loading=\"lazy\" width=\"660\" height=\"300\" style=\"border: 1px solid #cccccc;\" src=\"https:\/\/thingspeak.com\/channels\/1250149\/maps\/channel_show?width=655&amp;heigth=235\"><\/iframe>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity is-style-wide\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">PM2.5 istantaneo:<\/p>\n\n\n\n<iframe loading=\"lazy\" width=\"450\" height=\"260\" style=\"border: 1px solid #cccccc;\" src=\"https:\/\/thingspeak.com\/channels\/1250149\/widgets\/695095?title=PM2.5+istantaneo\"><\/iframe>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity is-style-wide\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">PM10 istantaneo:<\/p>\n\n\n\n<iframe loading=\"lazy\" width=\"450\" height=\"260\" style=\"border: 1px solid #cccccc;\" src=\"https:\/\/thingspeak.com\/channels\/1250149\/widgets\/695929\"><\/iframe>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity is-style-wide\"\/>\n\n\n\n<iframe loading=\"lazy\" width=\"660\" height=\"300\" style=\"border: 1px solid #cccccc;\" src=\"https:\/\/thingspeak.com\/channels\/1250149\/charts\/1?width=auto&amp;heigth=auto&amp;average=10&amp;bgcolor=%23ffffff&amp;color=%23d62020&amp;dynamic=true&amp;results=240&amp;round=2&amp;title=PM2.5+-+Ultime+12+ore&amp;type=column&amp;xaxis=Ora&amp;yaxis=PM2.5+%28\u00b5g%2Fm3%29\"><\/iframe>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity is-style-wide\"\/>\n\n\n\n<iframe loading=\"lazy\" width=\"660\" height=\"300\" style=\"border: 1px solid #cccccc;\" src=\"https:\/\/thingspeak.com\/channels\/1250149\/charts\/3?width=auto&amp;heigth=auto&amp;average=10&amp;bgcolor=%23ffffff&amp;color=%23038d07&amp;dynamic=true&amp;results=240&amp;round=2&amp;title=PM10+-+Ultime+12+ore&amp;type=column&amp;xaxis=Ora&amp;yaxis=PM10+%28\u00b5g%2Fm3%29\"><\/iframe>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity is-style-wide\"\/>\n\n\n\n<style>\n.highcharts-figure, .highcharts-data-table table {\n    min-width: 310px;\n    max-width: 800px;\n    margin: 1em auto;\n}\n\n.highcharts-data-table table {\n    font-family: Verdana, sans-serif;\n    border-collapse: collapse;\n    border: 1px solid #EBEBEB;\n    margin: 10px auto;\n    text-align: center;\n    width: 100%;\n    max-width: 600px;\n}\n\n.highcharts-data-table caption {\n    padding: 1em 0;\n    font-size: 0.9em;\n    color: #555;\n}\n\n.highcharts-data-table th {\n    font-weight: 500;\n    padding: 0.5em;\n}\n\n.highcharts-data-table td,\n.highcharts-data-table th,\n.highcharts-data-table caption {\n    padding: 1em;\n}\n\n.highcharts-data-table thead tr,\n.highcharts-data-table tr:nth-child(even) {\n    background: #f8f8f8;\n}\n\n.highcharts-data-table tr:hover {\n    background: #f1f7ff;\n}\n<\/style>\n\n<script src=\"https:\/\/code.highcharts.com\/highcharts.js\"><\/script>\n<script src=\"https:\/\/code.highcharts.com\/highcharts-more.js\"><\/script>\n<script src=\"https:\/\/code.highcharts.com\/modules\/exporting.js\"><\/script>\n<script src=\"https:\/\/code.highcharts.com\/modules\/series-label.js\"><\/script>\n<script src=\"https:\/\/code.highcharts.com\/modules\/export-data.js\"><\/script>\n<script src=\"https:\/\/code.highcharts.com\/modules\/accessibility.js\"><\/script>\n\n<figure class=\"highcharts-figure\">\n    <div id=\"container\"><\/div>\n    <figcaption>\n        Grafico degli ultimi 4 giorni di registrazione di PM2.5 e PM10\n        rilevati dalla centralina PMS5003 n.000. Ogni punto mostra il\n        valore della media delle misure fatte nell&#8217;ora precedente\n        (media mobile oraria).\n    <\/figcaption>\n<\/figure>\n\n<script>\n(function () {\n\n    const CHANNEL_ID = '1253820';\n    const READ_API_KEY = 'EDMX5MRXCJ7LU0PO';\n\n    const requestURL =\n        'https:\/\/api.thingspeak.com\/channels\/' +\n        CHANNEL_ID +\n        '\/feeds.json?api_key=' +\n        encodeURIComponent(READ_API_KEY) +\n        '&days=4';\n\n    function mostraErrore(messaggio) {\n        const container = document.getElementById('container');\n        container.innerHTML =\n            '<p style=\"text-align:center; color:#b00020; padding:30px;\">' +\n            messaggio +\n            '<\/p>';\n    }\n\n    function valoreValido(valore) {\n        if (valore === null || valore === undefined || valore === '') {\n            return null;\n        }\n\n        const numero = Number(valore);\n        return Number.isFinite(numero) ? numero : null;\n    }\n\n    function popolaGrafico(risposta) {\n\n        if (!risposta || !Array.isArray(risposta.feeds)) {\n            mostraErrore('Risposta non valida da ThingSpeak.');\n            return;\n        }\n\n        const misure = risposta.feeds;\n\n        if (misure.length === 0) {\n            mostraErrore('Nessuna misura disponibile negli ultimi 4 giorni.');\n            return;\n        }\n\n        const serie25 = [];\n        const serie10 = [];\n\n        misure.forEach(function (misura) {\n\n            const data = Date.parse(misura.created_at);\n\n            if (!Number.isFinite(data)) {\n                return;\n            }\n\n            const pm25 = valoreValido(misura.field3);\n            const pm10 = valoreValido(misura.field4);\n\n            if (pm25 !== null) {\n                serie25.push([data, pm25]);\n            }\n\n            if (pm10 !== null) {\n                serie10.push([data, pm10]);\n            }\n        });\n\n        serie25.sort((a, b) => a[0] - b[0]);\n        serie10.sort((a, b) => a[0] - b[0]);\n\n        if (serie25.length === 0 && serie10.length === 0) {\n            mostraErrore('Non sono disponibili valori PM2.5 o PM10 validi.');\n            return;\n        }\n\n        Highcharts.chart('container', {\n\n            time: {\n                timezone: 'Europe\/Rome'\n            },\n\n            chart: {\n                type: 'line',\n                zooming: {\n                    type: 'x'\n                }\n            },\n\n            title: {\n                text: 'PM 2.5 \/ PM 10 Ultimi 4 giorni',\n                align: 'center'\n            },\n\n            subtitle: {\n                text: 'Sensore PMS5003 n.000 situato in Cernusco sul Naviglio (MI) - Viale Assunta',\n                align: 'center'\n            },\n\n            xAxis: {\n                type: 'datetime',\n                labels: {\n                    overflow: 'justify'\n                }\n            },\n\n            yAxis: {\n                title: {\n                    text: '\u00b5g\/m3'\n                },\n\n                min: 0,\n                minorGridLineWidth: 1,\n                gridLineWidth: 1,\n                gridZIndex: 3,\n                minorTickLength: 5,\n                alternateGridColor: '#ffffff',\n\n                plotBands: [\n                    {\n                        from: 0,\n                        to: 10,\n                        color: 'rgba(0, 255, 0, 0.25)',\n                        label: { text: 'Good' }\n                    },\n                    {\n                        from: 10,\n                        to: 25,\n                        color: 'rgba(255, 255, 0, 0.35)',\n                        label: { text: 'Acceptable' }\n                    },\n                    {\n                        from: 25,\n                        to: 75,\n                        color: 'rgba(255, 192, 0, 0.35)',\n                        label: { text: 'Worrying' }\n                    },\n                    {\n                        from: 75,\n                        to: 125,\n                        color: 'rgba(255, 0, 0, 0.35)',\n                        label: { text: 'Bad' }\n                    },\n                    {\n                        from: 125,\n                        to: 200,\n                        color: 'rgba(112, 48, 160, 0.40)',\n                        label: { text: 'Very Bad' }\n                    },\n                    {\n                        from: 200,\n                        to: 250,\n                        color: 'rgba(16, 7, 23, 0.4)',\n                        label: {\n                            text: 'Dangerous',\n                            style: { color: '#ffffff' }\n                        }\n                    },\n                    {\n                        from: 250,\n                        to: 300,\n                        color: 'rgba(16, 7, 23, 0.55)',\n                        label: {\n                            text: 'Health Alert',\n                            style: { color: '#ffffff' }\n                        }\n                    }\n                ]\n            },\n\n            tooltip: {\n                shared: true,\n                xDateFormat: '%d\/%m\/%Y %H:%M'\n            },\n\n            series: [\n                {\n                    type: 'line',\n                    color: '#ff0000',\n                    name: 'PM2.5',\n                    data: serie25,\n                    marker: { enabled: false }\n                },\n                {\n                    type: 'line',\n                    color: '#0106bf',\n                    name: 'PM10',\n                    data: serie10,\n                    marker: { enabled: false }\n                }\n            ]\n\n        });\n    }\n\n    fetch(requestURL)\n        .then(function (response) {\n            if (!response.ok) {\n                throw new Error('Errore HTTP ' + response.status);\n            }\n            return response.json();\n        })\n        .then(popolaGrafico)\n        .catch(function (errore) {\n            console.error('Errore caricamento ThingSpeak:', errore);\n            mostraErrore('Impossibile caricare i dati da ThingSpeak.');\n        });\n\n})();\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Posizione (+ e &#8212; per modificare lo zoom): PM2.5 istantaneo: PM10 istantaneo: Grafico degli ultimi 4 giorni di registrazione di PM2.5 e PM10 rilevati dalla centralina PMS5003 n.000. Ogni punto mostra il valore della media delle misure fatte nell&#8217;ora precedente (media mobile oraria).<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"give_campaign_id":0,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"footnotes":""},"class_list":["post-4073","page","type-page","status-publish","hentry","post-preview"],"campaignId":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/P5jWVr-13H","_links":{"self":[{"href":"https:\/\/www.benecomunecernusco.it\/wordpress\/wp-json\/wp\/v2\/pages\/4073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.benecomunecernusco.it\/wordpress\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.benecomunecernusco.it\/wordpress\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.benecomunecernusco.it\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.benecomunecernusco.it\/wordpress\/wp-json\/wp\/v2\/comments?post=4073"}],"version-history":[{"count":35,"href":"https:\/\/www.benecomunecernusco.it\/wordpress\/wp-json\/wp\/v2\/pages\/4073\/revisions"}],"predecessor-version":[{"id":5139,"href":"https:\/\/www.benecomunecernusco.it\/wordpress\/wp-json\/wp\/v2\/pages\/4073\/revisions\/5139"}],"wp:attachment":[{"href":"https:\/\/www.benecomunecernusco.it\/wordpress\/wp-json\/wp\/v2\/media?parent=4073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}