Comments (24)
I mean they're kind of already supported via the Analog To Digital Converted Sensor. You can just hook up a photodiode to an analog pin and measure the voltage on that pin. I've been using that method myself for quite some time now.
But digital light sensors are currently unsupported, though they would probably be good to have too. The problem is that there are just so many different types of light sensors out there and I don't have much knowledge about which ones are usually used in projects. I would like to support them, is the light sensor you would like something like the TSL2561 or something else?
from esphome-core.
I don't really have any suggestions as I don't really have any experience with any.
But I found this article and maybe some of them are easier to integrate than others?
https://www.intorobotics.com/common-budgeted-arduino-light-sensors/
from esphome-core.
Thanks for finding that link! Most of the sensors are already kind of supported through the ADC sensor and for the ESP32 the pulse counter sensor, but I will take a look at the i2c sensors. They probably won't be too difficult to implement 👍
from esphome-core.
When using a photoresistor or TEMT6000 (i'm currently testing with the last one) on ADC do you convert the voltage to lux when using it in HA?
from esphome-core.
In general, you'll have to consult the datasheet of the sensor. Every sensor has their own characteristic collector current to illuminance curve. Then you can use the Lambda Sensor Filter to convert the incoming values to another unit, see Converting Celsius to Fahrenheit for an example of this. Above links are for esphomeyaml, if you're just using esphomelib I can also show you have it would be done in there.
Typically you'll hook up a photoresistor as a voltage divider using a known value resistor. On the TEMT6000 Sparkfun Board this resistor has a value of 10kΩ. The datasheet of the TEMT6000 has a figure that shows you the relationship between current and illuminance in lux. With the 10kΩ series resistor and VCC
hooked up to 3.3V, the current across the TEMT6000 should be about adcvalue * 3.3 / 10000.0
. And based on the datasheet there's a proportional relationship between current and illuminance: every 2 microamps in current correspond to 1 lux. Therefore the formula should be (adcvalue * 3.3 / 10000.0) * 2000000.0
.
So if using esphomeyaml, the configuration would be something like this:
sensor:
- platform: adc
pin: A0
name: Illuminance
unit_of_measurement: lux
filters:
- lambda: (x * 3.3 / 10000.0) * 2000000.0
I'm not 100% sure how esphomelib/esphomeyaml should handle these 2nd order sensors that use the ADC. It would be awesome if we could have predefined components like the TEMT6000 that use the existing components (here ADC) and setup all filters for the user. However that would make the project a lot bigger and less maintainable :/ So I guess one option would be to do all of this 2nd order component stuff within esphomeyaml. If you can verify that above filter value conversion works, that would be awesome 😀
from esphome-core.
My suggestion would be to recommend users to use a sensor that works out-of-the-box and reports an actual lux value to make it easy for them.
If one or two i2c sensors is supported by esphomelib and we know they work that would be great.
Maybe ADC should be for "advanced use/users only"?
I'm not very experienced with any of the sensors i'm actually using and most code is copy-paste from somewhere :-)
I've tried the formula for TEMT6000 and compared the results with an Aeon Labs MultiSensor 6.
Same room and same location (inside living room, cloudy day):
MS6: 15lux
EHL: 5lux
MS6: 11lux
EHL: 4lux
from esphome-core.
I found a random link in a comment on a webshop with code for BH1750:
https://github.com/Genotronex/BH1750FVI_Master
from esphome-core.
Thanks! It will require a bit of cleaning up but would be relatively easy to add support for. I'll have to take a look at this in a few days as I currently don't have too much time on my hand.
from esphome-core.
I've ordered some BH1750 and TSL2561 (both i2c) on Aliexpress a week ago but it takes forever to delivered.
I've currently only have one TEMT6000 analog sensor to play with 😀
from esphome-core.
I'm still only using the one TEMT6000 sensor I have but it works good enough so i've removed the Aeon Labs MultiSensor 6 from my setup inside the house.
Regarding the values calculated with TEMT6000:
I don't think they a very accurate with the ADC and seems to cap at 726 lux so a digital sensor would be nice.
I've set my indoor light to turn on below 20lux (combined with a PIR sensor) and that works nicely.
from esphome-core.
Here is an example where it caps at 726 lux.
For use with automatic light this is not an issue but nice to know.
from esphome-core.
Ah sorry, didn't see this message, I've just put the BH1750 and TSL2561 on my task list as they seems easy to support without any core changes.
About the scoping out. So using above formula this turns out to be exactly 1.1V, the maximum the internal ADC can handle using the default settings. On the ESP you have the option to set an ADC attenuation of up to 11db (corresponds to about 3.5V). See.the link on the documentation page for what maximum voltage these attenuations map to.
from esphome-core.
That would be nice. I've recieved 5 TSL2561 sensors the other day.
The board with the TEMT6000 is a ESP32 so I'll try set the attenuation to 11db and see what happens.
Totally unrelated question:
Where is the best place for general discussion on esphomelib/esphomeyaml? The Home Assistant forum?
from esphome-core.
So to your last question: I don't really know myself. The problem is that for me keeping track of all the Github issues (even though there are only ~10) is quite a pain, even with e-mail notifications.
The positive side of using the hass community forums is that it's a lot more real time and I can keep track of all threads much easier. But for tracking issues github is definitely better IMO.
I've now also done a big i2c update (here) that will be released with 1.5.0. It includes (experimental) support for the TSL2561, BH1750, BME280, BME680 and SHT3XD 🎉
from esphome-core.
No luck with the TSL2561. I haven't recieved the BH1750 sensors yet.
The TSL2561 sensor shows up on a i2c scan with address 0x39, but I keep getting the same value 2.8lx (actually 2.814720). I have only tested with one TSL2561 sensor for now.
From the log:
[20:41:21][I][i2c:051]: Scanning i2c bus for active devices...
[20:41:21][I][i2c:057]: Found i2c device at address 0x39
...
[20:41:22][D][sensor.tsl2561:129]: Got illuminance=2.8lx
[20:41:22][D][sensor.mqtt:039]: 'ESP test TSL2561': Pushing out value 2.814720 with accuracy 1
[20:41:35][D][sensor.tsl2561:129]: Got illuminance=2.8lx
(same values repeat)
from esphome-core.
Bummer... In 1.5.0 I've added a new log level that should help with resolving these issues a lot: VERY_VERBOSE
. For i2c it for example dumps the entire transmitted and received values for debugging.
Could you try setting the level:
in the logger
component to VERY_VERBOSE
? That would be great, thanks!
from esphome-core.
I have no idea what I'm looking at 😀
Broken sensor is also a possibility. I can test with another, but not today.
[21:07:36][VV][component:107]: Running interval 'update':0 with interval=15000 last_execution=194969 (now=209970)
[21:07:36][VV][i2c:076]: Beginning Transmission to 0x39:
[21:07:36][VV][i2c:109]: Writing 0b00000000 (0x00)
[21:07:36][VV][i2c:109]: Writing 0b00000011 (0x03)
[21:07:36][VV][i2c:081]: Transmission ended. Status code: 0x00
[21:07:36][V][component:054]: set_timeout(name='illuminance', timeout=422)
[21:07:37][VV][component:107]: Running timeout 'illuminance':1 with interval=422 last_execution=209997 (now=210420)
[21:07:37][VV][i2c:076]: Beginning Transmission to 0x39:
[21:07:37][VV][i2c:109]: Writing 0b00001100 (0x0C)
[21:07:37][VV][i2c:081]: Transmission ended. Status code: 0x00
[21:07:37][VV][i2c:103]: Requesting 2 bytes from 0x39:
[21:07:37][VV][i2c:133]: Received 0b00001100 (0x0C)
[21:07:37][VV][i2c:133]: Received 0b00000010 (0x02)
[21:07:37][VV][i2c:076]: Beginning Transmission to 0x39:
[21:07:37][VV][i2c:109]: Writing 0b00001110 (0x0E)
[21:07:37][VV][i2c:081]: Transmission ended. Status code: 0x00
[21:07:37][VV][i2c:103]: Requesting 2 bytes from 0x39:
[21:07:37][VV][i2c:133]: Received 0b00001110 (0x0E)
[21:07:37][VV][i2c:133]: Received 0b00000010 (0x02)
[21:07:37][VV][i2c:076]: Beginning Transmission to 0x39:
[21:07:37][VV][i2c:109]: Writing 0b00000000 (0x00)
[21:07:37][VV][i2c:109]: Writing 0b00000000 (0x00)
[21:07:37][VV][i2c:081]: Transmission ended. Status code: 0x00
[21:07:37][D][sensor.tsl2561:129]: Got illuminance=2.8lx
[21:07:37][V][sensor.sensor:022]: 'ESP test TSL2561': Received new value 2.814720
[21:07:37][V][sensor.sensor:028]: 'ESP test TSL2561': Filter #0 aborted chain
from esphome-core.
Thanks for the logs! I've now identified at least one issue using them. Basically, for the implementation I was mostly following the datasheet which had an implementation detail only very hidden.
I'll try to fix the source code for the TSL2561 today and get it into 1.5.1 :)
from esphome-core.
I recieved the BH1750 sensors and it seem to work. Getting some realistic values. 😁
from esphome-core.
It's definitely better than using the TEMT6000 with the ADC in low light conditions.
The last 2 hours the TEMT6000 value was 0 in my living room and the BH1750 about 30 down to 7 (low light but with 2 lamps turned on).
from esphome-core.
Ok, all your suggested sensors are now supported and should work. Please open a new issue if one of them doesn't work.
from esphome-core.
I haven't tested TSL2561 recently, but BH1750 works like a charm.
from esphome-core.
@ladefoged81 Hey I have been trying to get my TEMT6000 working but it seems like the Voltage readings from the sensor are pretty low (0.15V in a decently lit room) (which corresponds to 3lux or so)
What calculation did you use?
Did you also face the problem of exceptionally low values?
I just want to use it to see if it's somewhat dark to turn on light.
Thanks.
from esphome-core.
@2016for I used the code provided by Otto however I have moved to a bh1750 i2c sensor instead.
from esphome-core.
Related Issues (20)
- Auto-load esphome component upon discovery by Home Assistant HOT 10
- esp32_ble_tracker scan_interval not used correctly HOT 1
- Firmware seems to have watchdog issues for esp32_ble_tracker HOT 1
- PMSx003 does not work
- MQ-2 Sensor. HOT 5
- [RGB Light Platform] Remember brightness and color after restart HOT 5
- Error in HA since 0.86 HOT 1
- DO NOT POST ISSUES HERE
- ESP32 goes to boot loops with option exrire_after HOT 1
- Error OTA update ESP8266 12e HOT 2
- MIC sensor, status fast change HOT 1
- esphomeyaml showing terminated process HOT 1
- esp32 access point not enabled HOT 1
- Update Failed: ERROR[8]: Flash config wrong real: 4194304 IDE: 16777216 HOT 1
- Returning NAN when using id.value HOT 1
- esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header HOT 1
- Ok, now I understand, so you want to have all three units show up as sensor at the same time. HOT 2
- witty cloud with LDR and RGB HOT 2
- Cannot connect to hidden SSID HOT 1
- ERROR Error binary size: Error: ESP has been flashed with wrong flash size. Please choose the correct 'board' option (esp01_1m always works) and then flash over USB. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esphome-core.