M0 and LSM9DS1 no serial output [solved - use SerialUSB]

Started by aliocha12, February 20, 2019, 11:45:32 PM

aliocha12

I just soldered an LSM9DS1 shield to the Moteino M0 RFM69 board via the SDA/SCL/3v/gnd lines and uploaded the sample sketch on this page:

https://lowpowerlab.com/guide/moteino/m0-sensor-shields/ with the Sparkfun , spi and wire libs


I am getting no output on my serial port. Any troubleshooting tips? I have many IMU projects under my belt with other MCUs without a hitch.

Thanks!




Felix

There are init/debugging messages in the sketch, that would tell you if the M0 can't talk to the IMU.
But if you get absolutely no serial at all, that is indicating a problem with your USB/communications to the M0.

What happens if you load another sketch with serial output (ie. "hello world")? Do you get serial output?

aliocha12

When I connect the M0 to my PC it comes up as Com41, as soon as I push the "hello world" sketch, it switches to Com42, then I get error opening Com41, (port not found). I tried this with a nano and works as expected. Thanks.

Felix

nano !== M0
You need to reselect the correct serial port.

aliocha12

I get that. I tried a feather M0 express and it runs the sketch fine. Tried a different PC as well with same behavior. Thanks.

Felix

#5
The bootloader has a different port. When the sketch runs, and you upload a sketch, it switches to bootloader serial port temporarily, then it runs the new sketch and emulates the previous serial port. SerialUSB is also different than a UART and it needs a little time to be initialized but then it works at high speed. All of this can be confusing when you come from the UNO world.

Boards are tested individually to ensure they are not faulty, that sketches can upload, and the sensors give valid readings.

But ... in case it helps:

- Others who use the same combination of M0+LSM do not report any problems.
- If you want to send it back, for me to check and demo it for you, you're welcome to do that.
- If there's actually something wrong, I will replace it for you, but I highly doubt that's the case.

For M0, to get serial output through USB, you need to use SerialUSB.print...
In the LSM sample sketch this is done by replacing Serial in the following way:

#ifdef MOTEINO_ZERO
  #ifdef SERIAL_PORT_USBVIRTUAL
    #define Serial SERIAL_PORT_USBVIRTUAL // Required for Serial on Zero based boards
  #endif
#endif


But you need to select the correct port after it's uploaded.
I suggested just printing a simple hello world, using SerialUSB to ensure you can get serial output, once you know that works then try the LSM sketch.

aliocha12

I replaced all the Serial.print to SerialUSB.print and all is well. Thanks so much!