{"id":25111883,"url":"https://github.com/apadevices/apaphx_ads1015","last_synced_at":"2026-04-24T16:35:37.853Z","repository":{"id":274313609,"uuid":"922536776","full_name":"apadevices/APAPHX_ADS1015","owner":"apadevices","description":"Arduino library for pH and ORP/Redox measurements with non-blocking operation, two-point calibration, and error detection. Features configurable sampling, rolling averages, and range validation (pH 0-14, ORP 0-1000mV). Compatible with any pH/ORP analog circuits using ADS1015. No external dependencies besides Wire.h.","archived":false,"fork":false,"pushed_at":"2025-02-23T11:04:03.000Z","size":4351,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T10:18:16.236Z","etag":null,"topics":["ads1015","apa","apadevices","arduino","arduino-libraries","arduino-library","arduinolibrary","arudino","i2c","i2c-device","orp","ph","redox","sensor","sensors","water-quality","watertreatment"],"latest_commit_sha":null,"homepage":"https://www.facebook.com/APA.adm","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/apadevices.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":"2025-01-26T13:36:35.000Z","updated_at":"2025-02-23T11:04:07.000Z","dependencies_parsed_at":"2025-01-26T14:42:54.153Z","dependency_job_id":null,"html_url":"https://github.com/apadevices/APAPHX_ADS1015","commit_stats":null,"previous_names":["apadevices/apaphx_ads1015"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apadevices%2FAPAPHX_ADS1015","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apadevices%2FAPAPHX_ADS1015/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apadevices%2FAPAPHX_ADS1015/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apadevices%2FAPAPHX_ADS1015/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apadevices","download_url":"https://codeload.github.com/apadevices/APAPHX_ADS1015/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246794208,"owners_count":20834938,"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":["ads1015","apa","apadevices","arduino","arduino-libraries","arduino-library","arduinolibrary","arudino","i2c","i2c-device","orp","ph","redox","sensor","sensors","water-quality","watertreatment"],"created_at":"2025-02-08T01:28:25.825Z","updated_at":"2026-04-24T16:35:37.846Z","avatar_url":"https://github.com/apadevices.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# APADevices PHX ADS1015 Library\r\n\r\nArduino library for pH and ORP/Redox measurements using ADS1015 ADC with optional temperature compensation. Originally designed for APADevices PHX hardware but compatible with any pH/ORP analog circuits using ADS1015.\r\n\r\n## Features\r\n\r\n- Non-blocking operation with state machine design\r\n- Two-point calibration for both pH and ORP\r\n- **NEW: Temperature compensation for pH measurements (Pasco 2001 formula)**\r\n- Configurable sampling and filtering\r\n- Built-in error detection\r\n- Rolling average support\r\n- No external dependencies (uses only Wire.h)\r\n- pH range: 0-14 with validation\r\n- ORP range: 0-1000mV with validation (configurable)\r\n- Temperature range: 0-50°C (optimized for swimming pools)\r\n\r\n## Installation\r\n\r\n1. Download the library files\r\n2. Create folder `APAPHX_ADS1015` in your Arduino libraries directory\r\n3. Copy all files into the created folder\r\n4. Restart Arduino IDE\r\n\r\n## Hardware Setup\r\n\r\nConnect your ADS1015 to Arduino:\r\n- VDD to 3.3V or 5V\r\n- GND to GND\r\n- SCL to SCL (A5 on most Arduino boards)\r\n- SDA to SDA (A4 on most Arduino boards)\r\n- ADDR pin:\r\n  - GND for address 0x48\r\n  - VDD for address 0x49\r\n  - SDA for address 0x4A\r\n  - SCL for address 0x4B\r\n\r\n## Basic Usage\r\n\r\n```cpp\r\n#include \"APAPHX_ADS1015.h\"\r\n\r\n// Create instances\r\nADS1015 ads1015PH(ADDRESS_49);  // pH sensor\r\nADS1015 ads1015RX(ADDRESS_48);  // ORP sensor\r\n\r\nvoid setup() {\r\n    ads1015PH.begin();\r\n    ads1015RX.begin();\r\n\r\n    //Set preferred ADS gains aligned with your needs\r\n    ads1015PH.setGain(ADS1015_REG_SET_GAIN0_6_144V);\r\n    ads1015RX.setGain(ADS1015_REG_SET_GAIN1_4_096V);\r\n}\r\n\r\nvoid loop() {\r\n    // Configure pH reading\r\n    PHXConfig phConfig = {\r\n        .type = \"ph\",        // pH measurement\r\n        .samples = 100,      // samples per reading\r\n        .delay_ms = 10,      // delay between samples\r\n        .avg_buffer = 3      // rolling average size\r\n    };\r\n    \r\n    // Configure ORP reading\r\n    PHXConfig orpConfig = {\r\n        .type = \"rx\",        // ORP measurement\r\n        .samples = 100,      // samples per reading\r\n        .delay_ms = 10,      // delay between samples\r\n        .avg_buffer = 3      // rolling average size\r\n    };\r\n    \r\n    // Take pH reading\r\n    ads1015PH.startReading(phConfig);\r\n    while(ads1015PH.getState() != PHXState::IDLE) {\r\n        ads1015PH.updateReading();\r\n    }\r\n    \r\n    // Take ORP reading\r\n    ads1015RX.startReading(orpConfig);\r\n    while(ads1015RX.getState() != PHXState::IDLE) {\r\n        ads1015RX.updateReading();\r\n    }\r\n    \r\n    float ph = ads1015PH.getLastReading();\r\n    float orp = ads1015RX.getLastReading();\r\n}\r\n```\r\n\r\n## Temperature Compensation (NEW!)\r\n\r\nTemperature compensation improves pH accuracy using the scientifically proven Pasco 2001 formula, perfect for swimming pool applications:\r\n\r\n### Basic Temperature Compensation\r\n```cpp\r\n// Enable temperature compensation\r\nads1015PH.enableTemperatureCompensation(true);\r\n\r\n// Set current temperature (in Celsius)\r\nads1015PH.setTemperature(28.5);  // Pool temperature\r\n\r\n// Take temperature-compensated reading\r\nPHXConfig config = {\"ph\", 100, 10, 3};\r\nads1015PH.startReading(config);\r\nwhile(ads1015PH.getState() != PHXState::IDLE) {\r\n    ads1015PH.updateReading();\r\n}\r\n\r\nfloat compensatedPH = ads1015PH.getLastReading();\r\n```\r\n\r\n### Temperature Compensation Methods\r\n```cpp\r\n// Enable/disable temperature compensation\r\nads1015PH.enableTemperatureCompensation(true);\r\n\r\n// Set current temperature (0-50°C range)\r\nads1015PH.setTemperature(25.4);\r\n\r\n// Get current temperature setting\r\nfloat temp = ads1015PH.getCurrentTemperature();\r\n\r\n// Check if compensation is enabled\r\nbool enabled = ads1015PH.isTemperatureCompensationEnabled();\r\n```\r\n\r\n### Benefits\r\n- **Improved accuracy**: ±0.1 pH improvement for temperature variations\r\n- **Swimming pool optimized**: Uses pool-specific Pasco 2001 formula\r\n- **Automatic normalization**: All readings referenced to 25°C standard\r\n- **Error handling**: Invalid temperatures (outside 0-50°C) are detected\r\n- **Backward compatible**: Disabled by default, doesn't affect existing code\r\n\r\n## Calibration\r\n\r\nTwo-point calibration is required for accurate readings:\r\n\r\n```cpp\r\n// pH Calibration (using pH 4 and 7 buffers by default, configurable)\r\nPHX_Calibration phCal;\r\n\r\n// First point (pH 4)\r\nphCal.ref1_mV = ads1015PH.calibratePHXReading(\"ph\");\r\nphCal.ref1_value = 4.0;\r\n\r\n// Second point (pH 7)\r\nphCal.ref2_mV = ads1015PH.calibratePHXReading(\"ph\");\r\nphCal.ref2_value = 7.0;\r\n\r\nads1015PH.calibratePHX(\"ph\", phCal);\r\n\r\n// ORP Calibration (using 475mV and 650mV solution buffers by default)\r\nPHX_Calibration orpCal;\r\norpCal.ref1_mV = ads1015RX.calibratePHXReading(\"rx\");\r\norpCal.ref1_value = 475.0;\r\norpCal.ref2_mV = ads1015RX.calibratePHXReading(\"rx\");\r\norpCal.ref2_value = 650.0;\r\nads1015RX.calibratePHX(\"rx\", orpCal);\r\n```\r\n\r\n**Note**: Temperature compensation is automatically disabled during calibration (correct behavior).\r\n\r\n## Error Handling\r\n\r\n```cpp\r\nPHXError error = sensor.getLastError();\r\nswitch(error) {\r\n    case PHXError::NONE: break;\r\n    case PHXError::PH_LOW: // pH below 0\r\n    case PHXError::PH_HIGH: // pH above 14\r\n    case PHXError::ORP_LOW: // ORP below 0mV\r\n    case PHXError::ORP_HIGH: // ORP above 1000mV\r\n    case PHXError::TEMP_INVALID: // Temperature outside 0-50°C range\r\n}\r\n```\r\n\r\n## Examples\r\n\r\nThe library includes five example sketches with a logical learning progression:\r\n\r\n1. **APAPHX_basic_example**: Simple continuous reading with calibration\r\n2. **APAPHX_intermediate_example**: Separate pH/ORP calibration with rolling average\r\n3. **APAPHX_advanced_example**: Full feature demonstration including error handling\r\n4. **APAPHX_basic_temperature_example**: Temperature compensation demonstration\r\n5. **APAPHX_eeprom_calsave_example**: Permanent calibration storage with automatic loading\r\n6. **APAPHX_chlorine_levels_example**: Extract approx. CL levels (ppm) based on messurements \r\n\r\n### Learning Progression\r\n\r\nThe progression makes sense for users:\r\n\r\n* Start with **Basic** to understand core functionality\r\n* Move to **Intermediate** for better control and rolling averages\r\n* Use **Advanced** for production applications with full error handling\r\n* Add **Basic Temperature** to learn temperature compensation\r\n* Implement **EEPROM CalSave** for permanent, professional installations\r\n\r\nThe EEPROM CalSave example represents the most complete solution - a professional pH/ORP monitoring system that remembers its calibration permanently and handles all edge cases. This would be perfect for swimming pool controllers, aquarium systems, or any application where the device needs to work immediately after power cycles without manual recalibration.\r\n\r\n## Available Gain Settings\r\n\r\n- `ADS1015_REG_SET_GAIN0_6_144V`: ±6.144V (recommended for APA Devices pH module and classic pH analog modules)\r\n- `ADS1015_REG_SET_GAIN1_4_096V`: ±4.096V (recommended for APA Device ORP module) \r\n- `ADS1015_REG_SET_GAIN2_2_048V`: ±2.048V\r\n- `ADS1015_REG_SET_GAIN4_1_024V`: ±1.024V\r\n- `ADS1015_REG_SET_GAIN8_0_512V`: ±0.512V\r\n- `ADS1015_REG_SET_GAIN16_0_256V`: ±0.256V\r\n\r\n## Version History\r\n\r\n### v1.1.0 (Current)\r\n- Added temperature compensation using Pasco 2001 formula\r\n- Added temperature error handling (TEMP_INVALID)\r\n- Optimized for swimming pool applications\r\n- Backward compatible with v1.0.0\r\n- EEPROM example added\r\n- Chlorine examples added\r\n\r\n### v1.0.0\r\n- Initial release\r\n- Basic pH/ORP measurements\r\n- Two-point calibration\r\n- Non-blocking operation\r\n\r\n## License\r\n\r\nThis library is released under the MIT License.\r\n\r\n## Author\r\n\r\nauthor=APADevices \u003cjaroslav@vazac.eu\u003e\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n## Support\r\n\r\n\r\nNo support included! Use as is or leave it. Sorry about that.\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapadevices%2Fapaphx_ads1015","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapadevices%2Fapaphx_ads1015","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapadevices%2Fapaphx_ads1015/lists"}