Skip to content

Easy use of ToF 10120 LASER Rangefinder to measure distance with Arduino + LCD

 

         Hey everyone, and welcome to this tutorial, it’s about the ToF 10120 (Time-of-Flight) LASER Range sensor, the ToF sensors have become very popular due to their reliability and easy use, the most known ones are the Ultrasounds like HC-SR04 (there are a lot of variations), JSN SR-04…, you can find Infrareds too.

C.jpg
ToF 10120

But today we are about a LASER one, they all have the same principle (Send signal (Ultrasound-Laser wave-Infrared), and wait for it to return back) the duration between sending and receiving is called the Time of Flight: Speed is known before, Duration is calculated and divided by 2 -> We can find the distance.

The advantage of the LASER ones is that they are very small like the one we’re using, and can be used for high frequency applications such as camera AF…

D.jpg
Scale in (cm)

The module has 6 pins (GND-VCC) then (RX-TX) for UART and (SDA-SCL) for i²c, in this tutorial we gonna use the i²c interface to wire it with Arduino also I’ll add a LCD i²c screen to see the measure in (mm) you can convert it if you want just simple calculations.

This is the only datasheet I could find of the module Check it here.

Wiring

 

Wiring.png
Both devices use i²c interface
E.jpg
N.B: The module has 6 pins and usually come with its cable (Black is GND), GND VCC RX TX SDA SCL

Libraries

The only library I used is the LCD i²c NewLiquidCrystal: Download here

 

Codes

The codes I’ve used are modified version of some codes I found on a very sketchy chinese website with no author or source:

 

Tests:

To use this module is straight forward, wire and upload the codes:

F
Using with Serial Monitor
G
Using LCD i²c screen

That’s all folks … If you have any question you can ask me on the SurtrTech Facebook page, post a comment here or on the youtube tutorial video.

Yassine View All

Automation and Electrical Engineer, Electronics amateur trying to share my little projects.

