daily_automated

This commit is contained in:
paolo.iocco
2023-03-13 09:05:51 +00:00
parent ab2532ebf2
commit 4da858fb92
515 changed files with 226616 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
#HEADERS = main.h headers.h
default: main
all: main
main.o: main.c $(HEADERS)
gcc -c main.c -o main.o
main: main.o
gcc main.o -o main
clean:
-rm -f main.o
-rm -f main

View File

@@ -0,0 +1 @@
var array = [[0.00,0.16],[0.13,16.80],[0.25,36.52],[0.38,25.45],[0.50,3.36],[0.63,28.62],[0.75,36.60],[0.88,19.36],[1.00,17.12],[1.13,27.23],[1.25,2.09],[1.38,35.81],[1.50,38.10],[1.63,5.89],[1.75,23.59],[1.88,12.05],[2.00,7.55],[2.13,21.85],[2.25,26.23],[2.38,21.99],[2.50,15.78],[2.63,8.06],[2.75,19.64],[2.88,31.38],[3.00,1.66],[3.13,19.60],[3.25,3.57],[3.38,5.87],[3.50,33.43],[3.63,16.16],[3.75,25.56],[3.88,3.17],[4.00,37.18],[4.13,21.76],[4.25,26.65],[4.38,20.66],[4.50,19.09],[4.63,3.02],[4.75,11.71],[4.88,29.60],[5.00,7.71],[5.13,27.15],[5.25,20.40],[5.38,7.26],[5.50,2.66],[5.63,0.98],[5.75,35.04],[5.88,38.17],[6.00,35.90],[6.13,32.27],[6.25,21.75],[6.38,15.74],[6.50,31.68],[6.63,34.50],[6.75,1.06],[6.88,15.58],[7.00,11.82],[7.13,16.45],[7.25,24.10],[7.38,31.66],[7.50,12.07],[7.63,37.82],[7.75,30.93],[7.88,26.63],[8.00,16.22],[8.13,32.03],[8.25,26.87],[8.38,27.53],[8.50,33.94],[8.63,37.64],[8.75,33.47],[8.88,18.15],[9.00,28.77],[9.13,39.47],[9.25,10.03],[9.38,39.23],[9.50,22.37],[9.63,0.76],[9.75,2.19],[9.88,7.88],[10.00,1.39],[10.13,7.57],[10.25,33.64],[10.38,27.34],[10.50,33.18],[10.63,26.74],[10.75,37.34],[10.88,18.40],[11.00,16.51],[11.13,38.56],[11.25,22.38],[11.38,3.66],[11.50,33.72],[11.63,5.54],[11.75,12.89],[11.88,36.02],[12.00,10.35],[12.13,38.32],[12.25,35.05],[12.38,22.50],[12.50,8.67],[12.63,20.21],[12.75,8.62],[12.88,34.70],[13.00,21.22],[13.13,11.47],[13.25,19.15],[13.38,37.17],[13.50,30.76],[13.63,14.53],[13.75,27.13],[13.88,24.93],[14.00,2.75],[14.13,21.59],[14.25,10.39],[14.38,21.34],[14.50,16.64],[14.63,5.64],[14.75,35.87],[14.88,7.66],[15.00,2.26],[15.13,16.33],[15.25,17.20],[15.38,35.47],[15.50,7.57],[15.63,1.75],[15.75,14.14],[15.88,33.23],[16.00,23.94],[16.13,37.59],[16.25,30.29],[16.38,38.22],[16.50,15.27],[16.63,24.73],[16.75,5.19],[16.88,5.19],[17.00,17.21],[17.13,16.66],[17.25,37.19],[17.38,2.82],[17.50,32.67],[17.63,37.85],[17.75,13.19],[17.88,29.32],[18.00,29.96],[18.13,34.41],[18.25,1.72],[18.38,18.52],[18.50,9.69],[18.63,18.34],[18.75,25.30],[18.88,27.45],[19.00,6.84],[19.13,6.40],[19.25,8.61],[19.38,16.96],[19.50,34.05],[19.63,15.13],[19.75,38.65],[19.88,16.38],[20.00,32.57],[20.13,33.06],[20.25,12.96],[20.38,3.61],[20.50,37.00],[20.63,31.45],[20.75,12.45],[20.88,11.84],[21.00,20.15],[21.13,14.84],[21.25,34.81],[21.38,34.16],[21.50,24.15],[21.63,12.52],[21.75,24.95],[21.88,37.33],[22.00,4.22],[22.13,12.39],[22.25,38.63],[22.38,15.91],[22.50,31.22],[22.63,18.20],[22.75,35.51],[22.88,38.07],[23.00,39.30],[23.13,31.68],[23.25,17.92],[23.38,14.21],[23.50,4.85],[23.63,20.61],[23.75,11.61],[23.88,19.87]]

