CodingGraphsHardwareHighlevel

CPU load & Temperature Datalog chart

FILES TO INCLUDE ….

PROJECT TREE …..

<code>tree
 .
 ├── control.db
 ├── Flask_Data_fetching.py
 ├── log.txt
 ├── readme.txt
 ├── request_InsertCPUTempOnce.py
 ├── request_InsertCPUTemp.py
 └── templates
     ├── CanvasJS-Json-Data-Api-Ajax-Chart - Copy.html
     └── MultiY.html</code>

Read me

TREE:
 │   control.db                  --> Database   :   │ID│RoomID│TemperatureC│Datetime│
 │   Flask_Data_fetching.py      --> Server py  :   in:  ; /graph  │ Out : selectDB->Application/json ; http /text 
 │   request_InsertCPUTemp.py    --> Insert Temperature every 1 minute              : Insert Temp loop
 │   request_InsertCPUTempOnce.py--> Insert the discontinuity of Data each startup  : Insert Null once   
 │
 └───templates
         CanvasJS-Json-Data-Api-Ajax-Chart - Copy.html
 ────────────────────────────────────────────────────────────────────────────────────────────────────────────       
 DataFlow : 
 insert process :
     corn job :
     @reboot sudo python /home/pi/database/request_InsertCPUTempOnce.py >> /home/pi/database/log.txt   # Insert Null once
     * * * * * sudo python /home/pi/database/request_InsertCPUTemp.py   >> /home/pi/database/log.txt   # Insert Temp loop
 Select process :
 jSON :
 in     :  >> server.py : SelectDB[JSON] >> 
 Return : Application/json
 /graph :
 in     : /graph  >> server.py >> templates/.html : Ajax(server.py, fct(jsonData){Chart})
 Return : Application/text 
 ────────────────────────────────────────────────────────────────────────────────────────────────────────────
 DATABASE: 
 pi@rasNab:~/database $ sqlite3 control.db
 SQLite version 3.16.2 2017-01-06 16:32:41
 Enter ".help" for usage hints.
 sqlite> select * From RoomDetails ;
 1|Library
 sqlite> select * From Temperature ;
 1|1|222.0|2019-05-19 12:55:38
 2|1|222.0|2019-05-24 13:46:47       //   ID │ RoomID │TemperatureC│ Datetime
                                     //    3 │    1   │     51.5   │2019-05-24 14:17:55
 4|1|51.5|2019-05-24 14:18:05
 5|1|51.5|2019-05-24 14:18:09
 6|1|51.5|2019-05-24 14:18:14
 7|1|51.0|2019-05-31 09:39:51
 8|1|49.4|2019-06-05 06:37:08
 sqlite> .quit
   CREATE TABLE Temperature (ID INTEGER PRIMARY KEY AUTOINCREMENT,
   RoomID INTEGER, TemperatureC FLOAT(8), Datetime DATETIME, FOREIGN KEY(RoomID) REFERENCES RoomDetails(ID))
   CREATE TABLE RoomDetails (ID INTEGER PRIMARY KEY AUTOINCREMENT,
   Room VARCHAR(25)) 
 ────────────────────────────────────────────────────────────────────────────────────────────────────────────
 $ sqlite3 control.db
 sqlite> .tables
 RoomDetails  Temperature
 sqlite> .schema
 CREATE TABLE RoomDetails (ID INTEGER PRIMARY KEY AUTOINCREMENT,
 Room VARCHAR(25));
 CREATE TABLE Temperature (ID INTEGER PRIMARY KEY AUTOINCREMENT,
 RoomID INTEGER, TemperatureC FLOAT(8), Datetime DATETIME, FOREIGN KEY(RoomID) REFERENCES RoomDetails(ID));

Code Source :

0 thoughts on “CPU load & Temperature Datalog chart

Leave a Reply

Your email address will not be published. Required fields are marked *