{"id":18837022,"url":"https://github.com/xreef/pcf8591_library","last_synced_at":"2025-04-14T06:21:42.645Z","repository":{"id":104294522,"uuid":"110146332","full_name":"xreef/PCF8591_library","owner":"xreef","description":"Library to use pcf8591 i2c analog IC with Arduino, Raspberry Pi Pico and rp2040 boards, esp32, SMT32 and ESP8266. Can read analog value and write analog value with only 2 wire.","archived":false,"fork":false,"pushed_at":"2024-02-01T17:32:20.000Z","size":7126,"stargazers_count":30,"open_issues_count":0,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T20:07:22.458Z","etag":null,"topics":["analog","arduino","arduino-library","esp-01","esp32","esp8266","expander","i2c","library","pcf8591","raspberry-pi","read","rp2040","stm32","write"],"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":"2017-11-09T17:34:05.000Z","updated_at":"2025-03-06T15:10:34.000Z","dependencies_parsed_at":"2024-02-01T19:11:15.531Z","dependency_job_id":"ece21d2d-ba6d-4063-8eb5-13ed4b45a063","html_url":"https://github.com/xreef/PCF8591_library","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xreef%2FPCF8591_library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xreef%2FPCF8591_library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xreef%2FPCF8591_library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xreef%2FPCF8591_library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xreef","download_url":"https://codeload.github.com/xreef/PCF8591_library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830895,"owners_count":21168364,"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":["analog","arduino","arduino-library","esp-01","esp32","esp8266","expander","i2c","library","pcf8591","raspberry-pi","read","rp2040","stm32","write"],"created_at":"2024-11-08T02:33:20.364Z","updated_at":"2025-04-14T06:21:42.613Z","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/pcf8591-i2c-analog-expander/\"\u003e\u003cimg\n  src=\"https://github.com/xreef/LoRa_E32_Series_Library/raw/master/resources/buttonSupportForumEnglish.png\" alt=\"Support forum pcf8591 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/pcf8591-expander-analogico-i2c/\"\u003e\u003cimg\n  src=\"https://github.com/xreef/LoRa_E32_Series_Library/raw/master/resources/buttonSupportForumItaliano.png\" alt=\"Forum supporto pcf8591 italiano\"\n  align=\"right\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\n#\n#\n\nYou can find updated version of documentation on my site​ [PCF8591](https://www.mischianti.org/2019/01/03/pcf8591-i2c-analog-i-o-expander/)\n\nLibrary to use i2c analog IC with arduino and esp8266. Can read analog value and write analog value with only 2 wire (perfect for ESP-01).\n\n - 01/02/2024: v1.1.2 Add the possibility to insert address at begin() function \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.2 Fix package size\n\nTutorial: \n\nTo download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder PCF8591. Check that the PCF8591 folder contains `PCF8591\\\\.cpp` and `PCF8591.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 PCF8591 Analog input and analog output to digital converter with i2c bus.\nI try to simplify the use of this IC, with a minimal set of operation.\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\tPCF8591(uint8_t address);\n```\nfor esp8266 if you want specify SDA e SCL pin use this:\n\n```cpp\n\tPCF8591(uint8_t address, uint8_t sda, uint8_t scl);\n```\n\nthen IC as you can see in the image have 4 analog input and 1 analog output:\n\n![PCF8591 schema](https://github.com/xreef/PCF8591_library/blob/master/resources/PCF8591-Pin-Outs.png)\n\nSo to read all analog input in one trasmission you can do (the value is from 0 to 255):\n```cpp\n\tPCF8591::AnalogInput ai = pcf8591.analogReadAll();\n\tSerial.print(ai.ain0);\n\tSerial.print(\" - \");\n\tSerial.print(ai.ain1);\n\tSerial.print(\" - \");\n\tSerial.print(ai.ain2);\n\tSerial.print(\" - \");\n\tSerial.println(ai.ain3);\n```\n\n\nif you want read a single analog input or channel:\n\n```cpp\n\tint ana = pcf8591.analogRead(AIN0); // read analog 0\n```\n\nThis IC have multiple type of read and you can use Analog input or analog channel (when you use single read analog input and channel are the same:\n\n![Channel selection](https://github.com/xreef/PCF8591_library/blob/master/resources/channel_selection.PNG)\t\n\nFor example to read the value of channel 0 in Two differential input you must do:\n```cpp\n\tint ana = pcf8591.analogRead(CHANNEL0, TWO_DIFFERENTIAL_INPUT); // read analog 0\n```\n\nIf you want write an analog value you must do (the value is from 0 to 255):\n```cpp\n\tpcf8591.analogWrite(128);\n```\n\nAdditional feature is to read a write voltage:\nFor the calculation of voltage you must pass some parameter:\n - microcontrollerReferenceVoltage: get voltage from microcontroller voltage (only AVR no esp8266 for esp 3.3v fixed)\n - referenceVoltage: if microcontrollerReferenceVoltage false take this value\n \n\nThe command are:\n```cpp\n\tvoid voltageWrite(float value, bool microcontrollerReferenceVoltage = true, float referenceVoltage = 5.0);\n\tfloat voltageRead(uint8_t analogPin, bool microcontrollerReferenceVoltage = true, float referenceVoltage = 5.0);\n```\n\nAn examples is:\n```cpp\n\tpcf8591.voltageWrite(2.7); // 2.7Volts output\n\tdelay(3000);\n\n\tfloat ana0V = pcf8591.voltageRead(AIN0); // Read voltage from analog 0\n\tSerial.println(ana0V);\n```\n\nFor the examples I use this wire schema on breadboard:\n![Breadboard](https://github.com/xreef/PCF8591_library/blob/master/resources/simpleschema_bb.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxreef%2Fpcf8591_library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxreef%2Fpcf8591_library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxreef%2Fpcf8591_library/lists"}