Categories
Uncategorized

How to make MMA8451 working with raspberry pi over I2C

MMA88451 doesn’t work with raspbterry pi out of the box. It needs I2C with repeated start. Test program in python:

import smbus
DEVICE_ADDRESS = 0x1d
MMA8451_REG_WHOAMI = 0x0D
bus = smbus.SMBus(1)
ret = bus.read_byte_data(DEVICE_ADDRESS, MMA8451_REG_WHOAMI)
print ret

Shows zero instead of expected 26 (0x1A in hex)

pi@occberry ~/OpenCyclingComputer $ sudo python src/mma8451.py
0

Solution that I found here solves the problem:

sudo chmod 666 /sys/module/i2c_bcm2708/parameters/combined
sudo echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined

and now the python test code shows, as expected:
pi@occberry ~/OpenCyclingComputer $ sudo python src/mma8451.py
26

[1] www.adafruit.com/products/2019

[2] www.raspberrypi.org/forums/viewtopic.php?f=44&t=15840&start=25

Categories
Uncategorized

Python library for Raspberry PI for Ultimate GPS based on MTK3339 with serial interface as sold by Adafruit

https://gitlab.com/PrzemoF/mtk3339

Python library for Raspberry PI for Ultimate GPS based on MTK3339 with serial interface as sold by Adafruit. The library helps to set different chip parameters in a sane way. Currently supports minimum functional set of commands:

CMD_HOT_START – hot_start()

CMD_WARM_START – warm_start()

CMD_COLD_START – cold_start()

CMD_FULL_COLD_START – cold_reset()

SET_NMEA_UPDATERATE – set_nmea_update_rate()

SET_NMEA_BAUDRATE – set_baudrate()

API_SET_FIX_CTL – set_fix_update_rate()

API_SET_NMEA_OUTPUT – set_nmea_output()

SET_NAV_SPEED_TRESHOLD – set_nav_speed_threshold()

All functions are preforming basic range check to make sure values are accepted by MTK3339 as there is no check if a call was successful or not.

Example usage:

import mkt3339

gps = mt3339(“/dev/ttyAMA0”)

gps.set_fix_update_rate(800)

gps.set_nmea_update_rate(800)

gps.set_baudrate(115200)

gps.set_nmea_update_rate(1000)

gps.set_nav_speed_threshold(1.5)

gps.set_nmea_output(gll = 0, rmc = 1, vtg = 0, gga = 5, gsa = 5, gsv = 5)

That library is part of Open Cycling Computer project