Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Mar 30, 2017
0 parents commit 43e3295
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
11 changes: 11 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Temperature chez les Moumou</title>
</head>
<body>
<script src="../js/main.js"></script>
<h1>Will est cool</h1>
</body>
</html>
4 changes: 4 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
console.log(6*3);
console.log(6/3);
console.log(6+3);
console.log(6-3);
43 changes: 43 additions & 0 deletions piTherm.py
Original file line number Diff line number Diff line change
@@ -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()
Binary file added temperatures.db
Binary file not shown.

0 comments on commit 43e3295

Please sign in to comment.