Skip to content

jonathanrichardl/micropython-GY85

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Written By Jonathan Richard

Department Of Electrical Engineering, UI

micropython-GY85

Complete library for GY-85 compatible with all micropython board. Supports reading from ADXl345, HMC5883L, and ITG3200 in the GY85 board or its own standalone board. Examples are tested in Raspberry Pi Pico.

Features

  1. Selectable modes from Acceleration reading only, Gyroscope and Temperature reading only, Magnetometer reading only, or configurable multiple reading modes.
  2. Standard Micropython syntax, no special library used.
  3. Feature to detect counterfeit GY-85 (from my personal experience writing this library)
  4. Acceleration values in G
  5. Roll and Pitch Calculation
  6. Gyro values in °/s
  7. Temperature values in °C

Usage

from GY85 import GY85
import machine
import utime
sclPin = 1
sdaPin = 0
i2cid = 0
gy85 = GY85(scl = sclPin, sda = sdaPin, i2cid = i2cid, magnet = True, gyro = True) # enable all measurements
try:
    while True:
        buffer = gy85.read_acc()
        print("Acceleration Value x = " + str(buffer[0])+", y = " + str(buffer[1])+", z = " + str(buffer[2]))
        buffer = gy85.calculate_rp()
        print("Roll Value = " + str(buffer[0])+", Pitch Value = " + str(buffer[1]))
        buffer = gy85.read_gyro()
        print("Temperature : " + str(buffer[0]))
        print("Gyroscope Value x = " + str(buffer[1])+", y = " + str(buffer[2])+", z = " + str(buffer[3]))
        try:
            buffer = gy85.read_magnet()
            print("Magnet Value x = " + str(buffer[0])+", y = " + str(buffer[1])+", z = " + str(buffer[2]))
        except:
            pass
        utime.sleep(1)
except KeyboardInterrupt:
    acc.deinit()
        

Output:

Magnet Value x = 0.xxxx, y = 0.xxxx, z = -1.xxxx
Acceleration Value x = 0.0234, y = 0.0468, z = -1.0764
Roll Value = -2.489737, Pitch Value = -1.244281
Temperature : 34.73214
Gyroscope Value x = -0.6956522, y = -2.086957, z = 0.973913

About

Complete library for GY-85 compatible with all micropython board

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages