AS5048A with Arduino Mega: 0.0 readout

Hi, I connected the AS5048A magnetic sensor to an Arduino Mega board (SPI). I used the example program to test it.
https://github.com/simplefoc/Arduino-FOC/tree/master/examples/utils/sensor_test/magnetic_sensors/magnetic_sensor_spi/magnetic_sensor_spi_example

with:

MagneticSensorSPI sensor = MagneticSensorSPI(10, 14, 0x3FFF);

No compiling errors, but only 0.0 readouts. When I change the Mega with an Uno (same sketch, same pins), I get normal readouts.

Any solution? Is it a software bug?

Thx

  1. Check pin selection

Arduino Mega SPI pins: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS).

Arduino Nano SPI pins: 10 (SS) Chip Select or any pin, 11 (MOSI), 12 (MISO), 13 (SCK)

Arduino Uno SPI pins: 10 (SS) Chip Select or any pin, 11 (MOSI), 12 (MISO), 13 (SCK)

  1. Check wiring, crossed wires, wrong wires go to the wrong pins.

  2. Check bad / cold connections (pins connected but wire connector is bad).

  3. Check code for separate boards is using the correct pin assignment in the code.

  4. Check target MCU in Arduino IDE/GUI is building for correct target MCU.

  5. Check AS5048A sensor is using correct voltage (3v vs 5v), nano and mega use 5v, but if you select 3v for the sensor, sometimes it works intermittently even though it should not, so you get funny half-assed readings.

Most of the times it’s a combination of some of the aforementioned problems so you got to have extreme patience and trace the problem. Most importantly, the problem is simple so don’t get frustrated and throw the board on the floor and jump on top if it. It doesn’t help. I’ve tried.

Cheers,
Valentine
giphy

Thx, that did the trick. I knew this…

1 Like