kinCony KC868 A8, PCF8574

Hello friends..
I'm new here, I acquired a Kincony kc868 A8 board with esp32 and pcf8574 to activate the relays, I made an example in the Arduino IDE and everything works normally, however when I try to load the example in the Arduino Cloud an error always occurs that says P0, P1,... were not declared in the scope. Has anyone been through this or can anyone help me?

#include "PCF8574.h"
#include "Arduino.h"
PCF8574 pcf8574(0x24); 

void setup() {
 
  Serial.begin(115200);

  pcf8574.pinMode(P0,OUTPUT);
  pcf8574.pinMode(P1,OUTPUT);
  pcf8574.pinMode(P2,OUTPUT);
  pcf8574.pinMode(P3,OUTPUT);
  pcf8574.pinMode(P4,OUTPUT);
  pcf8574.pinMode(P5,OUTPUT);
  pcf8574.pinMode(P6,OUTPUT);
  pcf8574.pinMode(P7,OUTPUT);

  Serial.print("Initi pcf8574...");
  if(pcf8574.begin()){
    Serial.println("OK");
  }else{
    Serial.println("KO");
  }
  
}

void loop() {

  pcf8574.digitalWrite(P0,LOW);
  pcf8574.digitalWrite(P1,LOW);
  pcf8574.digitalWrite(P2,LOW);
  pcf8574.digitalWrite(P3,LOW);
  pcf8574.digitalWrite(P4,LOW);
  pcf8574.digitalWrite(P5,LOW);
  pcf8574.digitalWrite(P6,LOW);
  pcf8574.digitalWrite(P7,LOW);
  delay(5000);

  pcf8574.digitalWrite(P0,HIGH);
  delay(500);
  pcf8574.digitalWrite(P1,HIGH);
  delay(500);
  pcf8574.digitalWrite(P2,HIGH);
  delay(500);
  pcf8574.digitalWrite(P3,HIGH);
  delay(500);
  pcf8574.digitalWrite(P4,HIGH);
  delay(500);
  pcf8574.digitalWrite(P5,HIGH);
  delay(500);
  pcf8574.digitalWrite(P6,HIGH);
  delay(500);
  pcf8574.digitalWrite(P7,HIGH);
  delay(500);

  pcf8574.digitalWrite(P0,LOW);
  delay(500);
  pcf8574.digitalWrite(P1,LOW);
  delay(500);
  pcf8574.digitalWrite(P2,LOW);
  delay(500);
  pcf8574.digitalWrite(P3,LOW);
  delay(500);
  pcf8574.digitalWrite(P4,LOW);
  delay(500);
  pcf8574.digitalWrite(P5,LOW);
  delay(500);
  pcf8574.digitalWrite(P6,LOW);
  delay(500);
  pcf8574.digitalWrite(P7,LOW);
  delay(500);
  
}

The error that appears is this:

/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino: In function 'void setup()':
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:52:11: error: 'class PCF8574' has no member named 'pinMode'
   pcf8574.pinMode(P0,OUTPUT);
           ^~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:52:19: error: 'P0' was not declared in this scope
   pcf8574.pinMode(P0,OUTPUT);
                   ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:52:19: note: suggested alternative: 'T0'
   pcf8574.pinMode(P0,OUTPUT);
                   ^~
                   T0
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:53:11: error: 'class PCF8574' has no member named 'pinMode'
   pcf8574.pinMode(P1,OUTPUT);
           ^~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:53:19: error: 'P1' was not declared in this scope
   pcf8574.pinMode(P1,OUTPUT);
                   ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:53:19: note: suggested alternative: 'T1'
   pcf8574.pinMode(P1,OUTPUT);
                   ^~
                   T1
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:54:11: error: 'class PCF8574' has no member named 'pinMode'
   pcf8574.pinMode(P2,OUTPUT);
           ^~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:54:19: error: 'P2' was not declared in this scope
   pcf8574.pinMode(P2,OUTPUT);
                   ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:54:19: note: suggested alternative: 'T2'
   pcf8574.pinMode(P2,OUTPUT);
                   ^~
                   T2
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:55:11: error: 'class PCF8574' has no member named 'pinMode'
   pcf8574.pinMode(P3,OUTPUT);
           ^~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:55:19: error: 'P3' was not declared in this scope
   pcf8574.pinMode(P3,OUTPUT);
                   ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:55:19: note: suggested alternative: 'T3'
   pcf8574.pinMode(P3,OUTPUT);
                   ^~
                   T3
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:56:11: error: 'class PCF8574' has no member named 'pinMode'
   pcf8574.pinMode(P4,OUTPUT);
           ^~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:56:19: error: 'P4' was not declared in this scope
   pcf8574.pinMode(P4,OUTPUT);
                   ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:56:19: note: suggested alternative: 'T4'
   pcf8574.pinMode(P4,OUTPUT);
                   ^~
                   T4
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:57:11: error: 'class PCF8574' has no member named 'pinMode'
   pcf8574.pinMode(P5,OUTPUT);
           ^~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:57:19: error: 'P5' was not declared in this scope
   pcf8574.pinMode(P5,OUTPUT);
                   ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:57:19: note: suggested alternative: 'T5'
   pcf8574.pinMode(P5,OUTPUT);
                   ^~
                   T5
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:58:11: error: 'class PCF8574' has no member named 'pinMode'
   pcf8574.pinMode(P6,OUTPUT);
           ^~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:58:19: error: 'P6' was not declared in this scope
   pcf8574.pinMode(P6,OUTPUT);
                   ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:58:19: note: suggested alternative: 'T6'
   pcf8574.pinMode(P6,OUTPUT);
                   ^~
                   T6
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:59:11: error: 'class PCF8574' has no member named 'pinMode'
   pcf8574.pinMode(P7,OUTPUT);
           ^~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:59:19: error: 'P7' was not declared in this scope
   pcf8574.pinMode(P7,OUTPUT);
                   ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:59:19: note: suggested alternative: 'T7'
   pcf8574.pinMode(P7,OUTPUT);
                   ^~
                   T7
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino: In function 'void loop()':
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:74:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P0,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:74:24: error: 'P0' was not declared in this scope
   pcf8574.digitalWrite(P0,LOW);
                        ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:74:24: note: suggested alternative: 'T0'
   pcf8574.digitalWrite(P0,LOW);
                        ^~
                        T0
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:75:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P1,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:75:24: error: 'P1' was not declared in this scope
   pcf8574.digitalWrite(P1,LOW);
                        ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:75:24: note: suggested alternative: 'T1'
   pcf8574.digitalWrite(P1,LOW);
                        ^~
                        T1
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:76:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P2,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:76:24: error: 'P2' was not declared in this scope
   pcf8574.digitalWrite(P2,LOW);
                        ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:76:24: note: suggested alternative: 'T2'
   pcf8574.digitalWrite(P2,LOW);
                        ^~
                        T2
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:77:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P3,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:77:24: error: 'P3' was not declared in this scope
   pcf8574.digitalWrite(P3,LOW);
                        ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:77:24: note: suggested alternative: 'T3'
   pcf8574.digitalWrite(P3,LOW);
                        ^~
                        T3
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:78:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P4,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:78:24: error: 'P4' was not declared in this scope
   pcf8574.digitalWrite(P4,LOW);
                        ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:78:24: note: suggested alternative: 'T4'
   pcf8574.digitalWrite(P4,LOW);
                        ^~
                        T4
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:79:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P5,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:79:24: error: 'P5' was not declared in this scope
   pcf8574.digitalWrite(P5,LOW);
                        ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:79:24: note: suggested alternative: 'T5'
   pcf8574.digitalWrite(P5,LOW);
                        ^~
                        T5
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:80:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P6,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:80:24: error: 'P6' was not declared in this scope
   pcf8574.digitalWrite(P6,LOW);
                        ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:80:24: note: suggested alternative: 'T6'
   pcf8574.digitalWrite(P6,LOW);
                        ^~
                        T6
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:81:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P7,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:81:24: error: 'P7' was not declared in this scope
   pcf8574.digitalWrite(P7,LOW);
                        ^~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:81:24: note: suggested alternative: 'T7'
   pcf8574.digitalWrite(P7,LOW);
                        ^~
                        T7
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:84:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P0,HIGH);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:86:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P1,HIGH);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:88:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P2,HIGH);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:90:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P3,HIGH);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:92:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P4,HIGH);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:94:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P5,HIGH);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:96:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P6,HIGH);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:98:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P7,HIGH);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:101:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P0,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:103:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P1,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:105:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P2,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:107:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P3,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:109:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P4,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:111:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P5,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:113:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P6,LOW);
           ^~~~~~~~~~~~
/run/arduino/sketches/Untitled_2_dec27a/Untitled_2_dec27a.ino:115:11: error: 'class PCF8574' has no member named 'digitalWrite'
   pcf8574.digitalWrite(P7,LOW);
           ^~~~~~~~~~~~
Multiple libraries were found for "WiFiClientSecure.h"
  Used: /run/arduino/directories-data/packages/esp32/hardware/esp32/2.0.17/libraries/WiFiClientSecure
  Not used: /run/arduino/directories-data/internal/Seeed_Arduino_rpcWiFi_1.1.0_a93a349668c69c81
