diff --git a/html/index.html b/html/index.html new file mode 100644 index 0000000..62f27cd --- /dev/null +++ b/html/index.html @@ -0,0 +1,11 @@ + + + + + Temperature chez les Moumou + + + +

Will est cool

+ + diff --git a/js/main.js b/js/main.js new file mode 100644 index 0000000..65e53a3 --- /dev/null +++ b/js/main.js @@ -0,0 +1,4 @@ +console.log(6*3); +console.log(6/3); +console.log(6+3); +console.log(6-3); diff --git a/piTherm.py b/piTherm.py new file mode 100755 index 0000000..d26990f --- /dev/null +++ b/piTherm.py @@ -0,0 +1,43 @@ +import os +import glob +import time +import sqlite3 + +# Module to load +os.system('sudo modprobe w1-gpio') +os.system('sudo modprobe w1-therm') + +# Min to pause +m = 10 + +# Start DB connection +conn = sqlite3.connect('temperatures.db') +c = conn.cursor() + +# Getting the device file +w1_dir = '/sys/bus/w1/devices/' +thermFile = glob.glob(w1_dir + '28*')[0] + '/w1_slave' + +# extract the temperature value +while True: + with open(thermFile) as f: + line = f.readlines() + accept = line[0].split(' ')[-1] + if (accept[0:3] == 'YES'): + # get the value + tp = line[1].split(' ')[-1] + d = str(float(tp[2:7])/1000.0) + + # write in the table + querry = 'INSERT INTO RECORDS VALUES (current_timestamp,' + querry += str(d) + querry += ',\'D1\');' + print(querry) + c.execute(querry) + # Save (commit) the changes on the DB + conn.commit() + time.sleep(60*m) + + +# We close the connection if we are done with it. +conn.close() diff --git a/temperatures.db b/temperatures.db new file mode 100644 index 0000000..29f560a Binary files /dev/null and b/temperatures.db differ