30 thoughts on “Easy use of ToF 10120 LASER Rangefinder to measure distance with Arduino + LCD Leave a comment

  1. Newbie here…. Cannot get past this compile error…
    Can anyone please help….
    *********************************************************************************************************************************************************
    Compiling sketch…
    “C:\\Users\\JTR\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino5/bin/avr-g++” -c -g -Os -Wall -Wextra -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10810 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR “-IC:\\Users\\JTR\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\cores\\arduino” “-IC:\\Users\\JTR\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\variants\\standard” “-IC:\\Users\\JTR\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.2\\libraries\\Wire\\src” “C:\\Users\\JTR\\AppData\\Local\\Temp\\arduino_build_608678\\sketch\\ToF10120-a.ino.cpp” -o “C:\\Users\\JTR\\AppData\\Local\\Temp\\arduino_build_608678\\sketch\\ToF10120-a.ino.cpp.o”
    C:\Users\JTR\Documents\Arduino\My Sketches\Jan25a\ToF10120\ToF10120-a\ToF10120-a.ino: In function ‘void SensorRead(unsigned char, unsigned char*, unsigned char)’:

    C:\Users\JTR\Documents\Arduino\My Sketches\Jan25a\ToF10120\ToF10120-a\ToF10120-a.ino:57:27: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:

    Wire.requestFrom(82, cnt); // request cnt bytes from slave device #82 (0x52)

    ^

    In file included from C:\Users\JTR\Documents\Arduino\My Sketches\Jan25a\ToF10120\ToF10120-a\ToF10120-a.ino:6:0:

    C:\Users\JTR\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\Wire\src/Wire.h:64:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)

    uint8_t requestFrom(int, int);

    ^~~~~~~~~~~

    C:\Users\JTR\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\libraries\Wire\src/Wire.h:61:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

    uint8_t requestFrom(uint8_t, uint8_t);

    ^~~~~~~~~~~

    C:\Users\JTR\Documents\Arduino\My Sketches\Jan25a\ToF10120\ToF10120-a\ToF10120-a.ino:47:18: warning: unused variable ‘result’ [-Wunused-variable]

    unsigned short result=0;

    ^~~~~~

    Compiling libraries…

    ************************************************************************************************************************************************************************

    Like

  2. I just did a clean install on a different machine… Downloaded the “Serial Monitor Version” from the “Code” link above…. Now I get this error….
    *********************************************************************************************************************************************************
    C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino: In function ‘void SensorRead(unsigned char, unsigned char*, unsigned char)’:

    C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:57:27: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:

    Wire.requestFrom(82, cnt); // request cnt bytes from slave device #82 (0x52)

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:6:0:

    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:64:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)

    uint8_t requestFrom(int, int);

    ^

    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:61:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

    uint8_t requestFrom(uint8_t, uint8_t);

    ^
    *********************************************************************************************************************************************************
    Thanks…

    Like

  3. Thought I would try the LCD version from the code above… It throws this error….
    *************************************************************************************************************************************
    Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: “Arduino/Genuino Uno”

    TOF10120_i2c_LCD:27:80: error: no matching function for call to ‘LiquidCrystal_I2C::LiquidCrystal_I2C(int, int, int, int, int, int, int, int)’

    LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

    ^

    In file included from C:\Users\John_2\Downloads\TOF10120_i2c_LCD\TOF10120_i2c_LCD.ino:7:0:

    C:\Users\John_2\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:57:3: note: candidate: LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t, uint8_t, uint8_t)

    LiquidCrystal_I2C(uint8_t lcd_Addr,uint8_t lcd_cols,uint8_t lcd_rows);

    ^

    C:\Users\John_2\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:57:3: note: candidate expects 3 arguments, 8 provided

    C:\Users\John_2\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:55:7: note: candidate: constexpr LiquidCrystal_I2C::LiquidCrystal_I2C(const LiquidCrystal_I2C&)

    class LiquidCrystal_I2C : public Print {

    ^

    C:\Users\John_2\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:55:7: note: candidate expects 1 argument, 8 provided

    C:\Users\John_2\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:55:7: note: candidate: constexpr LiquidCrystal_I2C::LiquidCrystal_I2C(LiquidCrystal_I2C&&)

    C:\Users\John_2\Documents\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:55:7: note: candidate expects 1 argument, 8 provided

    C:\Users\John_2\Downloads\TOF10120_i2c_LCD\TOF10120_i2c_LCD.ino: In function ‘void setup()’:

    TOF10120_i2c_LCD:34:7: error: ‘class LiquidCrystal_I2C’ has no member named ‘setBacklightPin’

    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

    ^

    TOF10120_i2c_LCD:34:37: error: ‘POSITIVE’ was not declared in this scope

    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);

    ^

    C:\Users\John_2\Downloads\TOF10120_i2c_LCD\TOF10120_i2c_LCD.ino: In function ‘void SensorRead(unsigned char, unsigned char*, unsigned char)’:

    C:\Users\John_2\Downloads\TOF10120_i2c_LCD\TOF10120_i2c_LCD.ino:78:27: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:

    Wire.requestFrom(82, cnt); // request cnt bytes from slave device #82 (0x52)

    ^

    In file included from C:\Users\John_2\Downloads\TOF10120_i2c_LCD\TOF10120_i2c_LCD.ino:6:0:

    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:64:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)

    uint8_t requestFrom(int, int);

    ^

    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:61:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

    uint8_t requestFrom(uint8_t, uint8_t);

    ^

    exit status 1
    no matching function for call to ‘LiquidCrystal_I2C::LiquidCrystal_I2C(int, int, int, int, int, int, int, int)’
    **********************************************************************************************************************************************
    Seems I can’t win for loosing…. lol
    Do appreciate your help on this….

    Like

    • This is a library problem it can be solved… But I asked you about the previous code.
      After you press compile sketch does it says below that “Done compiling” or does the green bar at bottom turns orange and tells you an error?

      Like

  4. Sorry for the delay…. had some family time……

    The Serial Display code remains Green and says “Done Compiling”

    The green bar turns organge on the LCD version and displays an error message …
    “no matching function for call to ‘LiquidCrystal_I2C::LiquidCrystal_I2C(int, int, int, int, int, int, int, int)'”

    Like

    • No problem.
      Well if your code compile and says “Done compiling” it means that you have no error and the code can be uploaded on the board, the things you read are “warnings” it means that the code is “not perfect”…. and pretty much impossible in a lot of cases.

      So I suppose that it shows “Done compiling” for the codes that don’t use LCD, but for the LCD code it turns orange and that’s an actual error and the code cannot be uploaded to the board… well in the article there is the LCD i²c library, first make sure you are using an i²c LCD not a standard one, download the library it’s a .ZIP file, go to Arduino IDE -> sketch -> include library -> add .ZIP library and search for the .ZIP file you’ve downloaded, it should be okay as lon as the wiring is okay, LCD is i²c (with 0x27 address or you can make it 0x3F incase nothing shows…check also the contrast potentiometer) and finally make sure you have no other libraries with the same name in Arduino library folder.

      Like

  5. OK…. Library added, no problems…
    Still getting same error on LCD code plus this message….
    “Multiple libraries were found for “LiquidCrystal_I2C.h”
    Used: C:\Users\John_2\Documents\Arduino\libraries\LiquidCrystal_I2C
    Not used: C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5
    exit status 1
    no matching function for call to ‘LiquidCrystal_I2C::LiquidCrystal_I2C(int, int, int, int, int, int, int, int)'”

    Like

  6. Here is the line of code throwing the error…
    LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

    Like

    • That’s what I told about… you have 2 libraries with the same name, you should delete one of them: Either leave the one provided in the article and you can keep the code as it is, or leave that one you usually use and adapt the code to it.

      Like

  7. The names are different when I select Sketch->Include Libraries..
    How do I remove one of them… I do not see any option to delete under “Manage Library” nor the “Include”
    Man, I hate to appear so dumb on this stuff…. as you can see, I’m a newbie and to add insult to injury, I’m 71 years old…. things do come like they once did… You’ll see… lol

    Like

    • Absolutely no problem… Go to your folder (name depends on user name) then go to “My documents” or “Documents” you’ll find a folder named Arduino and inside it there’s a folder named “libraries”, the library folder that I’m using is named “NewLiquidCrystal” you should keep that one and delete others that have relation with LCD i²c.

      Like

  8. Hey man! I got it! Used this thing called a search engine (lol)… fixed it (I think)… Now when I compile I get this error message BUT it does say ” Done Compiling” on the bar above the error message window…

    C:\Users\John_2\Downloads\TOF10120_i2c_LCD\TOF10120_i2c_LCD.ino: In function ‘void SensorRead(unsigned char, unsigned char*, unsigned char)’:

    C:\Users\John_2\Downloads\TOF10120_i2c_LCD\TOF10120_i2c_LCD.ino:78:27: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:

    Wire.requestFrom(82, cnt); // request cnt bytes from slave device #82 (0x52)

    ^

    In file included from C:\Users\John_2\Downloads\TOF10120_i2c_LCD\TOF10120_i2c_LCD.ino:6:0:

    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:64:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)

    uint8_t requestFrom(int, int);

    ^

    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:61:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

    uint8_t requestFrom(uint8_t, uint8_t);

    ^

    Sketch uses 5748 bytes (17%) of program storage space. Maximum is 32256 bytes.
    Global variables use 487 bytes (23%) of dynamic memory, leaving 1561 bytes for local variables. Maximum is 2048 bytes.

    Like

    • Yes that’s completely normal, the important thing is that it tells you “Done compiling”.
      Those messages shown are not “errors” messages but “warnings” messages, and they are normal in most of the codes !!

      This means that you can upload the code to your board without any problem… The orange thing and highlighted lines are actually a problem, but now you fixed it, don’t care about “warnings”.

      Like

  9. Now the Serial Display is broken…. Just when I thought I was getting somewhere…

    Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: “Arduino/Genuino Uno”

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h: In function ‘void i2c_wait_scl_high()’:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:172:31: error: ‘SCL_PORT’ was not declared in this scope

    #define SCL_IN (_SFR_IO_ADDR(SCL_PORT) – 2)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:210:23: note: in expansion of macro ‘SCL_IN’

    : : [SCLIN] “I” (SCL_IN), [SCLPIN] “I” (SCL_PIN));

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:210:46: error: ‘SCL_PIN’ was not declared in this scope

    : : [SCLIN] “I” (SCL_IN), [SCLPIN] “I” (SCL_PIN));

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h: In function ‘boolean i2c_init()’:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:168:38: error: ‘SCL_PORT’ was not declared in this scope

    #define SCL_DDR (_SFR_IO_ADDR(SCL_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:264:23: note: in expansion of macro ‘SCL_DDR’

    [SCLDDR] “I” (SCL_DDR), [SCLPIN] “I” (SCL_PIN),

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:264:47: error: ‘SCL_PIN’ was not declared in this scope

    [SCLDDR] “I” (SCL_DDR), [SCLPIN] “I” (SCL_PIN),

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:167:38: error: ‘SDA_PORT’ was not declared in this scope

    #define SDA_DDR (_SFR_IO_ADDR(SDA_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:266:23: note: in expansion of macro ‘SDA_DDR’

    [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN),

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:266:47: error: ‘SDA_PIN’ was not declared in this scope

    [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN),

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h: In function ‘bool i2c_start(uint8_t)’:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:167:38: error: ‘SDA_PORT’ was not declared in this scope

    #define SDA_DDR (_SFR_IO_ADDR(SDA_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:284:25: note: in expansion of macro ‘SDA_DDR’

    : : [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN),

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:284:49: error: ‘SDA_PIN’ was not declared in this scope

    : : [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN),

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:172:31: error: ‘SCL_PORT’ was not declared in this scope

    #define SCL_IN (_SFR_IO_ADDR(SCL_PORT) – 2)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:285:21: note: in expansion of macro ‘SCL_IN’

    [SCLIN] “I” (SCL_IN),[SCLPIN] “I” (SCL_PIN));

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:285:43: error: ‘SCL_PIN’ was not declared in this scope

    [SCLIN] “I” (SCL_IN),[SCLPIN] “I” (SCL_PIN));

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h: In function ‘bool i2c_rep_start(uint8_t)’:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:168:38: error: ‘SCL_PORT’ was not declared in this scope

    #define SCL_DDR (_SFR_IO_ADDR(SCL_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:309:25: note: in expansion of macro ‘SCL_DDR’

    : : [SCLDDR] “I” (SCL_DDR), [SCLPIN] “I” (SCL_PIN),[SCLIN] “I” (SCL_IN),

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:309:49: error: ‘SCL_PIN’ was not declared in this scope

    : : [SCLDDR] “I” (SCL_DDR), [SCLPIN] “I” (SCL_PIN),[SCLIN] “I” (SCL_IN),

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:167:38: error: ‘SDA_PORT’ was not declared in this scope

    #define SDA_DDR (_SFR_IO_ADDR(SDA_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:310:25: note: in expansion of macro ‘SDA_DDR’

    [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN));

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:310:49: error: ‘SDA_PIN’ was not declared in this scope

    [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN));

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h: In function ‘void i2c_start_wait(uint8_t)’:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:167:38: error: ‘SDA_PORT’ was not declared in this scope

    #define SDA_DDR (_SFR_IO_ADDR(SDA_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:337:24: note: in expansion of macro ‘SDA_DDR’

    : : [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN),

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:337:48: error: ‘SDA_PIN’ was not declared in this scope

    : : [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN),

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:172:31: error: ‘SCL_PORT’ was not declared in this scope

    #define SCL_IN (_SFR_IO_ADDR(SCL_PORT) – 2)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:338:20: note: in expansion of macro ‘SCL_IN’

    [SCLIN] “I” (SCL_IN),[SCLPIN] “I” (SCL_PIN));

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:338:42: error: ‘SCL_PIN’ was not declared in this scope

    [SCLIN] “I” (SCL_IN),[SCLPIN] “I” (SCL_PIN));

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h: In function ‘void i2c_stop()’:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:168:38: error: ‘SCL_PORT’ was not declared in this scope

    #define SCL_DDR (_SFR_IO_ADDR(SCL_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:357:25: note: in expansion of macro ‘SCL_DDR’

    : : [SCLDDR] “I” (SCL_DDR), [SCLPIN] “I” (SCL_PIN), [SCLIN] “I” (SCL_IN),

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:357:49: error: ‘SCL_PIN’ was not declared in this scope

    : : [SCLDDR] “I” (SCL_DDR), [SCLPIN] “I” (SCL_PIN), [SCLIN] “I” (SCL_IN),

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:167:38: error: ‘SDA_PORT’ was not declared in this scope

    #define SDA_DDR (_SFR_IO_ADDR(SDA_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:358:25: note: in expansion of macro ‘SDA_DDR’

    [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN));

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:358:49: error: ‘SDA_PIN’ was not declared in this scope

    [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN));

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h: In function ‘bool i2c_write(uint8_t)’:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:168:38: error: ‘SCL_PORT’ was not declared in this scope

    #define SCL_DDR (_SFR_IO_ADDR(SCL_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:433:22: note: in expansion of macro ‘SCL_DDR’

    [SCLDDR] “I” (SCL_DDR), [SCLPIN] “I” (SCL_PIN), [SCLIN] “I” (SCL_IN),

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:433:46: error: ‘SCL_PIN’ was not declared in this scope

    [SCLDDR] “I” (SCL_DDR), [SCLPIN] “I” (SCL_PIN), [SCLIN] “I” (SCL_IN),

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:167:38: error: ‘SDA_PORT’ was not declared in this scope

    #define SDA_DDR (_SFR_IO_ADDR(SDA_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:434:22: note: in expansion of macro ‘SDA_DDR’

    [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN), [SDAIN] “I” (SDA_IN));

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:434:46: error: ‘SDA_PIN’ was not declared in this scope

    [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN), [SDAIN] “I” (SDA_IN));

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h: In function ‘uint8_t i2c_read(bool)’:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:168:38: error: ‘SCL_PORT’ was not declared in this scope

    #define SCL_DDR (_SFR_IO_ADDR(SCL_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:502:22: note: in expansion of macro ‘SCL_DDR’

    [SCLDDR] “I” (SCL_DDR), [SCLPIN] “I” (SCL_PIN), [SCLIN] “I” (SCL_IN),

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:502:46: error: ‘SCL_PIN’ was not declared in this scope

    [SCLDDR] “I” (SCL_DDR), [SCLPIN] “I” (SCL_PIN), [SCLIN] “I” (SCL_IN),

    ^

    In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

    from c:\program files\windowsapps\arduinollc.arduinoide_1.8.21.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

    from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

    from sketch\TOF10120_i2c_SerialM.ino.cpp:1:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:167:38: error: ‘SDA_PORT’ was not declared in this scope

    #define SDA_DDR (_SFR_IO_ADDR(SDA_PORT) – 1)

    ^

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:503:22: note: in expansion of macro ‘SDA_DDR’

    [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN), [SDAIN] “I” (SDA_IN)

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:13:0:

    C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/SoftI2CMaster.h:503:46: error: ‘SDA_PIN’ was not declared in this scope

    [SDADDR] “I” (SDA_DDR), [SDAPIN] “I” (SDA_PIN), [SDAIN] “I” (SDA_IN)

    ^

    C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino: In function ‘void SensorRead(unsigned char, unsigned char*, unsigned char)’:

    C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:73:27: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:

    Wire.requestFrom(82, cnt); // request cnt bytes from slave device #82 (0x52)

    ^

    In file included from C:\Users\John_2\Documents\Arduino\libraries\Newliquidcrystal_1.3.5/LiquidCrystal_I2C_ByVac.h:44:0,

    from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:6:

    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:64:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)

    uint8_t requestFrom(int, int);

    ^

    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:61:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

    uint8_t requestFrom(uint8_t, uint8_t);

    ^

    exit status 1
    Error compiling for board Arduino/Genuino Uno.

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    Like

  10. Hang on….. Somehow I don’t have the Serial version…. must have renamed something wrong… Getting the Serial version now…
    Man I hate the confusion…

    Like

  11. OK… I think I’m back on track…. I have compiled the Serial version and I get “Done Compiling” The is no “Error” message but I do get this…
    C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino: In function ‘void SensorRead(unsigned char, unsigned char*, unsigned char)’:

    C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:57:27: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second:

    Wire.requestFrom(82, cnt); // request cnt bytes from slave device #82 (0x52)

    ^

    In file included from C:\Users\John_2\Downloads\Arduino\TOF10120_i2c_SerialM\TOF10120_i2c_SerialM.ino:6:0:

    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:64:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)

    uint8_t requestFrom(int, int);

    ^

    C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\Wire\src/Wire.h:61:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

    uint8_t requestFrom(uint8_t, uint8_t);

    ^

    Sketch uses 4494 bytes (13%) of program storage space. Maximum is 32256 bytes.
    Global variables use 436 bytes (21%) of dynamic memory, leaving 1612 bytes for local variables. Maximum is 2048 bytes.

    Like

    • There’s a code version for Serial monitor where the module is connected using i²c
      And there’s a LCD i²c version where both the module and LCD are using i²c interface.

      If it shows “Done compiling” it means it can be uploaded to Arduino board, upload using the upload button make sure you’ve selected the correct COM port and the Arduino is plugged in.

      Like

  12. Thanks man…. you’ve been a great help…I think I’ve learned a great deal about the library system and how to manage it (somewhat…. lol).

    Thanks again
    John

    Like

  13. The wire.h library knows
    Wire.requestFrom(uint8_t, uint8_t);
    Wire.requestFrom(int, int);
    only, while the used
    Wire.requestFrom(82, cnt); means Wire.requestFrom(int, uint8_t);
    So modify the line in this way:
    Wire.requestFrom((uint8_t)82, cnt); // request cnt bytes from slave device #82 (0x52)
    BTW: Messages received by compiler were warnings only…

    Like

Leave a Reply to J tCancel Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: