{"id":18837036,"url":"https://github.com/xreef/pcf8575_library","last_synced_at":"2025-04-12T14:33:07.618Z","repository":{"id":41204643,"uuid":"196991398","full_name":"xreef/PCF8575_library","owner":"xreef","description":"i2c 16bits digital expander with i2c digital expander for Arduino, Raspberry Pi Pico and rp2040 boards, esp32, SMT32 and ESP8266. Can read write digital values with only 2 wire. Very simple and encoder support. Uncommet NOT_SEQUENTIAL_PINOUT define to have pins like datasheet and not sequential one.","archived":false,"fork":false,"pushed_at":"2024-05-12T06:59:47.000Z","size":2093,"stargazers_count":61,"open_issues_count":0,"forks_count":21,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-26T09:05:22.463Z","etag":null,"topics":["16bit","arduino","arduino-library","digital","esp32","esp8266","expander","i2c","library","pin","wire"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xreef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-15T12:08:31.000Z","updated_at":"2025-03-05T04:59:13.000Z","dependencies_parsed_at":"2024-02-01T19:08:31.656Z","dependency_job_id":"bd7f2995-61b6-4667-a421-419f26d4cf59","html_url":"https://github.com/xreef/PCF8575_library","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xreef%2FPCF8575_library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xreef%2FPCF8575_library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xreef%2FPCF8575_library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xreef%2FPCF8575_library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xreef","download_url":"https://codeload.github.com/xreef/PCF8575_library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248581357,"owners_count":21128155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["16bit","arduino","arduino-library","digital","esp32","esp8266","expander","i2c","library","pin","wire"],"created_at":"2024-11-08T02:33:23.461Z","updated_at":"2025-04-12T14:33:07.596Z","avatar_url":"https://github.com/xreef.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv\u003e\n\u003ca href=\"https://www.mischianti.org/forums/forum/mischiantis-libraries/pcf8575-16bits-i2c-digital-i-o-expander/\"\u003e\u003cimg\n  src=\"https://github.com/xreef/LoRa_E32_Series_Library/raw/master/resources/buttonSupportForumEnglish.png\" alt=\"Support forum pcf8575 English\"\n   align=\"right\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ca href=\"https://www.mischianti.org/it/forums/forum/le-librerie-di-mischianti/pcf8575-expander-digitale-i-o-i2c-a-16bits/\"\u003e\u003cimg\n  src=\"https://github.com/xreef/LoRa_E32_Series_Library/raw/master/resources/buttonSupportForumItaliano.png\" alt=\"Forum supporto pcf8575 italiano\"\n  align=\"right\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n###Additional information and document update here on my site: [pcf8575 Article](https://www.mischianti.org/2019/07/22/pcf8575-i2c-16-bit-digital-i-o-expander/).\n\n###If you need less pins [here](https://www.mischianti.org/2019/01/02/pcf8574-i2c-digital-i-o-expander-fast-easy-usage/) you can find pcf8574 discrete 8bit version of the IC.\n\nLibrary to use i2c analog IC with arduino and esp8266. Can read and write digital value with only 2 wire (perfect for ESP-01).\n\n - 30/04/2024: v2.0.0 Manage INPUT_PULLUP, LOW latency mode, support Arduino UNO R4 and initial OUTPUT value\n - 01/02/2024: v1.1.2 Add the possibility to insert address at begin() function and return status of begin operation\n - 10/07/2023: v1.1.1 Add support for Arduino UNO R4\n - 16/02/2023: v1.1.0 \n    - Fix STM32 support and add support for Raspberry Pi Pico and other rp2040 boards\n    - Add support for custom SERCOM interface of Arduino SAMD devices. Force SDA SCL to use GPIO numeration for STM32 bug (https://www.mischianti.org/forums/topic/compatible-with-stm32duino/). \n    - Force SDA SCL to use GPIO numeration (https://www.mischianti.org/forums/topic/cannot-set-sda-clk-on-esp8266/).\n    - Fix the SDA SCL type #58 and add basic support for SAMD device.\n - 06/04/2022: v1.0.3 Fix package size\n\nTutorial: \n\nTo download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder PCF8575. Check that the PCF8575 folder contains `PCF8575\\\\.cpp` and `PCF8575.h`. Place the DHT library folder your `\u003carduinosketchfolder\u003e/libraries/` folder. You may need to create the libraries subfolder if its your first library. Restart the IDE.\n\n# Reef complete PCF8575 PCF8575AP digital input and output expander with i2c bus.\nI try to simplify the use of this IC, with a minimal set of operation.\n\nPCF8575 address map 0x20 default\n\nConstructor:\nyou must pas the address of i2c (to check the adress use this guide [I2cScanner](https://playground.arduino.cc/Main/I2cScanner)) \n```cpp\n\tPCF8575(uint8_t address);\n```\nfor esp8266 if you want specify SDA e SCL pin use this:\n\n```cpp\n\tPCF8575(uint8_t address, uint8_t sda, uint8_t scl);\n```\nYou must set input/output mode:\n```cpp\n\tpcf8575.pinMode(P0, OUTPUT);\n\tpcf8575.pinMode(P1, INPUT);\n\tpcf8575.pinMode(P2, INPUT);\n```\n\nthen IC as you can see in the image have 8 digital input/output:\n\n![PCF8575 schema](https://github.com/xreef/PCF8575_library/blob/master/resources/PCF8575-pins.gif)\n\nSo to read all analog input in one trasmission you can do (even if I use  a 10millis debounce time to prevent too much read from i2c):\n```cpp\n\tPCF8575::DigitalInput di = PCF8575.digitalReadAll();\n\tSerial.print(di.p0);\n\tSerial.print(\" - \");\n\tSerial.print(di.p1);\n\tSerial.print(\" - \");\n\tSerial.print(di.p2);\n\tSerial.print(\" - \");\n\tSerial.println(di.p3);\n```\n\nTo follow a request (you can see It on [issue #5](https://github.com/xreef/PCF8575_library/issues/5)) I create a define variable to work with low memori device, if you decomment this line on .h file of the library:\n\n```cpp\n// #define PCF8575_LOW_MEMORY\n```\n\nEnable low memory props and gain about 7byte of memory, and you must use the method to read all like so:\n\n ```cpp\n\tbyte di = pcf8575.digitalReadAll();\n\tSerial.print(\"READ VALUE FROM PCF: \");\n\tSerial.println(di, BIN);\n```\n\nwhere di is a byte like 11100011110001, so you must do a bitwise operation to get the data, operation that I already do in the \"normal\" mode, here an example:\n\n ```cpp\n\tp0 = ((di \u0026 bit(0))\u003e0)?HIGH:LOW;\n\tp1 = ((di \u0026 bit(1))\u003e0)?HIGH:LOW;\n\tp2 = ((di \u0026 bit(2))\u003e0)?HIGH:LOW;\n\tp3 = ((di \u0026 bit(3))\u003e0)?HIGH:LOW;\n\tp4 = ((di \u0026 bit(4))\u003e0)?HIGH:LOW;\n\tp5 = ((di \u0026 bit(5))\u003e0)?HIGH:LOW;\n\tp6 = ((di \u0026 bit(6))\u003e0)?HIGH:LOW;\n\tp7 = ((di \u0026 bit(7))\u003e0)?HIGH:LOW;\n ```\n \n\nif you want read a single input:\n\n```cpp\n\tint p1Digital = PCF8575.digitalRead(P1); // read P1\n```\n\nIf you want write a digital value you must do:\n```cpp\n\tPCF8575.digitalWrite(P1, HIGH);\n```\nor:\n```cpp\n\tPCF8575.digitalWrite(P1, LOW);\n```\n\nYou can also use interrupt pin:\nYou must initialize the pin and the function to call when interrupt raised from PCF8575\n```cpp\n\t// Function interrupt\nvoid keyPressedOnPCF8575();\n\n// Set i2c address\nPCF8575 pcf8575(0x39, ARDUINO_UNO_INTERRUPT_PIN, keyPressedOnPCF8575);\n```\nRemember you can't use Serial or Wire on interrupt function.\n\nThe better way is to set only a variable to read on loop:\n```cpp\nvoid keyPressedOnPCF8575(){\n\t// Interrupt called (No Serial no read no wire in this function, and DEBUG disabled on PCF library)\n\t keyPressed = true;\n}\n```\n\nFor the examples I use this wire schema on breadboard:\n![Breadboard](https://www.mischianti.org/wp-content/uploads/2019/07/Arduino-pcf8575-module-wiring-schema-button-led.jpg)\n\n[![Test pcf8575](https://img.youtube.com/vi/jWeHzBLeN6s/0.jpg)](https://youtu.be/jWeHzBLeN6s \"Test pcf8575\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxreef%2Fpcf8575_library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxreef%2Fpcf8575_library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxreef%2Fpcf8575_library/lists"}