Example #1
0
def main():
    print("Raspberry Pi wiringPi DHT11 Temperature test program\n")
    while True:
        result = read_dht11_dat()
        if result:
            humidity, temperature = result
            print("humidity: %s %%,  Temperature: %s C`" %
                  (humidity, temperature))
            LCD.print_lcd(0, 0, 'HUM: ' + str(humidity) + ' %')
            LCD.print_lcd(0, 1, 'TEM: ' + str(temperature) + ' C')
        time.sleep(1)
def main():
    bus.write_byte(address,A3)
    value=bus.read_byte(address)
    #print("AOUT:%1.3f "%(value*3.3/255))
    value=str(value*3.3/255)
    
    LCD.print_lcd(1,1,value[0:5])
    LCD.print_lcd(7,1,"V")
    
    display="t0.txt=\""+value[0:5]+"V\""
    t.write(display)
    end_uart_lcd(t)
    time.sleep(0.1)
Example #3
0
    def run(self, output_fn, **kwargs):
        fd = open(output_fn, 'w')
        if not LCD.init_lcd():
            fd.write("Failed init lcd1602, stoping now.")
            return

        wlan0 = "None"
        eth0 = "None"
        t = 0
        while wlan0 != "None" or eth0 != "None":
            wlan0 = host.get_ip_address("wlan0")
            eth0 = host.get_ip_address("eth0")
            LCD.print_lcd(0, 0, "No network connect")
            LCD.print_lcd(0, 1, "%s times tried" % t)
            t += 0.5
            time.sleep(0.5)
        wlan0 = host.get_ip_address("wlan0")
        LCD.print_lcd(0, 0, "W" + wlan0)
        time.sleep(3)
        rund = 0
        LCD.clear_lcd()
        #d = 0
        #h = 0
        #m = 0
        #s = 0
        while True:
            #s += 1
            #if s%60 == 0:
            #	s = 0
            #	m += 1
            #	if m%60 == 0:
            #		m=0
            #		h += 1
            #		if h%24 == 0:
            #			h=0
            #			d += 1
            LCD.print_lcd(0, 0, wlan0)
            LCD.print_lcd(0, 1, host.get_up_time(
            ))  # "%s %s%s:%s%s:%s%s"%(d, h/10, h%10, m/10, m%10, s/10, s%10))
            time.sleep(1)
        fd.close()
Example #4
0
    # time.sleep(5)


    while True:
        # nowtime = datetime.now().strftime('%b %d %H:%M:%S')
        # mintime = time.strftime('%M',time.localtime(time.time()))
        # print('current time:'+nowtime)
        # LCD.print_lcd(0,0,nowtime)
        # if mintime == 59:
        # LCD.turn_light(1)
        # print('mintime:'+mintime)


        top = run_cmd(uptime)
        ipaddr = run_cmd(ip)

        LCD.print_lcd(0, 0, top[top.find(": ") + 2:].strip(','))
        LCD.print_lcd(0, 1, ipaddr[:ipaddr.find('\n')])

        time.sleep(2.5)

        LCD.clear_lcd()

        cpu_temp = get_cpu_temp()
        gpu_temp = get_gpu_temp()
        mem = get_mem_info()
        LCD.print_lcd(0, 0, cpu_temp)
        LCD.print_lcd(8, 0, gpu_temp)
        LCD.print_lcd(0, 1, mem)
        time.sleep(2.5)
        LCD.clear_lcd()
Example #5
0
#!/user/bin/env python

import smbus
import time
import sys
import LCD1602 as LCD

if __name__ == '__main__':
    LCD.init_lcd()
    LCD.print_lcd(0, 0, 'RaspberryPi IIC')
    LCD.print_lcd(1, 1, 'wait a moment')
    print('wait 3 seconds')
    LCD.turn_light(1)
    time.sleep(3)
    try:
        while True:
            nowtime = time.strftime('%m-%d %H:%M:%S',
                                    time.localtime(time.time()))
            mintime = time.strftime('%M', time.localtime(time.time()))
            print('current time:' + nowtime)
            LCD.print_lcd(1, 1, nowtime)
            if mintime == 59:
                LCD.turn_light(1)
                print('mintime:' + mintime)
            time.sleep(1)
    except KeyboardInterrupt:
        LCD.print_lcd(0, 1, 'Can\'t see anyth')
    print('exit')
Example #6
0
#!/user/bin/env python
import smbus
import time
import sys
import LCD1602 as LCD

if __name__ == '__main__':
    LCD.init_lcd()
    time.sleep(1)
    LCD.print_lcd(2, 0, 'WWW.QUWJ.COM')
    for x in xrange(1, 4):
        LCD.turn_light(0)
        LCD.print_lcd(4, 1, 'LIGHT OFF')
        time.sleep(0.5)
        LCD.turn_light(1)
        LCD.print_lcd(4, 1, 'LIGHT ON ')
        time.sleep(0.5)

    LCD.turn_light(0)

    while True:
        now = time.strftime('%m/%d %H:%M:%S', time.localtime(time.time()))
        LCD.print_lcd(1, 1, now)
        time.sleep(0.2)
def LCD_Init():
    LCD.init_lcd()
    LCD.print_lcd(0,0,'RaspberryPi IIC')
    #LCD.print_lcd(1,1,'wait a moment')
    LCD.turn_light(1)
    time.sleep(1.5)
Example #8
0
#!/user/bin/env python


import smbus
import time
import sys
import LCD1602 as LCD
import logx
import logging

if __name__ == '__main__':
        LCD.init_lcd()
        time.sleep(2)
        LCD.print_lcd(0,0,'Hello DFRobot!')
        LCD.print_lcd(1,1,'local time')
        logging.info('wait 2 seconds')
        LCD.turn_light(1)
        logging.info('turn on Light')
        time.sleep(5)
        while True:
                nowtime = time.strftime('%m-%d %H:%M:%S',time.localtime(time.time()))
                hourtime = time.strftime('%H',time.localtime(time.time()))
                mintime = time.strftime('%M',time.localtime(time.time()))
                sectime = time.strftime('%S',time.localtime(time.time()))
                LCD.print_lcd(1,1,nowtime)
                if mintime == '59':
                        if sectime == '00':
                                LCD.turn_light(1)
                        elif sectime  == '59':
                                LCD.turn_light(0)
                time.sleep(1)
#!/user/bin/env python

import socket
import smbus
import time
import sys
import LCD1602 as LCD


def Get_local_ip():
    try:
        csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        csock.connect(('8.8.8.8', 80))
        (addr, port) = csock.getsockname()
        csock.close()
        return addr
    except socket.error:
        return "127.0.0.1"


if __name__ == '__main__':
    LCD.init_lcd()
    local_IP = Get_local_ip()
    LCD.print_lcd(0, 0, 'RaspberryPi IP')
    LCD.print_lcd(1, 1, local_IP)
    LCD.turn_light(1)
    time.sleep(3)
Example #10
0
#!/user/bin/env python 


import smbus
import time
import sys
import LCD1602 as LCD
import logx
import logging

if __name__ == '__main__':  
	LCD.init_lcd()
	time.sleep(2)
	LCD.print_lcd(0,0,'NUPT bear BLight')
	LCD.print_lcd(1,1,'local time')
	logging.info('wait 2 seconds')
	LCD.turn_light(1)
	logging.info('turn on BLight')
	time.sleep(5)
	while True:
		nowtime = time.strftime('%m-%d %H:%M:%S',time.localtime(time.time()))
		hourtime = time.strftime('%H',time.localtime(time.time()))
		mintime = time.strftime('%M',time.localtime(time.time()))
		sectime = time.strftime('%S',time.localtime(time.time()))
		LCD.print_lcd(1,1,nowtime)
		if mintime == '59':
			if sectime == '00':
				LCD.turn_light(1)
			elif sectime  == '59':
				LCD.turn_light(0)
		time.sleep(1)	
Example #11
0
#!/user/bin/env python 


import smbus
import time
import sys
import LCD1602 as LCD
temp=0


if __name__ == '__main__':
        LCD.init_lcd()
        LCD.print_lcd(0,0,'CPU T:%.2f'%temp)
        LCD.print_lcd(1,1,'wait a moment')
        print('wait 3 seconds')
        LCD.turn_light(1)
        time.sleep(3)
        try:
                while True:
                        file=open("/sys/class/thermal/thermal_zone0/temp")
                        temp=float(file.read())/1000
                        file.close()
                        LCD.print_lcd(0,0,'CPU T:%.2f'%temp)
                        nowtime = time.strftime('%m-%d %H:%M:%S',time.localtime(time.time()))
                        mintime = time.strftime('%M',time.localtime(time.time()))
                        print('current time:'+nowtime)
                        LCD.print_lcd(1,1,nowtime)
                        if mintime == 59:
                                LCD.turn_light(1)
                                print('mintime:'+mintime)	
                        time.sleep(1)
Example #12
0
import LCD1602 as LCD
import time

LCD.init_lcd()
time.sleep(2)
LCD.print_lcd(0, 0, 'start')