import machine
import time
import ustruct
from MPU6050 import MPU6050
import dht
# Initialize MPU6050 sensor
i2c = machine.I2C(0, scl=machine.Pin(9), sda=machine.Pin(8))
accelerometer = MPU6050(i2c)
# Initialize DHT22 sensor
dht_pin = machine.Pin(2, machine.Pin.IN, machine.Pin.PULL_UP)
dht_sensor = dht.DHT22(dht_pin)
while True:
# Read data from MPU6050
acceleration_data = accelerometer.get_accel_data()
gyroscope_data = accelerometer.get_gyro_data()
print("Accelerometer data (x, y, z):", acceleration_data)
print("Gyroscope data (x, y, z):", gyroscope_data)
# Read data from DHT22
dht_sensor.measure()
temperature = dht_sensor.temperature()
humidity = dht_sensor.humidity()
print("Temperature:", temperature, "°C")
print("Humidity:", humidity, "%")
# Wait for 1 second before reading again
time.sleep(1)