Multiple libraries were found for "Wire.h"
  Used: /run/arduino/directories-data/packages/esp32/hardware/esp32/2.0.17/libraries/Wire
  Not used: /run/arduino/directories-data/internal/FlexWire_1.2.1_1fc5f1d1a14af0e7
Multiple libraries were found for "PCF8574.h"
  Used: /run/arduino/custom-libraries/PCF8574
  Not used: /run/arduino/directories-data/internal/PCF8574_0.4.1_bbea225d3c93d76c
  Not used: /run/arduino/directories-data/internal/PCF8574_library_2.3.7_288bbfb1808c4029
  Not used: /run/arduino/custom-libraries/PCF8574 library
Multiple libraries were found for "WiFi.h"
  Used: /run/arduino/directories-data/packages/esp32/hardware/esp32/2.0.17/libraries/WiFi
  Not used: /run/arduino/directories-data/internal/BetterWiFiNINA_1.3.0_0ccca45bdf408f34
  Not used: /run/arduino/directories-data/internal/NINA-Wi-Fi_1.0.1_8b5f9e1dc71eca55
  Not used: /run/arduino/directories-data/internal/WiFi_1.2.7_c357666d3257ae8a
  Not used: /run/arduino/directories-data/internal/DA16200_Wi-Fi_Library_for_Arduino_1.1.0_9d156d307009fe30
  Not used: /run/arduino/directories-data/internal/WiFiNINA_1.8.14_50fd037d6f2f4b4b
  Not used: /run/arduino/directories-data/internal/indhilib_3.0.5_645ae16078e566f4
  Not used: /run/arduino/directories-data/internal/WiFiEspAT_1.5.0_5169a7bcde168205
  Not used: /run/arduino/directories-data/internal/VEGA_WiFiNINA_1.0.1_ab2db6059607e9f4
  Not used: /run/arduino/directories-data/internal/Seeed_Arduino_rpcWiFi_1.1.0_a93a349668c69c81

Did you add the library to the cloud?

1 Like

yes I installed the library as you can see in the posted code. However, this error only appears in the web editor, in the Arduino IDE everything runs normally.

I think the no member error is the key, a same name library was used rather than the intended. I don't know how to resolve that off the top of my head, but it has been solved before on the forum so try searching here for wrong library.

Let's see if I understand. Are you saying that there are two libraries with the same name and I may have used the wrong one and that's why this error occurs? Have you seen anything about this here on the forum before?

Yes I have, that is what I said. Do a search because at 82 I don't remember the fine details so much.

Very good.. I'm doing research but I'm not finding anything. I'm going to keep looking and also hope that a member of the group can help me with this solution.

The library names and includes are case sensitive, so the PCF8574 by Rob Tillaart is not the same as pfc8574 by MSZ98.

Something funny, I copied your sketch and get the same errors you got. I think I tried all the combos, upper case/lower case, adafruit.
It does NOT compile in IDE, so no chance in the cloud.

Friend, I think you gave me great ideas, everything is compiling normally in the Arduino IDE. What I was thinking is the following: The library I need is from the author Henzo Michianti and above it in the web editor there is the one from the author Rob Tillaart if I'm not mistaken and both are declared the same way PCF8574.h so it could be that the web Is the editor making a mistake when running these libraries?

Not the same at all, one is uppercase, one is lowercase. That is the only way identically named libraries can be managed. See pic for proof.
Could you rephrase the following in English I can understand?
BTW, your sketch does NOT compile in the IDE either.

so it could be that the web Is the editor making a mistake when running these libraries?

It compiled here with me, the relays are all working, it just doesn't compile in the web editor.. I have the same problem

Obviously there is some missing information, so I will mute this.

My friend, this is the original sketch:

#include <PCF8574.h>

PCF8574 pcf8574(0x24);

void setup() {
  
  pcf8574.pinMode(P0,OUTPUT);
  pcf8574.pinMode(P1,OUTPUT);
  pcf8574.pinMode(P2,OUTPUT);
  pcf8574.pinMode(P3,OUTPUT);
  pcf8574.pinMode(P4,OUTPUT);
  pcf8574.pinMode(P5,OUTPUT);
  pcf8574.pinMode(P6,OUTPUT);
  pcf8574.pinMode(P7,OUTPUT);

  Serial.print("Initi pcf8574...");
  if(pcf8574.begin()){
    Serial.println("OK");
  }else{
    Serial.println("KO");
  }

}

void loop() {

   pcf8574.digitalWrite(P0,LOW);
  pcf8574.digitalWrite(P1,LOW);
  pcf8574.digitalWrite(P2,LOW);
  pcf8574.digitalWrite(P3,LOW);
  pcf8574.digitalWrite(P4,LOW);
  pcf8574.digitalWrite(P5,LOW);
  pcf8574.digitalWrite(P6,LOW);
  pcf8574.digitalWrite(P7,LOW);
  delay(5000);

  pcf8574.digitalWrite(P0,HIGH);
  delay(1000);
  pcf8574.digitalWrite(P1,HIGH);
  delay(1000);
  pcf8574.digitalWrite(P2,HIGH);
  delay(1000);
  pcf8574.digitalWrite(P3,HIGH);
  delay(1000);
  pcf8574.digitalWrite(P4,HIGH);
  delay(1000);
  pcf8574.digitalWrite(P5,HIGH);
  delay(1000);
  pcf8574.digitalWrite(P6,HIGH);
  delay(1000);
  pcf8574.digitalWrite(P7,HIGH);
  delay(1000);

  pcf8574.digitalWrite(P0,LOW);
  delay(1000);
  pcf8574.digitalWrite(P1,LOW);
  delay(1000);
  pcf8574.digitalWrite(P2,LOW);
  delay(1000);
  pcf8574.digitalWrite(P3,LOW);
  delay(1000);
  pcf8574.digitalWrite(P4,LOW);
  delay(1000);
  pcf8574.digitalWrite(P5,LOW);
  delay(1000);
  pcf8574.digitalWrite(P6,LOW);
  delay(1000);
  pcf8574.digitalWrite(P7,LOW);
  delay(1000);

}

It compiles normally, I saw someone here in the community with a similar problem. The board I'm using is Kincony and the communication pins have to be 4 and 5 for the relays to be activated.
https://forum.arduino.cc/t/difference-in-compiled-file-cloud-vs-ide/1203419
But I don't know how to use this in my code, could you help me?
I believe it is easy for people with experience.

Hi @10eliseu.

Great job on identifying the cause of the problem!

Every one of the thousands of libraries in the Arduino Library Manager are pre-installed in Arduino Cloud.

This is very convenient because it means you don't need to worry about installing or updating the libraries. However, it can sometimes cause issues. The problem is that, for any common filename used in an #include directive in your sketch program, there may be multiple libraries that contain a file of that name. When this occurs, Arduino Cloud attempts to automatically pick the best library to use when compiling your sketch. It is pretty smart about this, but unfortunately doesn't always make the right choice.

As you guessed, this is a case where Arduino Cloud picked a different library than the one your sketch was meant to use.

I'll provide instructions you can follow to configure the library that should be used when compiling your sketch in Arduino Cloud:

  1. If you are not already, log in to your Arduino account:
    https://login.arduino.cc/login
  2. Click the following link to open the list of your Arduino Cloud sketches in the web browser:
    https://app.arduino.cc/sketches
  3. Select the sketch for which you want to configure the library to be used.
    The sketch will open in Arduino Cloud Editor.
  4. Click the icon that looks like shelved books ("Libraries") in the bar on the left side of the Cloud Editor page.
    The "Libraries" panel will open.
  5. Type PCF8574 library in the "Search libraries" field near the top of the panel.
  6. Find the entry for the "PCF8574 library" library in the list of search results.
  7. You will see a drop-down menu in the library's entry. Click on it.
    The menu will open.
  8. Select the version of the library you want the sketch to use from the menu.
    :exclamation: You must select a menu item other than the "Latest (...)" item at the top of the menu.
    The menu will close.
  9. Click the "INCLUDE" button in the "PCF8574 library" library entry.
    Clicking this button configures the sketch to use the "PCF8574 library" library, at the specific version selected from the menu.
    You might now see a "Library already included" notification. This is expected and doesn't indicate any problem.

Now try compiling the sketch again. This time the expected library should be used.

Note that the library configuration achieved via the above procedure was specific to the sketch you had open in Arduino Cloud Editor. If you want to make the same configuration for another sketch, open it in Cloud Editor and repeat the procedure.

The above procedure configured the sketch to always use the version you selected from the menu. Important enhancements or bug fixes might be made to the library in future releases of the library, so it is a good idea to periodically check for the availability of newer versions. You can repeat the procedure above to configure the sketch to use a different version of the library.


Please let me know if you have any questions or problems while following those instructions.

@ptillisch

No my friend, it still doesn't work, now I don't know if he is accessing this library or the other. Or if the problem is something else.
If there was a way for me to delete this rob tillart library, I believe it could work.

@ptillisch
I saw that you are part of the Arduino team. I found the solution, I took Renzo Mischianti's library and placed it at the beginning of my sketch instead of including it and so my code compiled normally:

