Browse Source

Initial commit l0l

Wazakindjes 1 year ago
commit
ac20ac4748
2 changed files with 81 additions and 0 deletions
  1. 38 0
      .gitignore
  2. 43 0
      temps.py

+ 38 - 0
.gitignore

@@ -0,0 +1,38 @@
+.DS_Store
+._.*
+$RECYCLE.BIN
+.*.swp
+*-bak*
+*.ini
+/ssl
+
+/app/release
+/app/src/.idea/assetWizardSettings.xml
+/app/src/.idea/caches
+/app/src/.idea/gradle.xml
+/app/src/.idea/libraries
+/app/src/.idea/modules.xml
+/app/src/.idea/workspace.xml
+
+.gradle/
+build/
+*.class
+*.dex
+local.properties
+proguard/
+*.log
+.navigation/
+captures/
+*.iml
+/app/src/.idea/tasks.xml
+/app/src/.idea/dictionaries
+.externalNativeBuild
+google-services.json
+freeline.py
+freeline/
+freeline_project_description.json
+fastlane/report.xml
+fastlane/Preview.html
+fastlane/screenshots
+fastlane/test_output
+fastlane/readme.md

+ 43 - 0
temps.py

@@ -0,0 +1,43 @@
+#!/usr/bin/python
+import MySQLdb
+import time
+#import sys
+
+sensorids = ["28-02155265b0ff"]
+avgtemperatures = []
+
+try:
+	#print 'Connecting.'
+	#sys.stdout.flush()
+	db = MySQLdb.connect(host='topkeks',
+						 port=3306,
+						 user='topkeks',
+						 passwd='topkeks',
+						 db='topkeks',
+						 ssl={'cipher': 'AES256-SHA'})
+	cur = db.cursor()
+	#print 'Connected.'
+	#sys.stdout.flush()
+	
+	for sensor in range(len(sensorids)):
+		temperatures = []
+		for i in range(0,5):
+				text = '';
+				while text.split("\n")[0].find("YES") == -1:
+						tfile = open("/sys/bus/w1/devices/"+ sensorids[sensor] +"/w1_slave")
+						text = tfile.read()
+						tfile.close()
+						time.sleep(1)
+						
+				secondline = text.split("\n")[1]
+				temperaturedata = secondline.split(" ")[9]
+				temperature = float(temperaturedata[2:])
+				temperatures.append(temperature / 1000)
+				
+		avgtemperatures.append(sum(temperatures) / float(len(temperatures)))
+
+	cur.execute("INSERT INTO `topkeks` (temp) VALUES ({0})".format(avgtemperatures[0]))
+	db.commit()
+	
+except KeyboardInterrupt:
+	print '\nCTRL + C'