-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (60 loc) · 2.46 KB
/
main.py
File metadata and controls
66 lines (60 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# INFO: STARTING THE RPPI PICO UART PINS
from machine import UART, Pin
from time import sleep
uart = UART(0,baudrate=9600,tx=Pin(12),rx=Pin(13))
sleep(0.5)
# INFO: START THE TELEMETRY
from telemetry import *
while True:
# BMP180 Values
pressure_bmp180 = bmp180.pressure/100
temperature_bmp180 = bmp180.temperature
altitude_bmp180 = bmp180.altitude
# BME280 Values
temperature_bme280raw, pressure_bme280raw, humidity_bme280raw = bme280.read_compensated_data()
temperature_bme280 = temperature_bme280raw/100
pressure_bme280 = pressure_bme280raw / (256*100) # hPa around 823.5 hpa in Silao Gto
humidity_bme280 = humidity_bme280raw/1000 # aprox 53.4% of humidity in Silao Gto
altitude_bme280 = bme280.altitude
# MPU9250 Values
temperature_mpu9250 = mpu9250.temperature
acceleration_mpu9250 = mpu9250.acceleration
gyro_mpu9250 = mpu9250.gyro
magnetic_mpu9250 = mpu9250.magnetic
print("###Temperature###")
print(f"{temperature_bmp180:.2f},{temperature_bme280:.2f},{temperature_mpu9250:.2f}")
print("###Pressure###")
print(f"{pressure_bmp180:.2f},{pressure_bme280:.2f}")
print("###Altitude###")
print(f"{altitude_bmp180:.2f},{altitude_bme280:.2f}")
print("###Humidity###")
print(f"{humidity_bme280:.2f}")
print("###Acceleration###")
print(f"{acceleration_mpu9250[0]:.6f},{acceleration_mpu9250[1]:.6f},{acceleration_mpu9250[2]:.6f}")
print("###Gyroscope###")
print(f"{gyro_mpu9250[0]:.6f},{gyro_mpu9250[1]:.6f},{gyro_mpu9250[2]:.6f}")
print("###Magnetic###")
print(f"{magnetic_mpu9250[0]:.3f},{magnetic_mpu9250[1]:.3f},{magnetic_mpu9250[2]:.3f}")
print("><")
uart.write("###Temperature###\n")
uart.write(f"{temperature_bmp180},{temperature_bme280},{temperature_mpu9250}\n")
uart.write("###Pressure###\n")
uart.write(f"{pressure_bmp180},{pressure_bme280}\n")
uart.write("###Altitude###\n")
uart.write(f"{altitude_bmp180},{altitude_bme280}\n")
uart.write("###Humidity###\n")
uart.write(f"{humidity_bme280}\n")
uart.write("###Acceleration###\n")
uart.write(f"{acceleration_mpu9250}\n")
uart.write("###Gyroscope###\n")
uart.write(f"{gyro_mpu9250}\n")
uart.write("###Magnetic###\n")
uart.write(f"{magnetic_mpu9250}\n")
uart.write("><\n")
sleep_ms(400)
# Pin 12 and pin 13 are initialized to be UART
# LED BLINKS TO SAY ITS STARTED OR RESTARTED
# led = machine.Pin(25,machine.Pin.OUT)
# for i in range(4):
# led.toggle()
# sleep(0.1)