Skip to content

[apds9930]: Add sensor support#13125

Open
iyesin wants to merge 6 commits into
esphome:devfrom
iyesin:discussions/3459_add_support_for_apds9930
Open

[apds9930]: Add sensor support#13125
iyesin wants to merge 6 commits into
esphome:devfrom
iyesin:discussions/3459_add_support_for_apds9930

Conversation

@iyesin
Copy link
Copy Markdown

@iyesin iyesin commented Jan 10, 2026

Add support for APDS-9930 sensor (ambient light + proximity)

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Developer breaking change (an API change that could break external components)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

Pull request in esphome-docs with documentation (if applicable):

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx
  • nRF52840

Example entry for config.yaml:

external_components:
  - source: github://pr#13125
    components: [apds9930]
    refresh: 1h

i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true

apds9930:
  id: light_proximity_sensor
  address: 0x39
  update_interval: 60s
  led_drive: 100ma
  proximity_gain: 8x
  ambient_light_gain: 1x
  proximity_diode: 2

sensor:
  - platform: apds9930
    apds9930_id: light_proximity_sensor
    type: illuminance
    illuminance:
      name: "Living Room Illuminance"
      id: living_room_lux
      filters:
        - sliding_window_moving_average:
            window_size: 5
            send_every: 5
      on_value_range:
        - below: 50
          then:
            - light.turn_on: main_light
        - above: 200
          then:
            - light.turn_off: main_light

  - platform: apds9930
    apds9930_id: light_proximity_sensor
    type: proximity
    proximity:
      name: "Object Proximity"
      id: object_proximity
      filters:
        - throttle: 1s
      on_value_range:
        - above: 500
          then:
            - logger.log: "Object detected nearby"
            - switch.turn_on: proximity_alert
        - below: 100
          then:
            - switch.turn_off: proximity_alert

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@github-actions
Copy link
Copy Markdown
Contributor

To use the changes from this PR as an external component, add the following to your ESPHome configuration YAML file:

external_components:
  - source: github://pr#13125
    components: [apds9930]
    refresh: 1h

(Added by the PR bot)

esphome[bot]
esphome Bot previously requested changes Jan 10, 2026
Copy link
Copy Markdown
Contributor

@esphome esphome Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👥 Code Ownership

Hey there @iyesin,
Thanks for submitting this pull request! Can you add yourself as a codeowner for this integration? This way we can notify you if a bug report for this integration is reported.

In __init__.py of the integration, please add:

CODEOWNERS = ["@iyesin"]

And run script/build_codeowners.py

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.88%. Comparing base (091a05c) to head (a44c89a).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #13125   +/-   ##
=======================================
  Coverage   75.88%   75.88%           
=======================================
  Files          69       69           
  Lines       14599    14599           
  Branches     2107     2107           
=======================================
  Hits        11078    11078           
  Misses       3067     3067           
  Partials      454      454           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@esphome esphome Bot dismissed their stale review January 10, 2026 19:58

Review dismissed: All requirements have been met

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 10, 2026

Memory Impact Analysis

Components: apds9930
Platform: esp8266-ard

Metric Target Branch This PR Change
RAM 28,164 bytes 28,804 bytes 📈 🚨 +640 bytes (+2.27%)
Flash 275,311 bytes 287,183 bytes 📈 🚨 +11,872 bytes (+4.31%)
📊 Component Memory Breakdown
Component Target Flash PR Flash Change
[esphome]i2c 0 bytes 2,342 bytes 📈 🔸 +2,342 bytes (0.00%)
other 7,483 bytes 9,459 bytes 📈 +1,976 bytes (+26.41%)
[esphome]core 6,620 bytes 8,578 bytes 📈 🚨 +1,958 bytes (+29.58%)
[esphome]apds9930 0 bytes 1,610 bytes 📈 🔸 +1,610 bytes (0.00%)
[esphome]sensor 0 bytes 1,061 bytes 📈 🔸 +1,061 bytes (0.00%)
[lib]wire 0 bytes 643 bytes 📈 +643 bytes (0.00%)
app_framework 1,581 bytes 1,923 bytes 📈 +342 bytes (+21.63%)
wifi_stack 40,648 bytes 40,308 bytes 📉 -340 bytes (-0.84%)
power_mgmt 6,800 bytes 7,140 bytes 📈 +340 bytes (+5.00%)
misc_system 3,911 bytes 4,160 bytes 📈 +249 bytes (+6.37%)
interrupt_handlers 899 bytes 1,099 bytes 📈 +200 bytes (+22.25%)
wifi_config 2,489 bytes 2,672 bytes 📈 +183 bytes (+7.35%)
static_init 52 bytes 181 bytes 📈 +129 bytes (+248.08%)
arduino_core 2,336 bytes 2,392 bytes 📈 +56 bytes (+2.40%)
exception_handling 2,488 bytes 2,531 bytes 📈 +43 bytes (+1.73%)
memory_alloc 901 bytes 927 bytes 📈 +26 bytes (+2.89%)
esp_system 5,627 bytes 5,605 bytes 📉 -22 bytes (-0.39%)
wifi_phy_pp 2,926 bytes 2,948 bytes 📈 +22 bytes (+0.75%)
rom_functions 5,471 bytes 5,484 bytes 📈 +13 bytes (+0.24%)
error_handling 120 bytes 128 bytes 📈 +8 bytes (+6.67%)
... ... ... (1 more components not shown)
🔍 Symbol-Level Changes (click to expand)

