Esempio n. 1
0
def main():
	while True:
		GPIO.setmode(GPIO.BCM)
		GPIO.setup(DISPLAY_E, GPIO.OUT)
		GPIO.setup(DISPLAY_RS, GPIO.OUT)
		GPIO.setup(DISPLAY_DATA4, GPIO.OUT)
		GPIO.setup(DISPLAY_DATA5, GPIO.OUT)
		GPIO.setup(DISPLAY_DATA6, GPIO.OUT)	
		GPIO.setup(DISPLAY_DATA7, GPIO.OUT)
		GPIO.setup(CLK, GPIO.OUT)
		GPIO.setup(DIN, GPIO.OUT)
		GPIO.setup(DOUT, GPIO.IN)
		GPIO.setup(CS, GPIO.OUT)

		wert = MCP3008.getAnalogData(adCh, CLK, DIN, DOUT, CS)/float(310)
		ref = 15/float(3.3)
		wert12v = wert * ref
		wertg = round(wert12v, 3)

		display_init()

		rx_bytes, tx_bytes = get_network_bytes('eth0')
		rx1_bytes, tx1_bytes = get_network_bytes('wlan0')
	
		lcd_byte(DISPLAY_LINE_1, DISPLAY_CMD)
		lcd_string('Home - '+get_up_stats()[0])
	
		lcd_byte(DISPLAY_LINE_2, DISPLAY_CMD)
		lcd_string('Free: '+str(get_ram()[1])+'/'+str(get_ram()[0])+'MB')
		time.sleep(5)

		lcd_byte(DISPLAY_LINE_1, DISPLAY_CMD)
		lcd_string('C: '+str(get_temperature())+chr(223)+'C '+str(get_cpu_speed()[:3])+'MHz')

		lcd_byte(DISPLAY_LINE_2, DISPLAY_CMD)
		#lcd_string('Ld: '+str(os.getloadavg()[:2]))
		lcd_string(str(wertg) + " Volt")

		time.sleep(5)
	
		lcd_byte(DISPLAY_LINE_1, DISPLAY_CMD)
		lcd_string('Eth0 send/rec.')

		lcd_byte(DISPLAY_LINE_2, DISPLAY_CMD)
		lcd_string(str(rx_bytes)+'/'+str(tx_bytes)+' MB')

		time.sleep(5)

		lcd_byte(DISPLAY_LINE_1, DISPLAY_CMD)
		lcd_string('WLAN0 send/rec.')

		lcd_byte(DISPLAY_LINE_2, DISPLAY_CMD)
		lcd_string(str(rx1_bytes)+'/'+str(tx1_bytes)+' MB')
		time.sleep(5)
Esempio n. 2
0
import time
import MCP3008
import RPi.GPIO as GPIO

adCh = 0
CLK = 11
DIN = 9
DOUT = 10
CS = 7
TRESHOLD = 3



GPIO.setup(CLK, GPIO.OUT)
GPIO.setup(DIN, GPIO.OUT)
GPIO.setup(DOUT, GPIO.IN)
GPIO.setup(CS, GPIO.OUT)





while True:

	wert = MCP3008.getAnalogData(adCh, CLK, DIN, DOUT, CS)/float(310)
	#float(310) = 1023/310 = 3.3
	ref = 15/float(3.3)
	wert12v = wert * ref
	wertg = round(wert12v, 2)
	print str(wertg)