Interfacing Razor 9dof M0 IMU with ESP32

Hi, I’m using an old Razor 9dof IMU and I can’t get it to send serial data to my ESP32 board to create a dead reckoning device. I’ve checked the baud rates, set up the firmware on the setup page to send data through HARDWARE instead of USBVIRTUAL, and believe that my code doesn’t have too much issue, unless I’m doing it all wrong. How should I go about fixing this? Thanks!

Looks like a typo in line 4?

Line 4 is commented out though? I assigned the actual pin values in the UART initialization instead of using the RX2 TX2 values.

Doh, I had never seen comment blocks in arduino

You might need the flash storage library too 9DoF Razor IMU M0 Hookup Guide - SparkFun Learn to be able to save the settings, and finally there’s a an example for this if you scroll up 1 page from here 9DoF Razor IMU M0 Hookup Guide - SparkFun Learn

I have the library and followed all the instructions for setting up the UART connection, but it’s still not detecting if the channel is open or not. I’m wondering if I need to write my own firmware for the IMU instead of using the default one? Is there anything that looks wrong on the ESP32’s end?

This is what the output is looking like on the ESP32’s end, I’m using PlatformIO with the above written code for the ESP and the original firmware from the hookup guide.

There are more notes in that link I sent; make sure you made the other 2 modifications too

Serial Output Through Hardware UART Pins

The default test code does not output serial data automatically to the hardware Tx and Rx pins. It currently outputs to the SerialUSB port (i.e. the Arduino Serial Monitor). To adjust for the Hardware Serial UART pins, adjust the config.h file on line 25 to print to the Serial1 port (i.e. pin 0 for Rx and pin 1 for Tx):

#define LOG_PORT SERIAL_PORT_USBVIRTUAL

to

#define LOG_PORT SERIAL_PORT_HARDWARE

Additionally, the default firmware is currently waiting for a “$” under our QC test procedures so you would need to comment out line 131 in the _9DoF_Razor_M0_Firmware.ino by changing:

Serial1.begin(9600);

to

//Serial1.begin(9600);

Additionally, you need to comment out line 163 in the _9DoF_Razor_M0_Firmware.ino. We recommend commenting out this section of code by adding a //'s where it says:

if ( Serial1.available() )
{
if ( Serial1.read() == '

After commenting out the lines, it should look like like the following:

//if ( Serial1.available() )
//{
//  if ( Serial1.read() == '

Be sure to change the baud rate when you initialize the serial port to match the receiving serial device. The default is 115200 baud. By changing a few lines and printing the string to one of the hardware UARTs, the other serial UART that is connected can read the serial data. At a minimum, make sure to connect GND-GND, Tx-RX, and Rx-Tx. This is assuming that you are connecting the 9DoF Razor to a 3.3V device. If the other serial device can be powered at 3.3V, you can connect it to the 9DoF Razor’s 3.3V pin.

If you have not used a serial UART before, try looking at this tutorial for more information about serial communication and UARTs.

I’ve made those modifications as well. Still doesn’t work. Could it be the data formatting?

Maybe - try removing some of the explicit 8N1 or try 115200 instead (although it saying ‘no’ makes think otherwise)?