Rich_Morin
I have a pair of BerryGPS-IMUv3 (10 DOF + GPS) HATs which I want to use with a pair of Raspberry Pi 3B+ and 4B computers, using Raspbian and Stormux (an Arch Linux ARM variant) respectively.
I’m able to talk to the device on the RasPi 3B+, using circuits_i2c, but I’m unable to get useful data from it. Here are some IEx interactions, in which I try to read the compass:
iex(1)> alias Circuits.I2C
Circuits.I2C
iex(2)> {:ok, ref} = I2C.open("i2c-1")
{:ok, #Reference<0.517024855.4042391563.14505>}
iex(3)> I2C.bus_names
["i2c-1"]
iex(4)> I2C.detect_devices
Devices on I2C bus "i2c-1":
* 28
* 106
* 119
3 devices detected on 1 I2C buses
iex(5)> I2C.write(ref, 0x1c, <<0xf0, 0x60, 0x00>>)
iex(6)> I2C.read(ref, 0x1c, 6)
{:ok, <<0, 0, 0, 0, 0, 0>>}
iex(7)> I2C.read(ref, 0x08, 6)
{:error, :i2c_nak}
iex(8)> I2C.read(ref, 0x28, 6)
{:error, :i2c_nak}
Because I find the documentation a bit confusing, I’m not sure what address(es) I need to use. More generally, it’s quite possible that I’m sending the wrong commands. Help?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
entone
Nerves won’t help you in the near term, but i would highly recommend checking it out for reproducible builds.
I haven’t used those devices before, so unfortunately can’t be any help there. But it is most likely an issue with your commands. Also be sure you try both hats, maybe one of them is foobard.
lucaong
Here you are reading from the device with address
0x08, which is not among the addresses returned byI2C.detect_devices. Same for the other read, where you use0x28(which is address40in base 10).The documentation on the page you linked reports that the I2C addresses should be:
0x1E(30in base 10) for the magnetometer and accelerometer0x6A(106in base 10) for the gyroscope0x77(119in base 10) for the pressure sensorOr, on version 3 (which seems to be yours):
0x6A(106in base 10) for the gyroscope and accelerometer0x1C(28in base 10) for the magnetometer0x77(119in base 10) for the pressure sensorThe specifics of the protocol to read the magnetometer data over I2C is explained here, while for the accelerometer/gyro data explained here (and the C code seems to refer to this source code).
You’ll have to translate the C code in the guide to Elixir, but with some patience it looks feasible, as the guide explains it step by step. The actual addresses and registers can be found in one of these two header files, depending on the specific chip in use on your board: LSM9DS0.h and LSM9DS1.h. It looks like your board mounts the LSM9DS1.
At a glance, in order to read the compass (magnetometer) you’ll have to:
0x1Cfor the next stepsCTRL_REG5_XMto0b11110000CTRL_REG6_XMto0b01100000CTRL_REG7_XMto0b00000000OUT_X_L_Mas shown in the guideOnce you get the basic working, if you get stuck on something I am sure people here will be able to help.
Note: I made a few edits to this reply, as I was finding out more and more about it.