This commit is contained in:
LazyAssassin445
2017-03-01 12:26:48 +00:00
parent 1906df6fff
commit adb240122c
4 changed files with 43 additions and 0 deletions

Binary file not shown.

26
fetchprogram Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/python3
import os, sys
lib_path = os.path.abspath(os.path.join('..', 'modules'))
sys.path.append(lib_path)
import hdc1000
import weight
hdc1000.init()
while True:
sleep(60)
try:
temp = hdc.temperature()
except:
pass
try:
humid = hdc.humidity()
except:
pass
try:
weight = weight.readchannel(7)
except:
pass
hdc1000.done()

0
testprograms/spitest → modules/weight Executable file → Normal file
View File

17
testprograms/weighttest Executable file
View File

@@ -0,0 +1,17 @@
#!/usr/bin/python
import spidev
import time
import os
spi = spidev.SpiDev()
spi.open(0, 0)
def readchannel(channel):
adc = spi.xfer2([1, (8+channel)<<4, 0])
data = ((adc[1]&3)<<8) + adc[2]
return data
while True:
print(readchannel(7))
time.sleep(.5)