Liadr lite v3, Adafruit Feather M4 Express, Arduino IDE

I'm trying to set up a LIDAR with the Adafruit Feather M4 Express using Arduino code.

I decided on the Feather M4 with the Garmin Lidar because of this project:

I figured the Lidar and Feather M4 are compatible. The project above uses circuitpython. I would like to use the Arduino IDE instead because I have a few other things already working with my Feather M4 and my Arduino code.

Garmin has a library for their LIDAR and when I run the GetDistanceI2c with my Feather M4


I get this error:

uint8_t requestFrom(uint8_t address, size_t quantity);

The GetDistanceI2c code and Lidar work great with my Arduino uno... Seems like my error is a common issue and since the project I linked uses the Feather M4, I figured I would have figured something out but I cant seem to get the two working on Arduino IDE.

Any tips or possible solutions would greatly help!
Thanks

Help the helpers by providing more information, like posting the code, complete error messages, a description of what went wrong, and a wiring diagram (hand drawn is preferred, with pins and parts clearly labeled).

Instructions can be found in the "How to get the best out of this forum" post, linked at the head of every forum category.

sure thing

/*------------------------------------------------------------------------------

  LIDARLite Arduino Library
  v3/GetDistanceI2c

  This example shows how to initialize, configure, and read distance from a
  LIDAR-Lite connected over the I2C interface.

  Connections:
  LIDAR-Lite 5 Vdc (red) to Arduino 5v
  LIDAR-Lite I2C SCL (green) to Arduino SCL
  LIDAR-Lite I2C SDA (blue) to Arduino SDA
  LIDAR-Lite Ground (black) to Arduino GND

  (Capacitor recommended to mitigate inrush current when device is enabled)
  680uF capacitor (+) to Arduino 5v
  680uF capacitor (-) to Arduino GND

  See the Operation Manual for wiring diagrams and more information:
  http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf

------------------------------------------------------------------------------*/

#include <Wire.h>
#include <LIDARLite.h>

LIDARLite myLidarLite;

void setup()
{
  Serial.begin(115200); // Initialize serial connection to display distance readings

  /*
    begin(int configuration, bool fasti2c, char lidarliteAddress)

    Starts the sensor and I2C.

    Parameters
    ----------------------------------------------------------------------------
    configuration: Default 0. Selects one of several preset configurations.
    fasti2c: Default 100 kHz. I2C base frequency.
      If true I2C frequency is set to 400kHz.
    lidarliteAddress: Default 0x62. Fill in new address here if changed. See
      operating manual for instructions.
  */
  myLidarLite.begin(0, true); // Set configuration to default and I2C to 400 kHz

  /*
    configure(int configuration, char lidarliteAddress)

    Selects one of several preset configurations.

    Parameters
    ----------------------------------------------------------------------------
    configuration:  Default 0.
      0: Default mode, balanced performance.
      1: Short range, high speed. Uses 0x1d maximum acquisition count.
      2: Default range, higher speed short range. Turns on quick termination
          detection for faster measurements at short range (with decreased
          accuracy)
      3: Maximum range. Uses 0xff maximum acquisition count.
      4: High sensitivity detection. Overrides default valid measurement detection
          algorithm, and uses a threshold value for high sensitivity and noise.
      5: Low sensitivity detection. Overrides default valid measurement detection
          algorithm, and uses a threshold value for low sensitivity and noise.
    lidarliteAddress: Default 0x62. Fill in new address here if changed. See
      operating manual for instructions.
  */
  myLidarLite.configure(0); // Change this number to try out alternate configurations
}

void loop()
{
  /*
    distance(bool biasCorrection, char lidarliteAddress)

    Take a distance measurement and read the result.

    Parameters
    ----------------------------------------------------------------------------
    biasCorrection: Default true. Take aquisition with receiver bias
      correction. If set to false measurements will be faster. Receiver bias
      correction must be performed periodically. (e.g. 1 out of every 100
      readings).
    lidarliteAddress: Default 0x62. Fill in new address here if changed. See
      operating manual for instructions.
  */

  // Take a measurement with receiver bias correction and print to serial terminal
  Serial.println(myLidarLite.distance());

  // Take 99 measurements without receiver bias correction and print to serial terminal
  for(int i = 0; i < 99; i++)
  {
    Serial.println(myLidarLite.distance(false));
  }
}

Looks like the Garmin library code is not written for use with whatever you have chosen as the default Wire library. Adafruit might have an adaption of the Garmin library for their boards.

You have another problem, as the Lidar is a 5V sensor, and 5V I/O pins cannot be directly connected to I/O pins on the 3.3V processor. You will need bidirectional logic level shifters for the connection, or you risk permanently damaging one or both boards.

Please do not post pictures of text. Copy and paste the error messages into the post, also using code tags.