/*
 * PCF8574 GPIO Port Expand
 *
 * AUTHOR:  Renzo Mischianti
 * VERSION: 2.3.7
 *
 * https://www.mischianti.org/2019/01/02/pcf8574-i2c-digital-i-o-expander-fast-easy-usage/
 *
 * The MIT License (MIT)
 *
 * Copyright (c) 2017 Renzo Mischianti www.mischianti.org All right reserved.
 *
 * You may copy, alter and reuse this code in any way you like, but please leave
 * reference to www.mischianti.org in your comments if you redistribute this code.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

#ifndef PCF8574_h
#define PCF8574_h

#include "Wire.h"

#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif

#define DEFAULT_SDA SDA;
#define DEFAULT_SCL SCL;

// Uncomment to enable printing out nice debug messages.
//  #define PCF8574_DEBUG

// Uncomment for low memory usage this prevent use of complex DigitalInput structure and free 7byte of memory
// #define PCF8574_LOW_MEMORY

// Uncomment for low latency to get realtime data every time.
// #define PCF8574_LOW_LATENCY

//#define PCF8574_SOFT_INITIALIZATION

// Select an algorithm to manage encoder progression
 #define BASIC_ENCODER_ALGORITHM
// #define MISCHIANTI_ENCODER_ALGORITHM
// #define SEQUENCE_ENCODER_ALGORITHM_REDUCED
// #define SEQUENCE_ENCODER_ALGORITHM
// #define POKI_ENCODER_ALGORITHM

// Define where debug output will be printed.
#define DEBUG_PRINTER Serial

// Setup debug printing macros.
#ifdef PCF8574_DEBUG
	#define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); }
	#define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); }
#else
	#define DEBUG_PRINT(...) {}
	#define DEBUG_PRINTLN(...) {}
#endif

#ifdef PCF8574_LOW_LATENCY
	#define READ_ELAPSED_TIME 0
#else
	#define READ_ELAPSED_TIME 10
#endif

//#define P0  	B00000001
//#define P1  	B00000010
//#define P2  	B00000100
//#define P3  	B00001000
//#define P4  	B00010000
//#define P5  	B00100000
//#define P6  	B01000000
//#define P7  	B10000000
//
#define P0  	0
#define P1  	1
#define P2  	2
#define P3  	3
#define P4  	4
#define P5  	5
#define P6  	6
#define P7  	7

#include <math.h>


class PCF8574 {
public:

	PCF8574(uint8_t address);
	PCF8574(uint8_t address, uint8_t interruptPin,  void (*interruptFunction)() );

#if !defined(__AVR) && !defined(ARDUINO_ARCH_SAMD) && !defined(TEENSYDUINO) && !defined(ARDUINO_ARCH_RENESAS)
	PCF8574(uint8_t address, int sda, int scl);
	PCF8574(uint8_t address, int sda, int scl, uint8_t interruptPin,  void (*interruptFunction)());
#endif

#if defined(ESP32) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_RENESAS)
	///// changes for second i2c bus
	PCF8574(TwoWire *pWire, uint8_t address);
	PCF8574(TwoWire *pWire, uint8_t address, uint8_t interruptPin,  void (*interruptFunction)() );
#endif
#if defined(ESP32)
	PCF8574(TwoWire *pWire, uint8_t address, int sda, int scl);
	PCF8574(TwoWire *pWire, uint8_t address, int sda, int scl, uint8_t interruptPin,  void (*interruptFunction)());
#endif

	bool begin();
	bool begin(uint8_t address);
	void pinMode(uint8_t pin, uint8_t mode, uint8_t output_start = HIGH);

	void encoder(uint8_t pinA, uint8_t pinB);

	void attachInterrupt();
	void detachInterrupt();

	void readBuffer(bool force = true);
	uint8_t digitalRead(uint8_t pin, bool forceReadNow = false);
	#ifndef PCF8574_LOW_MEMORY
		struct DigitalInput {
			uint8_t p0;
			uint8_t p1;
			uint8_t p2;
			uint8_t p3;
			uint8_t p4;
			uint8_t p5;
			uint8_t p6;
			uint8_t p7;
		} digitalInput;


		DigitalInput digitalReadAll(void);

		bool digitalWriteAll(PCF8574::DigitalInput digitalInput);
	#else
		byte digitalReadAll(void);
		bool digitalWriteAll(byte digitalInput);
	#endif
	bool digitalWrite(uint8_t pin, uint8_t value);

#ifdef MISCHIANTI_ENCODER_ALGORITHM
	bool readEncoderValueMischianti(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation = false);
	int8_t readEncoderValueMischianti(uint8_t pinA, uint8_t pinB);
#endif
#ifdef POKI_ENCODER_ALGORITHM
	bool readEncoderValuePoki(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation = false);
	int8_t readEncoderValuePoki(uint8_t pinA, uint8_t pinB);
#endif

//	bool readEncoderValueEvolved(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation = false);
//	int8_t readEncoderValueEvolved(uint8_t pinA, uint8_t pinB);

#ifdef SEQUENCE_ENCODER_ALGORITHM
	bool readEncoderValueSequence(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation = false);
	int8_t readEncoderValueSequence(uint8_t pinA, uint8_t pinB);
#endif
#ifdef SEQUENCE_ENCODER_ALGORITHM_REDUCED
	bool readEncoderValueSequenceReduced(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation = false);
	int8_t readEncoderValueSequenceReduced(uint8_t pinA, uint8_t pinB);
#endif
#ifdef BASIC_ENCODER_ALGORITHM
	bool readEncoderValue(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation = false);
	int8_t readEncoderValue(uint8_t pinA, uint8_t pinB);
#endif

	int getLatency() const {
		return latency;
	}

	void setLatency(int latency = READ_ELAPSED_TIME) {
		this->latency = latency;
	}

	uint8_t getTransmissionStatusCode() const {
		return transmissionStatus;
	}

	bool isLastTransmissionSuccess(){
		DEBUG_PRINT(F("STATUS --> "));
		DEBUG_PRINTLN(transmissionStatus);
		return transmissionStatus==0;
	}
private:
	uint8_t _address;

	#if !defined(DEFAULT_SDA)
	#  if defined(ARDUINO_ARCH_STM32)
	#    define DEFAULT_SDA PB7
	#  elif defined(ESP8266)
	#    define DEFAULT_SDA 4
	#  elif defined(SDA)
	#    define DEFAULT_SDA SDA
	#  else
	#    error "Error define DEFAULT_SDA, SDA not declared, if you have this error contact the mantainer"
	#  endif
	#endif
	#if !defined(DEFAULT_SCL)
	#  if defined(ARDUINO_ARCH_STM32)
	#    define DEFAULT_SCL PB6
	#  elif defined(ESP8266)
	#    define DEFAULT_SCL 5
	#  elif defined(SDA)
	#    define DEFAULT_SCL SCL
	#  else
	#    error "Error define DEFAULT_SCL, SCL not declared, if you have this error contact the mantainer"
	#  endif
	#endif

	int _sda = DEFAULT_SDA;
	int _scl = DEFAULT_SCL;

	TwoWire *_wire;

	bool _usingInterrupt = false;
	uint8_t _interruptPin = 2;
	void (*_interruptFunction)(){};

	byte writeMode 			= 	0b00000000;
	byte writeModeUp		= 	0b00000000;
	byte readMode 			= 	0b00000000;
	byte readModePullUp 	= 	0b00000000;
	byte readModePullDown 	= 	0b00000000;
	byte byteBuffered 		= 	0b00000000;
	byte resetInitial		= 	0b00000000;
	byte initialBuffer		= 	0b00000000;
	unsigned long lastReadMillis = 0;

	byte writeByteBuffered = 0b00000000;

	volatile byte encoderValues = 0b00000000;

	uint8_t prevNextCode = 0;
	uint16_t store=0;

	int latency = READ_ELAPSED_TIME;

	bool checkProgression(byte oldValA, byte newValA, byte oldValB, byte newValB, byte validProgression);

//	byte validCW = B11100001;
//	byte validCCW = B01001011;
	byte validCW = 0b01001011;
	byte validCCW = 0b11100001;

	uint8_t transmissionStatus = 0;

	void setVal(uint8_t pin, uint8_t value);
	bool digitalWriteAllBytes(byte allpins);
};

#endif




/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/




/*
 * PCF8574 GPIO Port Expand
 * https://www.mischianti.org/2019/01/02/pcf8574-i2c-digital-i-o-expander-fast-easy-usage/
 *
 * The MIT License (MIT)
 *
 * Copyright (c) 2017 Renzo Mischianti www.mischianti.org All right reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */


#include "Wire.h"

/**
 * Constructor
 * @param address: i2c address
 */
PCF8574::PCF8574(uint8_t address){
	_wire = &Wire;

	_address = address;
};

/**
 * Construcor
 * @param address: i2c address
 * @param interruptPin: pin to set interrupt
 * @param interruptFunction: function to call when interrupt raised
 */
PCF8574::PCF8574(uint8_t address, uint8_t interruptPin,  void (*interruptFunction)() ){
	_wire = &Wire;

	_address = address;
	_interruptPin = interruptPin;
	_interruptFunction = interruptFunction;
	_usingInterrupt = true;
};

#if !defined(__AVR) && !defined(ARDUINO_ARCH_SAMD) && !defined(TEENSYDUINO) && !defined(ARDUINO_ARCH_RENESAS)
	/**
	 * Constructor
	 * @param address: i2c address
	 * @param sda: sda pin
	 * @param scl: scl pin
	 */
	PCF8574::PCF8574(uint8_t address, int sda, int scl){
		_wire = &Wire;

		_address = address;
		_sda = sda;
		_scl = scl;
	};

	/**
	 * Constructor
	 * @param address: i2c address
	 * @param sda: sda pin
	 * @param scl: scl pin
	 * @param interruptPin: pin to set interrupt
 	 * @param interruptFunction: function to call when interrupt raised
	 */
	PCF8574::PCF8574(uint8_t address, int sda, int scl, uint8_t interruptPin,  void (*interruptFunction)() ){
		_wire = &Wire;

		_address = address;
		_sda = sda;
		_scl = scl;

		_interruptPin = interruptPin;
		_interruptFunction = interruptFunction;

		_usingInterrupt = true;
	};
#endif

#if defined(ESP32) || defined(ARDUINO_ARCH_SAMD)|| defined(ARDUINO_ARCH_RP2040)  || defined(ARDUINO_ARCH_STM32) || defined(ARDUINO_ARCH_RENESAS)
	/**
	 * Constructor
	 * @param address: i2c address
	 */
	PCF8574::PCF8574(TwoWire *pWire, uint8_t address){
		_wire = pWire;

		_address = address;
	};

	/**
	 * Construcor
	 * @param address: i2c address
	 * @param interruptPin: pin to set interrupt
	 * @param interruptFunction: function to call when interrupt raised
	 */
	PCF8574::PCF8574(TwoWire *pWire, uint8_t address, uint8_t interruptPin,  void (*interruptFunction)() ){
		_wire = pWire;

		_address = address;
		_interruptPin = interruptPin;
		_interruptFunction = interruptFunction;
		_usingInterrupt = true;
	};
#endif
#if defined(ESP32)
	/**
	 * Constructor
	 * @param address: i2c address
	 * @param sda: sda pin
	 * @param scl: scl pin
	 */
	PCF8574::PCF8574(TwoWire *pWire, uint8_t address, int sda, int scl){
		_wire = pWire;

		_address = address;
		_sda = sda;
		_scl = scl;
	};

	/**
	 * Constructor
	 * @param address: i2c address
	 * @param sda: sda pin
	 * @param scl: scl pin
	 * @param interruptPin: pin to set interrupt
	 * @param interruptFunction: function to call when interrupt raised
	 */
	PCF8574::PCF8574(TwoWire *pWire, uint8_t address, int sda, int scl, uint8_t interruptPin,  void (*interruptFunction)() ){
		_wire = pWire;

		_address = address;
		_sda = sda;
		_scl = scl;

		_interruptPin = interruptPin;
		_interruptFunction = interruptFunction;

		_usingInterrupt = true;
	};
#endif
	bool encoderPins[8];

	void PCF8574::attachInterrupt(){
		// If using interrupt set interrupt value to pin
		if (_usingInterrupt){
			for (int i = 0; i < 8;i++){
				if (encoderPins[i]) PCF8574::digitalRead(i);
			}
//			PCF8574::digitalReadAll();
//			(*_interruptFunction)();

	//		DEBUG_PRINTLN("Using interrupt pin (not all pin is interrupted)");
	//		::pinMode(_interruptPin, INPUT_PULLUP);
	//		attachInterrupt(digitalPinToInterrupt(_interruptPin), (*_interruptFunction), FALLING );
			DEBUG_PRINTLN("Using interrupt pin (not all pin is interrupted)");
			::pinMode(_interruptPin, INPUT_PULLUP);
			::attachInterrupt(digitalPinToInterrupt(_interruptPin), (*_interruptFunction), FALLING );
		}

	}
	void PCF8574::detachInterrupt(){
		// If using interrupt set interrupt value to pin
		if (_usingInterrupt){
			::detachInterrupt(digitalPinToInterrupt(_interruptPin));
			DEBUG_PRINTLN("Detach interrupt pin");
		}

	}

bool PCF8574::begin(uint8_t address){
	_address = address;
	return PCF8574::begin();
}


/**
 * wake up i2c controller
 */
bool PCF8574::begin(){
	this->transmissionStatus = 4;
	#if !defined(__AVR)  && !defined(ARDUINO_ARCH_SAMD)  && !defined(TEENSYDUINO) && !defined(ARDUINO_ARCH_RENESAS)
		DEBUG_PRINT(F("begin(sda, scl) -> "));DEBUG_PRINT(_sda);DEBUG_PRINT(F(" "));DEBUG_PRINTLN(_scl);
//		_wire->begin(_sda, _scl);
#ifdef ARDUINO_ARCH_STM32
		_wire->begin((uint32_t)_sda, (uint32_t)_scl);
#elif defined(ARDUINO_ARCH_RP2040)
		_wire->setSCL(_scl);
		_wire->setSDA(_sda);
		_wire->begin();
#else
		_wire->begin((int)_sda, (int)_scl);
#endif
	#else
	//			Default pin for AVR some problem on software emulation
	//			#define SCL_PIN _scl
	// 			#define SDA_PIN _sda
		_wire->begin();
	#endif

	// Check if there are pins to set low
	if (writeMode>0 || readMode>0){
		DEBUG_PRINTLN("Set write mode");
		_wire->beginTransmission(_address);


		DEBUG_PRINT("resetInitial pin ");
#ifdef PCF8574_SOFT_INITIALIZATION
		resetInitial = writeModeUp | readModePullUp;
#else
		resetInitial = writeModeUp | readMode;
#endif
		DEBUG_PRINTLN( resetInitial, BIN);

		_wire->write(resetInitial);

		initialBuffer = writeModeUp | readModePullUp;
		byteBuffered = initialBuffer;
		writeByteBuffered = writeModeUp;

		DEBUG_PRINTLN("Start end trasmission if stop here check pullup resistor.");
		this->transmissionStatus = _wire->endTransmission();
	}

//	// If using interrupt set interrupt value to pin
//	if (_usingInterrupt){
////		DEBUG_PRINTLN("Using interrupt pin (not all pin is interrupted)");
////		::pinMode(_interruptPin, INPUT_PULLUP);
////		attachInterrupt(digitalPinToInterrupt(_interruptPin), (*_interruptFunction), FALLING );
//		DEBUG_PRINTLN("Using interrupt pin (not all pin is interrupted)");
//		::pinMode(_interruptPin, INPUT_PULLUP);
//		::attachInterrupt(digitalPinToInterrupt(_interruptPin), (*_interruptFunction), FALLING );
//	}



	PCF8574::attachInterrupt();

	// inizialize last read
	lastReadMillis = millis();

	return this->isLastTransmissionSuccess();
}

/**
 * Set if fin is OUTPUT or INPUT
 * @param pin: pin to set
 * @param mode: mode, supported only INPUT or OUTPUT (to simplify)
 * @param output_start: output_start, for OUTPUT we can set initial value
 */
void PCF8574::pinMode(uint8_t pin, uint8_t mode, uint8_t output_start){
	DEBUG_PRINT("Set pin ");
	DEBUG_PRINT(pin);
	DEBUG_PRINT(" as ");
	DEBUG_PRINTLN(mode);

	if (mode == OUTPUT){
		writeMode = writeMode | bit(pin);
		if (output_start==HIGH) {
			writeModeUp = writeModeUp | bit(pin);
		}

		readMode =  readMode & ~bit(pin);
		readModePullDown 	=	readModePullDown 	& 	~bit(pin);
		readModePullUp 		=	readModePullUp 		& 	~bit(pin);

		DEBUG_PRINT("W: ");
		DEBUG_PRINT(writeMode, BIN);
		DEBUG_PRINT(" R ALL: ");
		DEBUG_PRINT(readMode, BIN);

		DEBUG_PRINT(" R Down: ");
		DEBUG_PRINT(readModePullDown, BIN);
		DEBUG_PRINT("R Up: ");
		DEBUG_PRINTLN(readModePullUp, BIN);

	}else if (mode == INPUT){
		writeMode = writeMode & ~bit(pin);

		readMode 			=   readMode 			| bit(pin);
		readModePullDown 	=	readModePullDown 	| bit(pin);
		readModePullUp 		=	readModePullUp 		& ~bit(pin);

		DEBUG_PRINT("W: ");
		DEBUG_PRINT(writeMode, BIN);
		DEBUG_PRINT(" R ALL: ");
		DEBUG_PRINT(readMode, BIN);

		DEBUG_PRINT(" R Down: ");
		DEBUG_PRINT(readModePullDown, BIN);
		DEBUG_PRINT("R Up: ");
		DEBUG_PRINTLN(readModePullUp, BIN);
	}else if (mode == INPUT_PULLUP){
		writeMode = writeMode & ~bit(pin);

		readMode 			=   readMode 			| bit(pin);
		readModePullDown 	=	readModePullDown 	& ~bit(pin);
		readModePullUp 		=	readModePullUp 		| bit(pin);

		DEBUG_PRINT("W: ");
		DEBUG_PRINT(writeMode, BIN);
		DEBUG_PRINT(" R ALL: ");
		DEBUG_PRINT(readMode, BIN);

		DEBUG_PRINT(" R Down: ");
		DEBUG_PRINT(readModePullDown, BIN);
		DEBUG_PRINT("R Up: ");
		DEBUG_PRINTLN(readModePullUp, BIN);
	}
	else{
		DEBUG_PRINTLN("Mode non supported by PCF8574")
	}
};