View File

@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<script src="data.html"></script>
<title>Termometro digitale</title>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="width:800px; height:400px;"></div>
<script>
document.addEventListener('DOMContentLoaded', function () {
var myChart = Highcharts.chart('container', {
chart: {
type: 'line'
},
title: {
text: 'Super termometrone by Paolo'
},
xAxis: {
min: 1,
max: 24,
tickAmount: 7,
title: {
text: 'Orario'
}
},
yAxis: {
min: 0,
max: 40,
title: {
text: 'Temperatura'
}
},
series: [{
name: 'Temperatura',
data: array
}]
});
});
</script>
</head>
<body>
<p style='text-align: left; font-family:arial'><span style='color: #0082ff;'>Temperatura attuale =
28.2
°C</p>
</body>
</html>

View File

@@ -0,0 +1,39 @@
<title>Termometro digitale</title>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="width:800px; height:400px;"></div>
<script>
document.addEventListener('DOMContentLoaded', function () {
var myChart = Highcharts.chart('container', {
chart: {
type: 'line'
},
title: {
text: 'Super termometrone by Paolo'
},
xAxis: {
min: 1,
max: 24,
tickAmount: 7,
title: {
text: 'Orario'
}
},
yAxis: {
min: 0,
max: 40,
title: {
text: 'Temperatura'
}
},
series: [{
name: 'Temperatura',
data: array
}]
});
});
</script>
</head>
<body>
<p style='text-align: left; font-family:arial'><span style='color: #0082ff;'>Temperatura attuale =

View File

@@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
#define MAX_SAMPLES 192
#define MAX_TEMP 40
float array_t[MAX_SAMPLES];
int i=0;
void main(void){
for (i=0;i<MAX_SAMPLES; i++) {array_t[i]=0;}
srand(28);
for (i=0;i<MAX_SAMPLES; i++) {
array_t[i]=(float)rand()/(float)(RAND_MAX)*MAX_TEMP;
printf("[%2.2f,%2.2f] \n", (float)(i)/(float)(MAX_SAMPLES/24), array_t[i]);
}
FILE *fptr = fopen("data.html", "w");
fprintf(fptr,"var array = [");
for (i=0;i<MAX_SAMPLES; i++) {
fprintf(fptr,"[%2.2f,%2.2f]", (float)(i)/(float)(MAX_SAMPLES/24), array_t[i]);
if (i<(MAX_SAMPLES-1)){
fprintf(fptr,",");
}
}
fprintf(fptr,"]");
fclose(fptr);
}

View File

@@ -0,0 +1 @@
https://api.highcharts.com/highcharts/series.line.name

View File

