Uploading to Arduino Causes Uno To Freeze from PlatformIO only

If I upload from Arduino IDE, everything works fine, if I upload from PlatformIO it just freezes the Arduino. PlatformIO says that an upload was successful, but the Arduino doesn’t reset and pressing reset has no effect, and no changes have been made. This is the only error and I can’t resolve it.

src\main.cpp:10:32: warning: invalid conversion from ‘int’ to ‘PCF8574_address’ [-fpermissive]
LiquidCrystal_I2C lcd(0x27,16,2);// Change to (0x27,16,2) for 16x2 LCD.
^
In file included from src\main.cpp:6:0:
.pio\libdeps\uno\LiquidCrystal_I2C\src/LiquidCrystal_I2C.h:173:4: note: initializing argument 1 of ‘LiquidCrystal_I2C::LiquidCrystal_I2C(PCF8574_address, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, backlightPolarity)’
LiquidCrystal_I2C(PCF8574_address = PCF8574_ADDR_A21_A11_A01, uint8_t P0 = 4, uint8_t P1 = 5, uint8_t P2 = 6, uint8_t P3 = 16, uint8_t P4 = 11, uint8_t P5 = 12, uint8_t P6 = 13, uint8_t P7 = 14, backlightPolarity = POSITIVE);

I’m doing a basic Hello World sketch:

    /* I2C LCD with Arduino example code. More info: https://www.makerguides.com */

    // Include the libraries:
    // LiquidCrystal_I2C.h: https://github.com/johnrickman/LiquidCrystal_I2C
     // Library for I2C communication
    #include <LiquidCrystal_I2C.h> // Library for LCD

    // Wiring: SDA pin is connected to A4 and SCL pin to A5.
    // Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered)
    LiquidCrystal_I2C lcd(0x27,16,2);// Change to (0x27,16,2) for 16x2 LCD.

    void setup() {
      // Initiate the LCD:

      lcd.backlight();
    }

    void loop() {
      // Print 'Hello World!' on the first line of the LCD:
      lcd.setCursor(0, 0); // Set the cursor on the first column and first row.
      lcd.print("Hello World!");// Print the string "Hello World!"
      lcd.setCursor(2, 1);
      lcd.print("Testing...");
     
      //lcd.setCursor(2, 1); //Set the cursor on the third column and the second row (counting starts at 0!).
      //lcd.print("LCD tutorial");
      
    }

I can’t find this piece of code in the library you have mentioned, so it probably uses the wrong one.

Make sure that you Clean the project and, in the platformio.ini, specify the exact library to work with

lib_deps = 
   LiquidCrystal_I2C=https://github.com/johnrickman/LiquidCrystal_I2C.git

see docs.

I made your change suggested and realized I was l missing the Arduino.h, so now I have no errors…but the problem persists. I upload from VS Code IDE and the Arduino freezes. :confused:

What happens if you add some Serial ‘debugging’? Does the sketch actually start? Or is it starting, and then the library locking up? Or perhaps the wrong board type selected? You know, the usual red herrings :wink:

I tried what you suggested, and just displayed a “1” on the serial monitor. So, I was able to verify it wasn’t frozen. So I compared VScode to Arduino IDE to see what I was missing…

lcd.init();

:grimacing:

Thanks for the help. It works now. :slight_smile:

1 Like