Skip to content

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



Hey everyone, and welcome to this tutorial, which’s about the ToF 10120 (Time-of-Flight) LASER Rangefinder distance 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 already known before, the 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
Size 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 display the measured distance 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, the module doesn’t require a library the day this tutorial was published, maybe there is one, do a little research.

Codes

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

Code 1: Simple use with the Serial Monitor

 

 

Code 2: Display on the LCD i2c screen

 

 



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….

Yassine View All

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

37 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…

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

  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…

    • Just tried for Arduino 1.8.9 and it compiled well, if you can downgrade and check.

      Also make sure you are compiling for Arduino Uno with AVRISP mkII

  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….

    • 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?

  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)'”

    • 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.

  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)'”

    • It’s not an error, it’s a warning. As the warning says, you have multiple libraries installed. It even gives you the path!!

  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);

    • 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.

  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

    • 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.

  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.

    • 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”.

  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.

  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…

  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.

    • 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.

  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

  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…

  14. Hi, I want to use this system to measure the heating oil in the tank. My first experiment with the system threw up the problem which you solved in the questions above. I needed to delete an earlier lcd I2C library and then everything worked. I now need to change the print on the scree to show litres remaining rather than depth to the surface. My tests show that the readings vary by about 20mm and so it may be sensible to take an average over say five or ten readings. I would also like to have set warnings at different levels to order more oil and how much the tank will take. Have you any ideas please?

    • Hello, first make sure that the sensor detects the oil surface and not the tank surface, with a little bit of math you will be able to extract the number of liters remaining from the oil level, you must first measure the tank dimensions to get the volume, then you’ll measure the oil level to know the volume remaining… check the volume formulas.

      I don’t know why there are variations, if the tank is in a vehicle or something moving it’s normal, you’ll have to find another solution…. once you can do this the alarm and warnings are easy.

  15. Hello everyone, I am facing the following error: redefinition of ‘void printf_begin()’
    Has someone faced the same problem?

    Here follows the entire error message:
    Arduino: 1.8.13 (Windows 10), Placa:”WiFi LoRa 32, Disabled, 240MHz (WiFi/BT), 115200, None, REGION_EU868, None”

    C:\Users\senegalha\Desktop\testesensor\testesensor.ino: In function ‘void printf_begin()’:

    testesensor:20:6: error: redefinition of ‘void printf_begin()’

    void printf_begin(void) {

    ^

    In file included from C:\Users\senegalha\Desktop\testesensor\testesensor.ino:11:0:

    C:\Users\senegalha\Documents\Arduino\libraries\arduino_426159/printf.h:29:6: note: ‘void printf_begin()’ previously defined here

    void printf_begin(void)

    ^

    testesensor:21:31: error: ‘fdevopen’ was not declared in this scope

    fdevopen( &serial_putc, 0 );

    ^

    In file included from C:\Users\senegalha\Documents\Arduino\libraries\Heltec_ESP32_Dev-Boards\src/heltec.h:10:0,

    from C:\Users\senegalha\Desktop\testesensor\testesensor.ino:6:

    C:\Users\senegalha\AppData\Local\Arduino15\packages\Heltec-esp32\hardware\esp32\0.0.5\libraries\Wire\src/Wire.h: In function ‘void SensorRead(unsigned char, unsigned char*, unsigned char)’:

    C:\Users\senegalha\AppData\Local\Arduino15\packages\Heltec-esp32\hardware\esp32\0.0.5\libraries\Wire\src/Wire.h:99:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)

    uint8_t requestFrom(int address, int size);

    ^

    C:\Users\senegalha\AppData\Local\Arduino15\packages\Heltec-esp32\hardware\esp32\0.0.5\libraries\Wire\src/Wire.h:97:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint8_t, uint8_t)

    uint8_t requestFrom(uint8_t address, uint8_t size);

    ^

    C:\Users\senegalha\AppData\Local\Arduino15\packages\Heltec-esp32\hardware\esp32\0.0.5\libraries\Wire\src/Wire.h:99:13: note: candidate 1: uint8_t TwoWire::requestFrom(int, int)

    uint8_t requestFrom(int address, int size);

    ^

    C:\Users\senegalha\AppData\Local\Arduino15\packages\Heltec-esp32\hardware\esp32\0.0.5\libraries\Wire\src/Wire.h:95:13: note: candidate 2: uint8_t TwoWire::requestFrom(uint16_t, uint8_t)

    uint8_t requestFrom(uint16_t address, uint8_t size);

    ^

    exit status 1

    redefinition of ‘void printf_begin()’

    Thank you!

  16. Hi,
    The distance between arduino and this sensor is 15m. Is ok UART for this comm? i2c is not ok clearly. Can anyone try this, before I buy it?

Leave a Reply

Discover more from SURTR TECHNOLOGY

Subscribe now to keep reading and get access to the full archive.

Continue reading