@@ -0,0 +1 @@
var array = [[0.00,0.16],[0.25,16.80],[0.50,36.52],[0.75,25.45],[1.00,3.36],[1.25,28.62],[1.50,36.60],[1.75,19.36],[2.00,17.12],[2.25,27.23],[2.50,2.09],[2.75,35.81],[3.00,38.10],[3.25,5.89],[3.50,23.59],[3.75,12.05],[4.00,7.55],[4.25,21.85],[4.50,26.23],[4.75,21.99],[5.00,15.78],[5.25,8.06],[5.50,19.64],[5.75,31.38],[6.00,1.66],[6.25,19.60],[6.50,3.57],[6.75,5.87],[7.00,33.43],[7.25,16.16],[7.50,25.56],[7.75,3.17],[8.00,37.18],[8.25,21.76],[8.50,26.65],[8.75,20.66],[9.00,19.09],[9.25,3.02],[9.50,11.71],[9.75,29.60],[10.00,7.71],[10.25,27.15],[10.50,20.40],[10.75,7.26],[11.00,2.66],[11.25,0.98],[11.50,35.04],[11.75,38.17],[12.00,35.90],[12.25,32.27],[12.50,21.75],[12.75,15.74],[13.00,31.68],[13.25,34.50],[13.50,1.06],[13.75,15.58],[14.00,11.82],[14.25,16.45],[14.50,24.10],[14.75,31.66],[15.00,12.07],[15.25,37.82],[15.50,30.93],[15.75,26.63],[16.00,16.22],[16.25,32.03],[16.50,26.87],[16.75,27.53],[17.00,33.94],[17.25,37.64],[17.50,33.47],[17.75,18.15],[18.00,28.77],[18.25,39.47],[18.50,10.03],[18.75,39.23],[19.00,22.37],[19.25,0.76],[19.50,2.19],[19.75,7.88],[20.00,1.39],[20.25,7.57],[20.50,33.64],[20.75,27.34],[21.00,33.18],[21.25,26.74],[21.50,37.34],[21.75,18.40],[22.00,16.51],[22.25,38.56],[22.50,22.38],[22.75,3.66],[23.00,33.72],[23.25,5.54],[23.50,12.89],[23.75,36.02]]

View File

@@ -0,0 +1,123 @@
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
* WiFi Thermometer *
* (C)05.12.2019 Paolo Iocco *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
*
* LM335K temperature sensor on A0
* 330Ohm Pull up resistor
* 10k trimmer compensation
*
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
#include <ESP8266WiFi.h>
#include <Ticker.h>
#include "FS.h"
#define DAY_SECONDS 86400
#define MAX_SAMPLES 192
float kelvin = 0, celsius = 0;
int i = 0, int j = 0;
float array_t[MAX_SAMPLES];
char buffer [(MAX_SAMPLES * 16)];
const unsigned long periodo= (DAY_SECONDS / MAX_SAMPLES);
const char* ssid = "OnDe";
const char* password = "44444444444444444444444444";
WiFiServer server(80);
WiFiClient client;
File file;
Ticker blinker;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
void digitalClockDisplay() {
time_t tnow = time(nullptr);
Serial.println(ctime(&tnow));
}
void setup() {
// Pins and variables initialize
pinMode(A0, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
for (i=0;i<MAX_SAMPLES; i++) {array_t[i]=0;}
// Mount filesystem
Serial.begin(57600);
if(!SPIFFS.begin()){
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
Serial.println("\nFilesystem mounted");
// WiFi Connect
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("\nWiFi is connected");
// NTP Synchronize
configTime(0, 0, "0.se.pool.ntp.org");
setenv("TZ", "UTC+7", 1);
tzset();
digitalClockDisplay();
server.begin();
Serial.println("Server started");
Serial.println(WiFi.localIP());
// Set Ticker
blinker.attach(periodo, Memorizza);
}
void Memorizza() {
j=(j+1) % MAX_SAMPLES;
array_t[j]=celsius;
digitalWrite(LED_BUILTIN, LOW);
delay(10);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop() {
// Temperature read (analog)
kelvin = (3.3 * analogRead(A0) / 1024)*100;
celsius= kelvin - 273.15;
Serial.print(celsius);
Serial.println(" °C");
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *
* Compose and output Web-Page *
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
client = server.available();
file = SPIFFS.open("/index.html", "r");
if(!file) {
Serial.println("Failed to open file for reading");
return;
}
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println("Refresh: 60");
client.println();
client.println("<!DOCTYPE html>");
client.println("<html>");
client.println("<head>");
// Output temperature vector array
client.print("<script> var array = [");
for (i=0;i<MAX_SAMPLES; i++) {
sprintf(buffer,"[%2.2f,%2.2f]", (float)(i)/(float)(MAX_SAMPLES/24), array_t[i]);
client.print(buffer);
if (i<(MAX_SAMPLES-1)){
client.print(",");
}
}
client.println("] </script>");
// Output HTML page and JavaScript
while(file.available()){
client.write(file.read());
}
file.close();
// Ourput HTML-END
client.println(celsius);
client.print("*C</p>");
client.println("</body>");
client.println("</html>");
}