{"id":18822880,"url":"https://github.com/tobymurray/esp32-ads1115","last_synced_at":"2026-05-07T05:33:44.539Z","repository":{"id":78725155,"uuid":"206993244","full_name":"tobymurray/ESP32-ads1115","owner":"tobymurray","description":"Use ESP-IDF to read an ADS1115","archived":false,"fork":false,"pushed_at":"2019-10-15T02:14:11.000Z","size":14,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-30T04:18:33.473Z","etag":null,"topics":["ads1115","c","esp-idf","esp32","espressif"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tobymurray.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-09-07T16:12:14.000Z","updated_at":"2022-03-01T12:47:58.000Z","dependencies_parsed_at":"2023-04-12T21:20:13.437Z","dependency_job_id":null,"html_url":"https://github.com/tobymurray/ESP32-ads1115","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobymurray%2FESP32-ads1115","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobymurray%2FESP32-ads1115/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobymurray%2FESP32-ads1115/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tobymurray%2FESP32-ads1115/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tobymurray","download_url":"https://codeload.github.com/tobymurray/ESP32-ads1115/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239758889,"owners_count":19692041,"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":["ads1115","c","esp-idf","esp32","espressif"],"created_at":"2024-11-08T00:51:57.899Z","updated_at":"2026-01-19T05:30:19.452Z","avatar_url":"https://github.com/tobymurray.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# I2C Self-Test Example\n\n(See the README.md file in the upper level 'examples' directory for more information about examples.)\n\n## Overview\n\nThis example demonstrates basic usage of I2C driver by running two tasks on I2C bus:\n\n1. Read external I2C sensor, here we take the BH1750 ambient light sensor (GY-30 module) for an example.\n2. Use one of ESP32’s I2C port (master mode) to read and write another I2C port (slave mode) in ESP32.\n\nIf you have a new I2C application to go (for example, read the temperature data from external sensor with I2C interface), try this as a basic template, then add your own code.\n\n## How to use example\n\n### Hardware Required\n\nTo run this example, you should have one ESP32 dev board (e.g. ESP32-WROVER Kit) or ESP32 core board (e.g. ESP32-DevKitC). Optionally, you can also connect an external sensor, here we choose the BH1750 just for an example. BH1750 is a digital ambient light sensor, for more information about it, you can read the [PDF](http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1721fvc-e.pdf) of this sensor.\n\n#### Pin Assignment:\n\n**Note:** The following pin assignments are used by default, yout can change these  in the `menuconfig` .\n\n|                  | SDA    | SCL    |\n| ---------------- | ------ | ------ |\n| ESP32 I2C Master | GPIO18 | GPIO19 |\n| ESP32 I2C Slave  | GPIO25 | GPIO26 |\n| BH1750 Sensor    | SDA    | SCL    |\n\n- slave:\n  - GPIO25 is assigned as the data signal of I2C slave port\n  - GPIO26 is assigned as the clock signal of I2C slave port\n- master:\n  - GPIO18 is assigned as the data signal of I2C master port\n  - GPIO19 is assigned as the clock signal of I2C master port\n\n- Connection:\n  - connect GPIO18 with GPIO25\n  - connect GPIO19 with GPIO26\n  - connect SDA/SCL of BH1750 sensor with GPIO18/GPIO19\n\n**Note: ** There’s no need to add an external pull-up resistors for SDA/SCL pin, because the driver will enable the internal pull-up resistors.\n\n### Configure the project\n\nOpen the project configuration menu (`idf.py menuconfig`). Then go into `Example Configuration` menu.\n\n- In the `I2C Master` submenu, you can set the pin number of SDA/SCL according to your board. Also you can modify the I2C port number and freauency of the master.\n- In the `I2C Slave` submenu, you can set the pin number of SDA/SCL according to your board. Also you can modify the I2C port number and address of the slave.\n- In the `BH1750 Sensor` submenu, you can choose the slave address of BH1750 accroding to the pin level of ADDR pin (if the pin level of ADDR is low then the address is `0x23`, otherwise it is `0x5c`). Here you can also control the operation mode of BH1750, each mode has a different resolution and measurement time. For example, in the `One Time L-Resolution` mode, the resolution is 4 Lux and measurement time is typically 16ms (higher resolution means longer measurement time). For more information, you can consult the datasheet of BH1750.\n\n\n### Build and Flash\n\nEnter `idf.py -p PORT flash monitor` to build, flash and monitor the project.\n\n(To exit the serial monitor, type ``Ctrl-]``.)\n\nSee the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects.\n\n## Example Output\n\n```bash\nI (6495) i2c-example: TASK[1] test cnt: 1\n*******************\nTASK[1]  MASTER READ SENSOR( BH1750 )\n*******************\ndata_h: 01\ndata_l: d0\nsensor val: 386.67 [Lux]\nI (6695) i2c-example: TASK[0] test cnt: 2\n*******************\nTASK[0]  MASTER READ SENSOR( BH1750 )\n*******************\ndata_h: 01\ndata_l: d0\nsensor val: 386.67 [Lux]\n*******************\nTASK[0]  MASTER READ FROM SLAVE\n*******************\n====TASK[0] Slave buffer data ====\n00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f \n10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f \n20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f \n30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f \n40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f \n50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f \n60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f \n70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f \n\n====TASK[0] Master read ====\n00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f \n10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f \n20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f \n30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f \n40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f \n50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f \n60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f \n70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f \n\n*******************\nTASK[1]  MASTER READ FROM SLAVE\n*******************\n====TASK[1] Slave buffer data ====\n00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f \n10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f \n20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f \n30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f \n40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f \n50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f \n60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f \n70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f \n\n====TASK[1] Master read ====\n00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f \n10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f \n20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f \n30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f \n40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f \n50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f \n60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f \n70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f \n\n*******************\nTASK[0]  MASTER WRITE TO SLAVE\n*******************\n----TASK[0] Master write ----\n0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 \n1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 \n2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 \n3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 \n4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 \n5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 \n6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 \n7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 \n\n----TASK[0] Slave read: [128] bytes ----\n0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 \n1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 \n2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37 38 39 \n3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 \n4a 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 \n5a 5b 5c 5d 5e 5f 60 61 62 63 64 65 66 67 68 69 \n6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 \n7a 7b 7c 7d 7e 7f 80 81 82 83 84 85 86 87 88 89 \n```\n\n## Troubleshooting\n\n- BH1750 has two I2C address, which is decided by the voltage level of `ADDR` pin at start up. Make sure to check your schemetic before run this example.\n\n(For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you as soon as possible.)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobymurray%2Fesp32-ads1115","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftobymurray%2Fesp32-ads1115","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftobymurray%2Fesp32-ads1115/lists"}