I am trying to take readings from the Melexis Tri-axis Hall effect sensor MLX90393, but all I seem to get is garbage.

I am reading the sensor over SPI, with a 1MHz clock. Here is an example of a couple of SPI transactions with the device, just to show that the waveform is nice. I have shown the two transactions closer together than they really are, just to fit them on the image. In reality they are 3ms apart.

SPI waveform MLX90303

Here is a description of the full set of transactions:

  1. Reset. Send F000 (then wait 3ms)
  2. Write Mem adr 00 with 000C (wait 100us)
  3. Write Mem adr 01 with C380 (wait 100us)
  4. Write Mem adr 02 with 0068 (wait 100us)
  5. Start single measurement read: Send 3E (wait 1ms)
  6. Read Measurement: Send 4E, receive FF75 8FEF FFFB (wait 100ms)

Then I loop 5. and 6. over and over.

The values I get back seem to make no sense. They certainly don't look like a slightly noise analog signal, which is what I would expect. For example, multiple reads from channel 0 look like: FFFB 0707 0707 8FEF 0707 F3AF FF75

What am I doing wrong?


1 Answer 1


Your SPI mode does not match the datasheet, it indicates CPOL = 1, aka your spi clock should idle high.

  • \$\begingroup\$ Well spotted! Unfortunately, this didn't seem to make any difference. \$\endgroup\$ Commented Jan 29, 2019 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.