Changed Symbols

Symbol Target Size PR Size Change
setup 206 bytes 548 bytes 📈 +342 bytes (+166.02%)
esphome::App 148 bytes 176 bytes 📈 +28 bytes (+18.92%)
[global constructor for: esphome::Application::register_component_(esphome::Component*)] 124 bytes 142 bytes 📈 +18 bytes (+14.52%)
esphome::esp8266::ESP8266Preferences::sync()::__pstr__ 15 bytes 7 bytes 📉 -8 bytes (-53.33%)
esphome::SchedulerNameLog::format(esphome::Scheduler::NameType, char const*, unsigned int)::__pstr__ 6 bytes 12 bytes 📈 +6 bytes (+100.00%)
setup::__pstr__ 12 bytes 9 bytes 📉 -3 bytes (-25.00%)

New Symbols (top 15)

Symbol Size
_vfprintf_r 899 bytes
pinMode 711 bytes
Twi::onTwipEvent(unsigned char) 464 bytes
esphome::i2c::ArduinoI2CBus::write_readv(unsigned char, unsigned char const*, unsigned int, unsig...esphome::i2c::ArduinoI2CBus::write_readv(unsigned char, unsigned char const*, unsigned int, unsigned char*, unsigned int)
380 bytes
esphome::i2c::ArduinoI2CBus::recover_() 363 bytes
esphome::apds9930::APDS9930::setup() 307 bytes
esphome::(anonymous namespace)::store_component_error_message(esphome::Component const*, char con...esphome::(anonymous namespace)::store_component_error_message(esphome::Component const*, char const*, bool)
252 bytes
esphome::apds9930::APDS9930::dump_config() 221 bytes
esphome::i2c::ArduinoI2CBus::dump_config() 221 bytes
esphome::apds9930::APDS9930::calculate_lux_(unsigned short, unsigned short) 219 bytes
std::pair<unsigned char, bool>& std::vector<std::pair<unsigned char, bool>, std::allocator<std::p...std::pair<unsigned char, bool>& std::vector<std::pair<unsigned char, bool>, std::allocator<std::pair<unsigned char, bool> > >::emplace_back<unsigned char&, bool>(unsigned char&, bool&&) [$isra$0]
200 bytes
Twi::readFrom(unsigned char, unsigned char*, unsigned int, unsigned char) 193 bytes
esphome::sensor::log_sensor(char const*, char const*, char const*, esphome::sensor::Sensor*) 179 bytes
esphome::format_hex_internal(char*, unsigned int, unsigned char const*, unsigned int, char, char)...esphome::format_hex_internal(char*, unsigned int, unsigned char const*, unsigned int, char, char) [$part$0]
174 bytes
twi 172 bytes
169 more new symbols... Total: 12,386 bytes

Removed Symbols (top 15)

Symbol Size
_vfiprintf_r 899 bytes
__pinMode 711 bytes
wifi_fpm_close 133 bytes
wifi_fpm_open 127 bytes
_vsnprintf_r 112 bytes
esp_delay 91 bytes
sprintf 89 bytes
_siprintf_r 82 bytes
wifi_fpm_do_wakeup 73 bytes
vprintf 63 bytes
__preloop_update_frequency 38 bytes
vsnprintf 32 bytes
vfiprintf 26 bytes
system_soft_wdt_feed 22 bytes
__loop_end 19 bytes
5 more removed symbols... Total: 2,538 bytes

Note: This analysis measures static RAM and Flash usage only (compile-time allocation).
Dynamic memory (heap) cannot be measured automatically.
⚠️ You must test this PR on a real device to measure free heap and ensure no runtime memory issues.

This analysis runs automatically when components change. Memory usage is measured from a representative test configuration.

@iyesin

This comment was marked as outdated.

@iyesin iyesin force-pushed the discussions/3459_add_support_for_apds9930 branch from e9b6d53 to 131a50a Compare January 11, 2026 18:59
@iyesin iyesin force-pushed the discussions/3459_add_support_for_apds9930 branch 3 times, most recently from c3b15aa to 0edc6a3 Compare February 3, 2026 21:57
@iyesin iyesin marked this pull request as ready for review February 4, 2026 01:47
@iyesin
Copy link
Copy Markdown
Author

iyesin commented Feb 4, 2026

I tested this code on the real hardware. The only problem I found is with the proximity sensor: its feedback is kinda chaotic and all 3 (!!!) sensors I posses, showing me different values.

@iyesin iyesin changed the title Add support for APDS-9930 sensor [APDS-9930] Add support Feb 27, 2026
@iyesin iyesin changed the title [APDS-9930] Add support [apds9930]: Add sensor support Feb 27, 2026
@iyesin iyesin force-pushed the discussions/3459_add_support_for_apds9930 branch from 24aa15e to 7b72b00 Compare April 15, 2026 14:44
@iyesin
Copy link
Copy Markdown
Author

iyesin commented Apr 15, 2026

Is there anybody here to review this PR?

@iyesin iyesin force-pushed the discussions/3459_add_support_for_apds9930 branch from 1de48a5 to 1da9551 Compare May 29, 2026 22:35
@iyesin iyesin force-pushed the discussions/3459_add_support_for_apds9930 branch from 1da9551 to a44c89a Compare May 29, 2026 22:41
@iyesin
Copy link
Copy Markdown
Author

iyesin commented May 30, 2026

Hello? Anybody?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants