def read(): rfid = RFID() tag_id, tag_text = rfid.read_no_block() return { 'id': str(tag_id), 'text': tag_text.strip() if tag_text else tag_text }
def get_ip_address(): ip_address = '' s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("8.8.8.8", 80)) ip_address = s.getsockname()[0] s.close() return ip_address rfid = RFID() host_ip = get_ip_address() while True: tag_id, tag_text = rfid.read_no_block() print(tag_id) lcd.clear() if tag_id is None: lcd.write(host_ip) led.value = False else: lcd.write(tag_text) if tag_id == 989699569615: led.value = True GPIO.cleanup()