void PCF8574::encoder(uint8_t pinA, uint8_t pinB){
	PCF8574::pinMode(pinA, INPUT_PULLUP);
	PCF8574::pinMode(pinB, INPUT_PULLUP);

	encoderPins[pinA] = true;
	encoderPins[pinB] = true;
}

byte getBit(byte n, byte position)
{
   return (n >> position) & 1;
}


//int8_t PCF8574::readEncoderValue(uint8_t pinA, uint8_t pinB){
//	  bool changed = false;
//
//	  byte offset = 0;
//
//	  byte na = PCF8574::digitalRead(pinA);
//	  byte nb = PCF8574::digitalRead(pinB);
//
//	  byte encoderPinALast = (encoderValues & bit(pinA));
//	  byte encoderPinBLast = (encoderValues & bit(pinB));
//
//	  if ((encoderPinALast!=na || encoderPinBLast!=nb) && (encoderPinALast == LOW) && (na == HIGH)) {
//		if (nb == LOW) {
//			offset = - 1;
//			changed = true;
//		} else {
//			offset = + 1;
//			changed = true;
//		}
//	  }
//
//	  encoderValues = (encoderPinALast!=na)?encoderValues ^ bit(pinA):encoderValues;
//	  encoderValues = (encoderPinBLast!=nb)?encoderValues ^ bit(pinB):encoderValues;
//
//	  return offset;
//}

bool PCF8574::checkProgression(byte oldValA, byte oldValB, byte newValA, byte newValB, byte validProgression){
	bool findOldVal = false;
	int posFinded = 0;
	for (int pos = 0; pos<8; pos = pos + 2){
		if ((oldValB == ((validProgression & bit(pos+1))>0?HIGH:LOW)) && (oldValA == ((validProgression & bit(pos+0))>0?HIGH:LOW)) ){
			findOldVal = true;
			posFinded = pos;
		}
	}
	if (!findOldVal) return false;

	posFinded = posFinded + 2;
	if (posFinded>8) posFinded = 0;

	return ((newValB == ((validProgression & bit(posFinded+1))>0?HIGH:LOW)) && (newValA == ((validProgression & bit(posFinded+0))>0?HIGH:LOW)) );
}

#ifdef BASIC_ENCODER_ALGORITHM
	bool PCF8574::readEncoderValue(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation){
		PCF8574::detachInterrupt();

		  bool changed = false;

		  byte na = PCF8574::digitalRead(pinA, true);
		  byte nb = PCF8574::digitalRead(pinB, true);

		  byte encoderPinALast = (this->encoderValues & bit(pinA))>0?HIGH:LOW;
		  byte encoderPinBLast = (this->encoderValues & bit(pinB))>0?HIGH:LOW;

		  DEBUG_PRINT(pinA);
		  DEBUG_PRINT(" TO --> ");
		  DEBUG_PRINT(encoderPinALast);
		  DEBUG_PRINT(encoderPinBLast);
		  DEBUG_PRINT(" - ");
		  DEBUG_PRINT(na);
		  DEBUG_PRINT(nb);
		  DEBUG_PRINTLN();

		  if ((encoderPinALast!=na || encoderPinBLast!=nb) && (encoderPinALast == LOW) && (na == HIGH)) {
//			  bool vCW = checkProgression(encoderPinALast, encoderPinBLast, na, nb, validCW);
//			  bool vCCW = checkProgression(encoderPinALast, encoderPinBLast, na, nb, validCCW);

				if (nb == LOW) {
					*encoderValue = *encoderValue + (!reverseRotation?+1:-1);
					changed = true;
				} else {
					*encoderValue = *encoderValue + (!reverseRotation?-1:+1);
					changed = true;
				}

	//			if (nb == LOW && vCW) {
	//	//			checkCW(encoderPinALast, encoderPinBLast, na, nb);
	//				*encoderValue = *encoderValue - 1;
	//				changed = true;
	//			} else if (vCCW) {
	//				*encoderValue = *encoderValue + 1;
	//				changed = true;
	//			}

		  }

		  this->encoderValues = (encoderPinALast!=na)?this->encoderValues ^ bit(pinA):this->encoderValues;
		  this->encoderValues = (encoderPinBLast!=nb)?this->encoderValues ^ bit(pinB):this->encoderValues;
		  PCF8574::attachInterrupt();

			return changed;
	}
	int8_t PCF8574::readEncoderValue(uint8_t pinA, uint8_t pinB) {
		volatile long encoderValue = 0;
		PCF8574::readEncoderValue(pinA, pinB, &encoderValue);
		return encoderValue;
	}

#endif

#ifdef SEQUENCE_ENCODER_ALGORITHM
	bool PCF8574::readEncoderValueSequence(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation){

		PCF8574::detachInterrupt();
		  bool changed = false;

		  delay(100);
		  byte na = PCF8574::digitalRead(pinA, true);
		  byte nb = PCF8574::digitalRead(pinB, true);

		  byte encoderPinALast = (this->encoderValues & bit(pinA))>0?HIGH:LOW;
		  byte encoderPinBLast = (this->encoderValues & bit(pinB))>0?HIGH:LOW;

		  DEBUG_PRINT(pinA);
		  DEBUG_PRINT(" TO --> ");
		  DEBUG_PRINT(encoderPinALast);
		  DEBUG_PRINT(encoderPinBLast);
		  DEBUG_PRINT(" - ");
		  DEBUG_PRINT(na);
		  DEBUG_PRINT(nb);
		  DEBUG_PRINT(" -- ");

		  int encoded = (na << 1) | nb; //converting the 2 pin value to single number
		  int lastEncoded = (encoderPinALast << 1) | encoderPinBLast;
		  int sum  = (lastEncoded << 2) | encoded; //adding it to the previous encoded value

		  DEBUG_PRINT("sum - ");
		  DEBUG_PRINT(sum, BIN);

		  DEBUG_PRINT(" enc - ");
		  DEBUG_PRINT( *encoderValue);

			  if(
					  sum == 0b1101
					   || sum == 0b0100
					  || sum == 0b0010
					   || sum == 0b1011
					  ){
	//			  encoderValue ++;
				  *encoderValue = *encoderValue + (!reverseRotation?+1:-1);
				  changed = true;
			  }
			  if(
					  sum == 0b1110
					   || sum == 0b0111
					  || sum == 0b0001
					   || sum == 0b1000
					) {
				  *encoderValue = *encoderValue + (!reverseRotation?-1:+1);
				  changed = true;
	//			  encoderValue --;
			  }

		  DEBUG_PRINT(" enc next - ");
		  DEBUG_PRINTLN( *encoderValue);

		  this->encoderValues = (encoderPinALast!=na)?this->encoderValues ^ bit(pinA):this->encoderValues;
		  this->encoderValues = (encoderPinBLast!=nb)?this->encoderValues ^ bit(pinB):this->encoderValues;
		  PCF8574::attachInterrupt();
			return changed;
	}
	int8_t PCF8574::readEncoderValueSequence(uint8_t pinA, uint8_t pinB) {
		volatile long encoderValue = 0;
		PCF8574::readEncoderValueSequence(pinA, pinB, &encoderValue);
		return encoderValue;
	}

#endif
#ifdef SEQUENCE_ENCODER_ALGORITHM_REDUCED
	bool PCF8574::readEncoderValueSequenceReduced(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation){

		PCF8574::detachInterrupt();
		  bool changed = false;

		  delay(100);
		  byte na = PCF8574::digitalRead(pinA, true);
		  byte nb = PCF8574::digitalRead(pinB, true);

		  byte encoderPinALast = (this->encoderValues & bit(pinA))>0?HIGH:LOW;
		  byte encoderPinBLast = (this->encoderValues & bit(pinB))>0?HIGH:LOW;

		  DEBUG_PRINT(pinA);
		  DEBUG_PRINT(" TO --> ");
		  DEBUG_PRINT(encoderPinALast);
		  DEBUG_PRINT(encoderPinBLast);
		  DEBUG_PRINT(" - ");
		  DEBUG_PRINT(na);
		  DEBUG_PRINT(nb);
		  DEBUG_PRINT(" -- ");

		  int encoded = (na << 1) | nb; //converting the 2 pin value to single number
		  int lastEncoded = (encoderPinALast << 1) | encoderPinBLast;
		  int sum  = (lastEncoded << 2) | encoded; //adding it to the previous encoded value

		  DEBUG_PRINT("sum - ");
		  DEBUG_PRINT(sum, BIN);

		  DEBUG_PRINT(" enc - ");
		  DEBUG_PRINT( *encoderValue);

			  if(
					  sum == 0b1101
					  // || sum == 0b0100
					  || sum == 0b0010
					  // || sum == 0b1011
					  ){
	//			  encoderValue ++;
				  *encoderValue = *encoderValue + (!reverseRotation?+1:-1);
				  changed = true;
			  }
			  if(
					  sum == 0b1110
					  // || sum == 0b0111
					  || sum == 0b0001
					  // || sum == 0b1000
					) {
				  *encoderValue = *encoderValue + (!reverseRotation?-1:+1);
				  changed = true;
	//			  encoderValue --;
			  }

		  DEBUG_PRINT(" enc next - ");
		  DEBUG_PRINTLN( *encoderValue);

		  this->encoderValues = (encoderPinALast!=na)?this->encoderValues ^ bit(pinA):this->encoderValues;
		  this->encoderValues = (encoderPinBLast!=nb)?this->encoderValues ^ bit(pinB):this->encoderValues;
		  PCF8574::attachInterrupt();
			return changed;
	}
	int8_t PCF8574::readEncoderValueSequenceReduced(uint8_t pinA, uint8_t pinB) {
		volatile long encoderValue = 0;
		PCF8574::readEncoderValueSequenceReduced(pinA, pinB, &encoderValue);
		return encoderValue;
	}