the usb pin is 5 volts and the garmin is suppose to use 5 volts. Is this ok or do i still need a bidirectional logic level shifter?

it is the library. Any tips on how to fix it or change the code? I'm assuming in the cpp file. this simple blink sketch doesn't compile with the header files.

// the setup function runs once when you press reset or power the board

#include <Wire.h>
#include <LIDARLite.h>

void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

Error:

/Users/chrisbolig/Documents/Arduino/libraries/LIDAR-Lite/src/LIDARLite_v4LED.cpp: In member function 'void LIDARLite_v4LED::read(uint8_t, uint8_t*, uint8_t, uint8_t)':
/Users/chrisbolig/Documents/Arduino/libraries/LIDAR-Lite/src/LIDARLite_v4LED.cpp:426:5: error: no matching function for call to 'TwoWire::requestFrom(uint8_t&, uint8_t&, uint8_t&, int, bool)'
426 | );
| ^
In file included from /Users/chrisbolig/Documents/Arduino/libraries/LIDAR-Lite/src/LIDARLite_v4LED.cpp:27:
/Users/chrisbolig/Library/Arduino15/packages/adafruit/hardware/samd/1.7.16/libraries/Wire/Wire.h:45:13: note: candidate: 'uint8_t TwoWire::requestFrom(uint8_t, size_t, bool)'
45 | uint8_t requestFrom(uint8_t address, size_t quantity, bool stopBit);
| ^~~~~~~~~~~
/Users/chrisbolig/Library/Arduino15/packages/adafruit/hardware/samd/1.7.16/libraries/Wire/Wire.h:45:13: note: candidate expects 3 arguments, 5 provided
/Users/chrisbolig/Library/Arduino15/packages/adafruit/hardware/samd/1.7.16/libraries/Wire/Wire.h:46:13: note: candidate: 'uint8_t TwoWire::requestFrom(uint8_t, size_t)'
46 | uint8_t requestFrom(uint8_t address, size_t quantity);
| ^~~~~~~~~~~
/Users/chrisbolig/Library/Arduino15/packages/adafruit/hardware/samd/1.7.16/libraries/Wire/Wire.h:46:13: note: candidate expects 2 arguments, 5 provided
/Users/chrisbolig/Documents/Arduino/libraries/LIDAR-Lite/src/LIDARLite_v3HP.cpp: In member function 'void LIDARLite_v3HP::read(uint8_t, uint8_t*, uint8_t, uint8_t)':
/Users/chrisbolig/Documents/Arduino/libraries/LIDAR-Lite/src/LIDARLite_v3HP.cpp:455:5: error: no matching function for call to 'TwoWire::requestFrom(uint8_t&, uint8_t&, uint8_t&, int, bool)'
455 | );
| ^
In file included from /Users/chrisbolig/Documents/Arduino/libraries/LIDAR-Lite/src/LIDARLite_v3HP.cpp:27:
/Users/chrisbolig/Library/Arduino15/packages/adafruit/hardware/samd/1.7.16/libraries/Wire/Wire.h:45:13: note: candidate: 'uint8_t TwoWire::requestFrom(uint8_t, size_t, bool)'
45 | uint8_t requestFrom(uint8_t address, size_t quantity, bool stopBit);
| ^~~~~~~~~~~
/Users/chrisbolig/Library/Arduino15/packages/adafruit/hardware/samd/1.7.16/libraries/Wire/Wire.h:45:13: note: candidate expects 3 arguments, 5 provided
/Users/chrisbolig/Library/Arduino15/packages/adafruit/hardware/samd/1.7.16/libraries/Wire/Wire.h:46:13: note: candidate: 'uint8_t TwoWire::requestFrom(uint8_t, size_t)'
46 | uint8_t requestFrom(uint8_t address, size_t quantity);
| ^~~~~~~~~~~
/Users/chrisbolig/Library/Arduino15/packages/adafruit/hardware/samd/1.7.16/libraries/Wire/Wire.h:46:13: note: candidate expects 2 arguments, 5 provided

exit status 1

Compilation error: exit status 1

To safely connect 5V I/O pins to 3.3V I/O pins, a logic level shifter is required.

Example

isnt this 5 volt to 5 volt? just to make sure I got my volt meter out and usb to ground is 5 volts on my feather board

Your Feather board runs on 3.3V and the I/O pins are 3.3V ONLY.

Read the Adafruit docs before you destroy that nice board, possibly taking the expensive Lidar sensor with it to the recycling bin.

sorry, i just want to see where im confused. their site says you can use a 5 volt usb cable and i thought the usb pin was just a connection to that 5 volts


@jremington

found the solution from github

add
#define LEGACY_I2C
to both LIDARLite_v3HP.cpp and LIDARLite_v4LED.cpp

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.