Has anyone had success reading from TI TMAG5170

I came across this thread on getting spi communications working with the TMAG5170 sensor from Texas Instruments. It was closed after 180 days of no activity with no obvious resolution, There is a corresponding tread in the TI E2E forum with a similar fate. Tagging @matistum to find out if there as been a resolution, but will welcome anyone else to jump in to help with his code. It appears that the main issue is with the CRC check.

Maybe some new info to help... The command to disable CRC must be the first command sent. A cycle through deep sleep would put the chip in that state.

My target is an esp32 and if there was a solution to the mentioned thread, it would be helpful to post the working code.

Read the pinned post re 'How to get the most from the forum'. Then make a hand drawn wiring diagram and post a picture of it. If any non-Arduino parts are used POST the datasheet (NOT a link). Do as much as you can and when stuck, post the code in code tags and any useful serial output.

Thanks for the suggestions. At tis point, I am trying to decide how to measure magnetic fields in 3d and have not committed to this chip. I have no code nor diagrams to show, Hence, the title of the post is asking "if anyone has had success" instead of "I'm stuck".

It's pretty clear that @matistum had the wiring right (was getting a response that is consistent) and posted code, which is mostly an adaptation of TI demo code. If that work never resulted in a positive outcome, I will look at other chips.

Have you tried the following library and example code?
https://github.com/light655/arduino-tmag5170

The readme claims that this is working code and addresses the CRC issue. The sample code is readable. I will order a sensor and give it a try.

For completeness, I will report back if there are any issues discovered.

Thanks for the help.

1 Like

Did you manage to get it working?

SHort answer- not yet, but still trying. After posting this thread, I tried to port the TI developer HAL to run with the ESP32. Clean compile but never tested Then I decided this was the right opportunity to dive into esp_idf. When I do get it working in idf, there might be a component I can share. It's been a long learning curve. The interface has a ton of flexibility. Based on what I know so far, if what you want is magnitudes of x, y, and z there might be a finite sequences of reads/writes that work. There are a lot of test and diagnostic registers that I haven't even looked into. Disabling crc for testing is a good idea, but can mask communication issues. Defining what sensors you want and setting them to the right mode (single shot vs continuous) is also critical. Then, realizing that if you write something (e.g. to read data), the response will be in the next frame. Right now, I think I have wiring issues which might be resolved by a capacitor.

If you are hoping for arduino code, the esp-idf c code might be a start, but it is tied to the espressif line of processors.

Looks like an interesting sensor, added the datasheet on my read list.

Only found this related (?) sensor breakout (quick look)

Hi guys,

I’m the author of the Arduino-TMAG5170 library.

When using this sensor, be sure to add a decoupling capacitor between the VDD and GND pins close to the IC. If there is no decoupling capacitor, the IC will brown out when it tries to measure the magnetic field.

This was my testing setup for your reference. Ideally, you would want a ceramic capacitor on the same PCB as the IC. But at least this was much better than wiring the IC through jumper wires to the Arduino without any capacitor in between. The resistor in the photo was for the nALERT pin, which is used to notify the MCU when the measurement is ready.

Thanks for the reply, I currently have a decoupling cap and recently added a logic analyzer to see what is going on. My alert pin is floating, which the datasheet says is fine(?).

I've been trying to stick with esp_idf (programming an esp-32), but at this point, would just like to see any approach that will get beyond every frame transfer resulting in a crc error. I don't see example code in github. Do you have an example that reads the three fields?

It should be fine to let the alert pin float.

Currently, the library doesn’t check with the TMAG5170 whether the CRC of the sent data is correct. However, it does read the 12-bit status bits every time when it exchanges an SPI frame with the TMAG5170. Maybe you can try reading the status bits and determine whether to resend the data or not.

Also, you can look at the Pico version of this library, developments happens there before being ported to Arduino.

What value capacitor would you recommend? Also, has anyone gotten this library to actually work with an Arduino or a Teensy? Currently working on this right now.

To clarify, I am just trying to read the values and get them to print to the Serial Monitor. Right now, the code successfully uploads with no errors but just does not print anything.

to enable Serial IO depending on the specific dev board if you are using an ESP32S3, ESP32C6, etc you may have to select Tools>USB CDC on Boot: Enabled

Hello,

I used a 1uF capacitor in my custom breakout board.

There is a critical bug fix just released, please update the library from Github.

@light655 - does this imply that you can include sample code that reports angles or flux strength for three axes? If so, does it work with esp32's?

@sheridandorsey I have seen reference to a 0.1uF cap across vcc and gnd. But, since my code hasn;t returned valid measurements, take that with a grain of salt

I don’t have an ESP32 so I cannot test the compatibility. I believe that bug was only related to AVR microcontrollers.

There’s an example code that measures the flux densities and print it through serial port. Maybe you can give it a try.

resolved, i was simply just reading the wrong pin. everything works as expected