#endif
#ifdef MISCHIANTI_ENCODER_ALGORITHM
	bool PCF8574::readEncoderValueMischianti(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation){
		PCF8574::detachInterrupt();
		  bool changed = false;

		  byte na = PCF8574::digitalRead(pinA, true);
		  byte nb = PCF8574::digitalRead(pinB, true);

		  byte encoderPinALast = (this->encoderValues & bit(pinA))>0?HIGH:LOW;
		  byte encoderPinBLast = (this->encoderValues & bit(pinB))>0?HIGH:LOW;

		  if ((encoderPinALast!=na || encoderPinBLast!=nb) && ((encoderPinALast == LOW) || encoderPinALast==encoderPinBLast) && (na == HIGH)) {
			  DEBUG_PRINT("TO --> ");
			  DEBUG_PRINT(encoderPinALast);
			  DEBUG_PRINT(encoderPinBLast);
			  DEBUG_PRINT(" - ");
			  DEBUG_PRINT(na);
			  DEBUG_PRINT(nb);
			  DEBUG_PRINTLN();

				if (nb == LOW && nb!=na) {
					*encoderValue = *encoderValue + (!reverseRotation?+1:-1);
					changed = true;
				} else if (nb==na && encoderPinALast==encoderPinBLast) {
					*encoderValue = *encoderValue + (!reverseRotation?-1:+1);
					changed = true;
				}
		  }
//		  encoderValues = encoderValues & (~(bit(pinA) | bit(pinB)));
//		  if (na == HIGH){
//			  encoderValues = encoderValues | bit(pinA);
//		  }
//		  if (nb == HIGH){
//			  encoderValues = encoderValues | bit(pinA);
//		  }

		  if (encoderPinALast!=na || encoderPinBLast!=nb){
		  this->encoderValues = (encoderPinALast!=na)?this->encoderValues ^ bit(pinA):this->encoderValues;
		  this->encoderValues = (encoderPinBLast!=nb)?this->encoderValues ^ bit(pinB):this->encoderValues;
		  }

		  PCF8574::attachInterrupt();
			return changed;
	}
	int8_t PCF8574::readEncoderValueMischianti(uint8_t pinA, uint8_t pinB) {
		volatile long encoderValue = 0;
		PCF8574::readEncoderValueMischianti(pinA, pinB, &encoderValue);
		return encoderValue;
	}

#endif
//#ifdef MISCHIANTI_ENCODER_ALGORITHM_EVOLVED
//	bool PCF8574::readEncoderValueEvolved(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation){
//		PCF8574::detachInterrupt();
//		  bool changed = false;
//
//		  byte na = PCF8574::digitalRead(pinA, true);
//		  byte nb = PCF8574::digitalRead(pinB, true);
//
//		  byte encoderPinALast = (this->encoderValues & bit(pinA))>0?HIGH:LOW;
//		  byte encoderPinBLast = (this->encoderValues & bit(pinB))>0?HIGH:LOW;
//
////		  Serial.print(pinA);
////		  Serial.print(" TO --> ");
////		  Serial.print(encoderPinALast);
////		  Serial.print(encoderPinBLast);
////		  Serial.print(" - ");
////		  Serial.print(na);
////		  Serial.print(nb);
//
//		  if (
//
//		  ((encoderPinALast!=na || encoderPinBLast!=nb) && ((encoderPinALast == LOW) || encoderPinALast==encoderPinBLast) && (na == HIGH))
//		  || ((encoderPinALast!=na || encoderPinBLast!=nb) && ((encoderPinALast == HIGH) || encoderPinALast==encoderPinBLast) && (na == LOW))
//			){
//			  DEBUG_PRINT("TO --> ");
//			  DEBUG_PRINT(encoderPinALast);
//			  DEBUG_PRINT(encoderPinBLast);
//			  DEBUG_PRINT(" - ");
//			  DEBUG_PRINT(na);
//			  DEBUG_PRINT(nb);
//			  DEBUG_PRINTLN();
//
////			  Serial.print (" <------ ");
//
//				if (nb == LOW && nb!=na) {
//					*encoderValue = *encoderValue + (!reverseRotation?+1:-1);
//					changed = true;
//				} else if (nb==na && encoderPinALast==encoderPinBLast) {
//					*encoderValue = *encoderValue + (!reverseRotation?-1:+1);
//					changed = true;
//				}
//		  }
////		  Serial.println();
////		  encoderValues = encoderValues & (~(bit(pinA) | bit(pinB)));
////		  if (na == HIGH){
////			  encoderValues = encoderValues | bit(pinA);
////		  }
////		  if (nb == HIGH){
////			  encoderValues = encoderValues | bit(pinA);
////		  }
//
//		  if (encoderPinALast!=na || encoderPinBLast!=nb){
//		  this->encoderValues = (encoderPinALast!=na)?this->encoderValues ^ bit(pinA):this->encoderValues;
//		  this->encoderValues = (encoderPinBLast!=nb)?this->encoderValues ^ bit(pinB):this->encoderValues;
//		  }
//
//		  PCF8574::attachInterrupt();
//			return changed;
//	}
//	int8_t PCF8574::readEncoderValueEvolved(uint8_t pinA, uint8_t pinB) {
//		volatile long encoderValue = 0;
//		PCF8574::readEncoderValueEvolved(pinA, pinB, &encoderValue);
//		return encoderValue;
//	}
//
//#endif

#ifdef POKI_ENCODER_ALGORITHM
	bool PCF8574::readEncoderValuePoki(uint8_t pinA, uint8_t pinB, volatile long *encoderValue, bool reverseRotation){
		  PCF8574::detachInterrupt();

		  bool changed = false;

		  byte na = PCF8574::digitalRead(pinA, true);
		  byte nb = PCF8574::digitalRead(pinB, true);

		  byte encoderPinALast = (this->encoderValues & bit(pinA))>0?HIGH:LOW;
		  byte encoderPinBLast = (this->encoderValues & bit(pinB))>0?HIGH:LOW;

		  DEBUG_PRINT("TO --> ");
		  DEBUG_PRINT(encoderPinALast);
		  DEBUG_PRINT(encoderPinBLast);
		  DEBUG_PRINT(" - ");
		  DEBUG_PRINT(na);
		  DEBUG_PRINT(nb);
		  DEBUG_PRINTLN();

		  if ((encoderPinALast!=na || encoderPinBLast!=nb) && ((encoderPinALast == LOW) || encoderPinALast==encoderPinBLast) && (na == HIGH)) {
			  DEBUG_PRINT("TO --> ");
			  DEBUG_PRINT(encoderPinALast);
			  DEBUG_PRINT(encoderPinBLast);
			  DEBUG_PRINT(" - ");
			  DEBUG_PRINT(na);
			  DEBUG_PRINT(nb);
			  DEBUG_PRINTLN();

			  if (na && !nb) {
					if (encoderPinBLast) {
						*encoderValue = *encoderValue + (!reverseRotation?+1:-1);
					} else {
						*encoderValue = *encoderValue  + (!reverseRotation?-1:+1);
					}
					changed = true;
				}
		  }

		  this->encoderValues = (encoderPinALast!=na)?this->encoderValues ^ bit(pinA):encoderValues;
		  this->encoderValues = (encoderPinBLast!=nb)?this->encoderValues ^ bit(pinB):encoderValues;
		  PCF8574::attachInterrupt();

			return changed;
	}
	int8_t PCF8574::readEncoderValuePoki(uint8_t pinA, uint8_t pinB) {
		volatile long encoderValue = 0;
		PCF8574::readEncoderValue(pinA, pinB, &encoderValue);
		return encoderValue;
	}

#endif


/**
 * Read value from i2c and bufferize it
 * @param force
 */
void PCF8574::readBuffer(bool force){
	if (millis() > PCF8574::lastReadMillis+latency || _usingInterrupt || force){
		_wire->requestFrom(_address,(uint8_t)1);// Begin transmission to PCF8574 with the buttons
		lastReadMillis = millis();
		if(_wire->available())   // If bytes are available to be recieved
		{
			byte iInput = _wire->read();// Read a byte
			  if ((iInput & readModePullDown)>0 and (~iInput & readModePullUp)>0){
//			  if ((iInput & readMode)>0){
				byteBuffered = (byteBuffered & ~readMode) | (byte)iInput;
			}
		}
	}
}

