Exemplo n.º 1
0
def main():

	#Inicialización de los módulos
	radio.init()
	sensor.init()
#	gps.init()

	while True:
		#Graba los datos a la microSD
		sensor.writeLogLine()
#		gps.writeLogLine()

		#Envía los datos por radio
		packet = bytes(sensor.line(), "utf-8")

			#Paquetiza la información para que no supere el tamaño de 60
		while len(packet) > 60:
			radio.rfm69.send(packet[:60])
			packet = packet[60:]

		if len(packet) > 0:
			radio.rfm69.send(packet)

		time.sleep(0.5)

	radio.close()
	sensor.close()
Exemplo n.º 2
0
def main():
    radio.init()
    sensor.init()

    while True:
        sensor.writeLogLine()
        packet = bytes(sensor.line(), "utf-8")
        radio.rfm69.send(packet)
        time.sleep(0.5)

    radio.close()
    sensor.close()
Exemplo n.º 3
0
def main():
    radio.init()
    i = 0

    sensorLog = open('dataTARS.txt', 'at')
    gpsLog = open('gpsData.txt', 'a')

    while True:
        packet = radio.rfm69.receive(timeout=2)

        if packet is None:
            print("No packet")
            radio.display.fill(0)
            radio.display.text('No packet', 25, 15, 1)
            radio.display.show()
        else:
            dataLine = packet.decode()

            fields = dataLine.split(' ')

            for x in fields:
                if x[:5] == '16204':
                    gpsLog.flush()
                    sensorLog.write(x + " ")
                    i += 1

                elif i > 0:
                    if i == 4:
                        sensorLog.write(x + "\n")
                        sensorLog.flush()
                        i = 0
                    else:
                        sensorLog.write(x + " ")
                        i += 1
                else:
                    gpsLog.write(x + "\n")
            '''


			radio.display.fill(0)
			radio.display.text('%0.2f  P:%0.1f hPa' % (float(fields[0]), float(fields[3])), 2, 2, 1)
			radio.display.text('T:%0.1f C  Hum:%0.2f%%' % (float(fields[1]), float(fields[2])), 2, 13, 1)
			radio.display.text('Alt:%0.2fm' % (float(fields[4])), 2, 25, 1)
			radio.display.show()
			'''

    radio.close()
    sensorLog.close()
    gpsLog.close()
Exemplo n.º 4
0
def main():
	radio.init()

	outputLog = open('dataTARS.txt', 'a')


	while True:
		packet = radio.rfm69.receive(timeout = 2)

		if packet is None:
			radio.display.fill(0)
			radio.display.text('No packet', 25, 15, 1)
			radio.display.show()
		else:
			dataLine = packet.decode()

			outputLog.write(dataLine)
			outputLog.flush()

			fields = dataLine.split (' ')

#			timeStamp = float(fields[0])
			temperature = float(fields[0])
			humedad = float(fields[1])
			presion = float(fields[2])
			altitud = float(fields[3])

#			outputLog.write("xxx %f %f %f %f %f\n" % (timeStamp, temperature, humedad, presion, altitud))
#			print("\nTime: %0.2f s" % (timeStamp - startTime))
			print("Temperature: %0.1f C" % temperature)
			print("Humedad: %0.1f %%" % humedad)
			print("Presión: %0.1f hPa" % presion)
			print("Altitud: %0.2f meters" % altitud)

			radio.display.fill(0)
#			radio.display.text('%0.2f  P:%0.1f hPa' % (timeStamp - startTime, presion), 2, 2, 1)
			radio.display.text('T:%0.1f C  Hum:%0.2f%%' % (temperature, humedad), 2, 13, 1)
			radio.display.text('Alt:%0.2fm' % (altitud), 2, 25, 1)
			radio.display.show()


	radio.close()
	outputLog.close()
Exemplo n.º 5
0
                        sensorLog.flush()
                        i = 0
                    else:
                        sensorLog.write(x + " ")
                        i += 1
                else:
                    gpsLog.write(x + "\n")
            '''


			radio.display.fill(0)
			radio.display.text('%0.2f  P:%0.1f hPa' % (float(fields[0]), float(fields[3])), 2, 2, 1)
			radio.display.text('T:%0.1f C  Hum:%0.2f%%' % (float(fields[1]), float(fields[2])), 2, 13, 1)
			radio.display.text('Alt:%0.2fm' % (float(fields[4])), 2, 25, 1)
			radio.display.show()
			'''

    radio.close()
    sensorLog.close()
    gpsLog.close()


try:
    main()

except KeyboardInterrupt:
    radio.close()
    sensorLog.close()
    gpsLog.close()
    print("Out")