#ifndef PCF8574_LOW_MEMORY
	/**
	 * Read value of all INPUT pin
	 * Debounce read more fast than 10millis, non managed for interrupt mode
	 * @return
	 */
	PCF8574::DigitalInput PCF8574::digitalReadAll(void){
		DEBUG_PRINTLN("Read from buffer");
		_wire->requestFrom(_address,(uint8_t)1);// Begin transmission to PCF8574 with the buttons
		lastReadMillis = millis();
		if(_wire->available())   // If bytes are available to be recieved
		{
			  DEBUG_PRINTLN("Data ready");
			  byte iInput = _wire->read();// Read a byte

			  if ((readModePullDown & iInput)>0 or (readModePullUp & ~iInput)>0){
				  DEBUG_PRINT(" -------- CHANGE --------- ");
				  byteBuffered = (byteBuffered & ~readMode) | (byte)iInput;
			  }
		}

		DEBUG_PRINT("Buffer value ");
		DEBUG_PRINTLN(byteBuffered, BIN);

		if ((bit(0) & readMode)>0) digitalInput.p0 = ((byteBuffered & bit(0))>0)?HIGH:LOW;
		if ((bit(1) & readMode)>0) digitalInput.p1 = ((byteBuffered & bit(1))>0)?HIGH:LOW;
		if ((bit(2) & readMode)>0) digitalInput.p2 = ((byteBuffered & bit(2))>0)?HIGH:LOW;
		if ((bit(3) & readMode)>0) digitalInput.p3 = ((byteBuffered & bit(3))>0)?HIGH:LOW;
		if ((bit(4) & readMode)>0) digitalInput.p4 = ((byteBuffered & bit(4))>0)?HIGH:LOW;
		if ((bit(5) & readMode)>0) digitalInput.p5 = ((byteBuffered & bit(5))>0)?HIGH:LOW;
		if ((bit(6) & readMode)>0) digitalInput.p6 = ((byteBuffered & bit(6))>0)?HIGH:LOW;
		if ((bit(7) & readMode)>0) digitalInput.p7 = ((byteBuffered & bit(7))>0)?HIGH:LOW;

		if ((bit(0) & writeMode)>0) digitalInput.p0 = ((writeByteBuffered & bit(0))>0)?HIGH:LOW;
		if ((bit(1) & writeMode)>0) digitalInput.p1 = ((writeByteBuffered & bit(1))>0)?HIGH:LOW;
		if ((bit(2) & writeMode)>0) digitalInput.p2 = ((writeByteBuffered & bit(2))>0)?HIGH:LOW;
		if ((bit(3) & writeMode)>0) digitalInput.p3 = ((writeByteBuffered & bit(3))>0)?HIGH:LOW;
		if ((bit(4) & writeMode)>0) digitalInput.p4 = ((writeByteBuffered & bit(4))>0)?HIGH:LOW;
		if ((bit(5) & writeMode)>0) digitalInput.p5 = ((writeByteBuffered & bit(5))>0)?HIGH:LOW;
		if ((bit(6) & writeMode)>0) digitalInput.p6 = ((writeByteBuffered & bit(6))>0)?HIGH:LOW;
		if ((bit(7) & writeMode)>0) digitalInput.p7 = ((writeByteBuffered & bit(7))>0)?HIGH:LOW;

		//if ((byteBuffered & readModePullDown)>0 and (~byteBuffered & readModePullUp)>0){

//		byteBuffered = (resetInitial & readMode) | (byteBuffered  & ~readMode); //~readMode & byteBuffered;

		byteBuffered = (initialBuffer & readMode) | (byteBuffered  & ~readMode); //~readMode & byteBuffered;

			DEBUG_PRINT("Buffer hight value readed set readed ");
			DEBUG_PRINTLN(byteBuffered, BIN);
		//}
		DEBUG_PRINT("Return value ");
		return digitalInput;
	};
#else
	/**
	 * Read value of all INPUT pin in byte format for low memory usage
	 * Debounce read more fast than 10millis, non managed for interrupt mode
	 * @return
	 */
	byte PCF8574::digitalReadAll(void){
		DEBUG_PRINTLN("Read from buffer");
		_wire->requestFrom(_address,(uint8_t)1);// Begin transmission to PCF8574 with the buttons
		lastReadMillis = millis();
		if(_wire->available())   // If bytes are available to be recieved
		{
			  DEBUG_PRINTLN("Data ready");
			  byte iInput = _wire->read();// Read a byte

			  if ((readModePullDown & iInput)>0 or (readModePullUp & ~iInput)>0){
				  DEBUG_PRINT(" -------- CHANGE --------- ");
				  byteBuffered = (byteBuffered & ~readMode) | (byte)iInput;

			  }
		}

		DEBUG_PRINT("Buffer value ");
		DEBUG_PRINTLN(byteBuffered, BIN);

		byte byteRead = byteBuffered | writeByteBuffered;

		//if ((byteBuffered & readModePullDown)>0 and (~byteBuffered & readModePullUp)>0){
//			byteBuffered = (resetInitial & readMode) | (byteBuffered  & ~readMode); //~readMode & byteBuffered;
		byteBuffered = (initialBuffer & readMode) | (byteBuffered  & ~readMode); //~readMode & byteBuffered;
			DEBUG_PRINT("Buffer hight value readed set readed ");
			DEBUG_PRINTLN(byteBuffered, BIN);
		//}
		DEBUG_PRINT("Return value ");
		return byteRead;
	};
#endif

/**
 * Read value of specified pin
 * Debounce read more fast than 10millis, non managed for interrupt mode
 * @param pin
 * @return
 */
uint8_t PCF8574::digitalRead(uint8_t pin, bool forceReadNow){
	uint8_t value = (bit(pin) & readModePullUp)?HIGH:LOW;
	DEBUG_PRINT("Read pin ");
	DEBUG_PRINT (pin);
	// Check if pin already HIGH than read and prevent reread of i2c
//	DEBUG_PRINTLN("----------------------------------")
//	DEBUG_PRINT("readModePullUp   ");
//	DEBUG_PRINTLN(readModePullUp, BIN);
//	DEBUG_PRINT("readModePullDown ");
//	DEBUG_PRINTLN(readModePullDown, BIN);
//	DEBUG_PRINT("byteBuffered     ");
//	DEBUG_PRINTLN(byteBuffered, BIN);


	if ((((bit(pin) & (readModePullDown & byteBuffered))>0) or (bit(pin) & (readModePullUp & ~byteBuffered))>0 )){
		DEBUG_PRINTLN(" ...Pin already set");
		  if ((bit(pin) & byteBuffered)>0){
			  value = HIGH;
		  }else{
			  value = LOW;
		  }
	 }else if (forceReadNow || (millis() > PCF8574::lastReadMillis+latency)){
		 DEBUG_PRINT(" ...Read from buffer... ");
		  _wire->requestFrom(_address,(uint8_t)1);// Begin transmission to PCF8574 with the buttons
		  lastReadMillis = millis();
		  if(_wire->available())   // If bytes are available to be recieved
		  {
			  DEBUG_PRINTLN(" Data ready");
			  byte iInput = _wire->read();// Read a byte
			  DEBUG_PRINT("Input ");
			  DEBUG_PRINT((byte)iInput, BIN);

			  if ((readModePullDown & iInput)>0 or (readModePullUp & ~iInput)>0){
				  DEBUG_PRINT(" -------- CHANGE --------- ");
				  byteBuffered = (byteBuffered & ~readMode) | (byte)iInput;
				  if ((bit(pin) & byteBuffered)>0){
					  value = HIGH;
				  }else{
					  value = LOW;
				  }
//				  value = (bit(pin) & byteBuffered);
			  }
		  }
	}
	DEBUG_PRINT(" ..Buffer value ");
	DEBUG_PRINT(byteBuffered, BIN);
	// If HIGH set to low to read buffer only one time
	if ((bit(pin) & readModePullDown) and value==HIGH){
		byteBuffered = bit(pin) ^ byteBuffered;
		DEBUG_PRINT(" ...Buffer hight value readed set readed ");
		DEBUG_PRINT (byteBuffered, BIN);
	}else if ((bit(pin) & readModePullUp) and value==LOW){
		byteBuffered = bit(pin) ^ byteBuffered;
		DEBUG_PRINT(" ...Buffer low value readed set readed ");
		DEBUG_PRINT(byteBuffered, BIN);
	}else if(bit(pin) & writeByteBuffered){
		value = HIGH;
	}
	DEBUG_PRINT(" ...Return value ");
	DEBUG_PRINTLN(value);
	return value;
};

/**
 * Write on pin
 * @param pin
 * @param value
 */
bool PCF8574::digitalWrite(uint8_t pin, uint8_t value){
	DEBUG_PRINTLN("Begin trasmission");
	_wire->beginTransmission(_address);     //Begin the transmission to PCF8574
	DEBUG_PRINT("Value ");
	DEBUG_PRINT(value);
	DEBUG_PRINT(" Write data pre ");
	DEBUG_PRINT(writeByteBuffered, BIN);

	if (value==HIGH){
		writeByteBuffered = writeByteBuffered | bit(pin);
		byteBuffered  = writeByteBuffered | bit(pin);
	}else{
		writeByteBuffered = writeByteBuffered & ~bit(pin);
		byteBuffered  = writeByteBuffered & ~bit(pin);
	}
	DEBUG_PRINT("Write data ");
	DEBUG_PRINT(writeByteBuffered, BIN);
	DEBUG_PRINT(" for pin ");
	DEBUG_PRINT(pin);
	DEBUG_PRINT(" bin value ");
	DEBUG_PRINT(bit(pin), BIN);
	DEBUG_PRINT(" value ");
	DEBUG_PRINT(value);

	// writeByteBuffered = writeByteBuffered & (~writeMode & byteBuffered);
	byteBuffered = (writeByteBuffered & writeMode) | (resetInitial & readMode);

	// byteBuffered = (writeByteBuffered & writeMode) | (byteBuffered & readMode);
	DEBUG_PRINT(" byteBuffered ");
	DEBUG_PRINTLN(byteBuffered, BIN);

	DEBUG_PRINT("Going to write data ");
	DEBUG_PRINTLN(writeByteBuffered, BIN);

	_wire->write(byteBuffered);

	byteBuffered = (writeByteBuffered & writeMode) | (initialBuffer & readMode);

//	byteBuffered = (writeByteBuffered & writeMode) & (byteBuffered & readMode);
	DEBUG_PRINTLN("Start end trasmission if stop here check pullup resistor.");

	this->transmissionStatus = _wire->endTransmission();

	return this->isLastTransmissionSuccess();
};

#ifndef PCF8574_LOW_MEMORY
	/**
	 * Read value of all INPUT pin
	 * Debounce read more fast than 10millis, non managed for interrupt mode
	 * @return
	 */
	void PCF8574::setVal(uint8_t pin, uint8_t value){
		if (value==HIGH){
			writeByteBuffered = writeByteBuffered | bit(pin);
			byteBuffered  = writeByteBuffered | bit(pin);
		}else{
			writeByteBuffered = writeByteBuffered & ~bit(pin);
			byteBuffered  = writeByteBuffered & ~bit(pin);
		}

	}
	bool PCF8574::digitalWriteAll(PCF8574::DigitalInput digitalInput){

		setVal(P0, digitalInput.p0);
		setVal(P1, digitalInput.p1);
		setVal(P2, digitalInput.p2);
		setVal(P3, digitalInput.p3);
		setVal(P4, digitalInput.p4);
		setVal(P5, digitalInput.p5);
		setVal(P6, digitalInput.p6);
		setVal(P7, digitalInput.p7);

		return digitalWriteAllBytes(writeByteBuffered);
	}
#else
	bool PCF8574::digitalWriteAll(byte digitalInput){
		return digitalWriteAllBytes(digitalInput);
	}
#endif


bool PCF8574::digitalWriteAllBytes(byte allpins){
	_wire->beginTransmission(_address);     //Begin the transmission to PCF8574

	// writeByteBuffered = writeByteBuffered & (~writeMode & byteBuffered);
	writeByteBuffered = allpins;
	byteBuffered = (writeByteBuffered & writeMode) | (resetInitial & readMode);

	// byteBuffered = (writeByteBuffered & writeMode) | (byteBuffered & readMode);
	DEBUG_PRINT(" byteBuffered ");
	DEBUG_PRINTLN(byteBuffered, BIN);

	DEBUG_PRINT("Going to write data ");
	DEBUG_PRINTLN(writeByteBuffered, BIN);

	_wire->write(byteBuffered);

	byteBuffered = (writeByteBuffered & writeMode) | (initialBuffer & readMode);

//	byteBuffered = (writeByteBuffered & writeMode) & (byteBuffered & readMode);
	DEBUG_PRINTLN("Start end trasmission if stop here check pullup resistor.");

	this->transmissionStatus = _wire->endTransmission();

	return this->isLastTransmissionSuccess();

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/



/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/35430ead-63d8-4daf-8cb6-cb3ce71e7484 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  - No variables have been created, add cloud variables on the Thing Setup page
    to see them declared here

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

#define SDA_PIN 4
#define SCL_PIN 5
PCF8574 pcf8574(0x24); // Setando o endereço de memória PCF para os reles de saida


void setup() {

  Wire.begin(SDA_PIN, SCL_PIN);
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();


  
  pcf8574.pinMode(P0,OUTPUT);
  pcf8574.pinMode(P1,OUTPUT);
  pcf8574.pinMode(P2,OUTPUT);
  pcf8574.pinMode(P3,OUTPUT);
  pcf8574.pinMode(P4,OUTPUT);
  pcf8574.pinMode(P5,OUTPUT);
  pcf8574.pinMode(P6,OUTPUT);
  pcf8574.pinMode(P7,OUTPUT);

  Serial.print("Initi pcf8574...");
  if(pcf8574.begin()){
    Serial.println("OK");
  }else{
    Serial.println("KO");
  }
  
}

void loop() {
  ArduinoCloud.update();
  // Your code here 

  pcf8574.digitalWrite(P0,LOW);
  pcf8574.digitalWrite(P1,LOW);
  pcf8574.digitalWrite(P2,LOW);
  pcf8574.digitalWrite(P3,LOW);
  pcf8574.digitalWrite(P4,LOW);
  pcf8574.digitalWrite(P5,LOW);
  pcf8574.digitalWrite(P6,LOW);
  pcf8574.digitalWrite(P7,LOW);
  delay(5000);

  pcf8574.digitalWrite(P0,HIGH);
  delay(500);
  pcf8574.digitalWrite(P1,HIGH);
  delay(500);
  pcf8574.digitalWrite(P2,HIGH);
  delay(500);
  pcf8574.digitalWrite(P3,HIGH);
  delay(500);
  pcf8574.digitalWrite(P4,HIGH);
  delay(500);
  pcf8574.digitalWrite(P5,HIGH);
  delay(500);
  pcf8574.digitalWrite(P6,HIGH);
  delay(500);
  pcf8574.digitalWrite(P7,HIGH);
  delay(500);

  pcf8574.digitalWrite(P0,LOW);
  delay(1000);
  pcf8574.digitalWrite(P1,LOW);
  delay(1000);
  pcf8574.digitalWrite(P2,LOW);
  delay(1000);
  pcf8574.digitalWrite(P3,LOW);
  delay(1000);
  pcf8574.digitalWrite(P4,LOW);
  delay(1000);
  pcf8574.digitalWrite(P5,LOW);
  delay(1000);
  pcf8574.digitalWrite(P6,LOW);
  delay(1000);
  pcf8574.digitalWrite(P7,LOW);
  delay(1000);
    
}





}

So I was sure that the Web Editor is looking for the wrong library when I declare include PCFF8574.h. To make my code not too long, I took a library, deleted everything from it and pasted the library I needed in place of that library and called the custom library in my code and everything worked normally too. So this is a Web Editor error, I will close this post in a few days as I will wait for your response. As you are part of the Arduino team, will you report this error to the Arduino team or am I the one who has to report this error? I believe that other users will suffer from this problem if they haven't already.
I hope you understood my solution and that it can help other users.
Thanks for the help my friend

I performed the instructions I provided above and they work perfectly. So from the information I have right now, I don't have any evidence that there is any problem with Arduino Cloud Editor. It is as likely that you did not correctly follow the fairly complex instructions.

It will not be appropriate or productive to report a problem to the developers until we have verified that there is actually a problem.

If you are satisfied with your hacky solution of copying the library into the sketch, then I'm also satisfied and we can consider this concluded. But if you are interested in investigating the problem you are experiencing, then I will need you to provide some additional information:

  1. Create a new sketch in Arduino Cloud Editor.
  2. Replace the default content of the new sketch with your original sketch code, as you provided in post #1.
  3. Follow the instructions I provided in post #17 for this sketch. Make sure to read the instructions very carefully and follow them exactly.
    :exclamation: It is essential to perform step (8) correctly, and this one is a bit tricky. You MUST NOT select the "Latest (2.3.7)" item from the menu:

    Instead, select any of the other versions from the menu (e.g., "2.3.7"):
  4. Click the button in the Cloud Editor toolbar.
  5. Wait for the compilation to finish.

Hopefully the compilation will be successful this time. If not, please provide the full verbose output from a compilation. I'll provide instructions you can follow to do that:


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


  1. Click the "Settings" icon at the bottom left corner of the page:

    The "Settings" panel will open.
  2. Select the "Verbose output" radio button under the "Console verbosity" section of the "Settings" panel.
  3. Click the button in the Cloud Editor toolbar.
  4. Wait for the compilation to fail.
  5. If the black "Console" panel at the bottom of the Cloud Editor page is minimized, click the ˄ icon at the right side of the "Console" toolbar to expand it.
  6. Click the icon in the top right corner of the black "Console" panel at the bottom of the Cloud Editor page that looks like two pieces of paper ("Copy Console Output"):
  7. Open a forum reply here by clicking the "Reply" button.
  8. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  9. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the compilation output into the code block.
  10. Move the cursor outside of the code block markup before you add any additional text to your reply.
  11. Click the "Reply" button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.

Click here for attachment instructions

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:

    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

My friend there is a place in the library that is used <pcf8574.h> and I removed it from the library to make it work

Where exactly in the library? I just searched all the files in version 2.3.7 of the "PCF8574 library" library and there is no such thing. Of course there are several occurrences of "PCF8574.h" in the library, as should be expected since the library contains a file of that name. But <pcf8574.h> and "PCF8574.h" are two completely different things.

It is not necessary to remove anything from the library. As I explained, I was able to compile your sketch by simply performing the instructions I provided in post #17.