-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TSL2561 not working Version 5.11.1 (Sonoff TH16) #1644
Comments
#define USE_TSL2561 // Add I2C code for TSL2561 sensor using library Adafruit TSL2561 Arduino (+1k2 code) user_config.h totally forgot that one... |
A little further, but it keeps on 0 lx? |
I had the same learning curve (didn't know I need to #define USE_TSL2561 and when I did, I got 0 lx). My sensor has a floating address bit, So it should be found at 0x39. And the following code snippet does so in a separate sketch on a nodemcu (and reports proper lx after that);
for me it looks like boolean TSL2561::begin(void) has a problem. It probably should check result of Wire.endTransmission(). |
Hm, I set the address bit to low to actually make the sensors address 0x29. But still no joy. |
Thnx Joba, for now I give up. I'm not so into coding, so I will wait for someone to fix it. Mayby Arendst can help out. |
There seems to be a problem with the for loop in xsns_16_tsl2561:
It only runs once and tries to start the tsl with address 0x29. |
So we need to change that line off code and recompile? |
The problem is in the Adafruit library which fails to report a not present device. The solution above is a workaround to use a fixed address of TSL2561_ADDR_FLOAT bypassing other possible addresses. If @Merdeka gets it to function with the float address then why can't @joba-1 get it to work with the default low address? Perhaps @Merdeka could try with the low address too. If it works I will just settle for a fixed low/float/high address. You may decide. NB. I do not own a TSL2561 (there are other device providing luminosity) so I can't test. |
Hi,
|
Without changing the library could anyone please test if the following change in xsns_16_tsl2561.ino also works. Pls replace from line 47:
to
|
Did some more research digging in the datasheet of the TSL2561. It seems, to get a valid value from the chip, the command bit (0x80) has to be set in addition to the register itself (0x0a). An example in the current driver can be found e.g. in the enable() method. If I dont do that, I get no valid values, just a reflection of the register number. That said: why only check for sensors on startup? The bus allows plugging them in and out any time... |
Didnt see your test request, will check... |
I can confirm, it works. Great! Here is the startup log:
As you can see, the driver has a bug (it checks for negative unsigned variable :) ). This results in 65535lx although it is very dark. |
Btw. here is the fix (including the actually working id check):
|
Just flashed 5.11.1i on the sonoff TH16, I now get TSL2561 Illuminance | 10708 lx 0.002 lux | Moonless clear night sky The chip itself can go up to 40,000 Lux |
You made me wonder. I checked the code and datasheet: The code simply uses getLuminosity() which returns raw sensor data, not lux! I'll try to fix this... |
If you want to check: In file Sonoff-Tasmota-5.11.1/sonoff/xsns_16_tsl2561.ino change the line (around no 70)
to
It compiles and shows a value for me that seems to make sense. But I have no equipment to verify correctnes. |
Yes joba-1 output is much more what i expected: 20:30:01 MQT: tele/sonoffTH16-2/SENSOR = {"Time":"2018-02-06T20:30:01","TSL2561":{"Illuminance":13}} (light out / only monitor light) So yeah I think this is working! |
It is working better, but not good yet. I sometimes get 0xffffffff from getFullLuminosity() raw value. Due to overflow in calculations within calculateLux() this results in 95lx. It should probably return an easily identifiable error value like 0xffffffff. Then, when raw brightness of visible + ir light rises above ~0x8000, it beginns to stall while the ir part still rises, until both values are equal at 0x90cc, resulting in calculated 54lx. Tested with a bright smartphone led, not sunlight. There is a define in the driver that changes lux calculations a bit (I think ~10-20%). I don't know how to determine which of the 2 variants is right for my chip. All those are not tasmota errors, but tsl2561 driver errors. @arendst: Getting a reading with auto gain and integration time could take a second (maybe even a bit more). Would that be an acceptable response time for tasmota or should a "driver" do continuous readings so it has a proper value ready when asked for? The chip only uses 0.24mA typical when powered on, so that doesnt really matter compared to what the esp needs with active wlan. Finally: I don't insist in using that chip. I just liked, I can read ir and normal light because in the end this might enable me to differ light sources (sun, led, ...). Anyone has a suggestion for an alternative? |
Current value not valid policy is do not display or keep it for up to 10 teleperiod reads then drop display. I prefer reading time as low as possible. If driver can kick device to start processing, then back off and connects after a second again to read value that's fine with me. |
to round this up here:
|
5.12.0 20180209 * Change library PubSubClient.h define MQTT_MAX_PACKET_SIZE from 512 to 1000 for Home Assistant support * Change relation of define MESSZ being dependent on PubSubClient.h define MQTT_MAX_PACKET_SIZE * Change command color parameter input checks to less strict for Home Assistant support * Change command Ina219Mode into command Sensor13 * Change commands HlwPCal, HlwUCal and HlwICal to PowerCal, VoltageCal and CurrentCal to be used for both Pow and S31 calibration * Change commands HlwPSet, HlwUSet and HlwISet to PowerSet, VoltageSet and CurrentSet to be used for both Pow and S31 calibration * Change uptime from hour to second resulting in a display of 123T13:45:21 where 123 is days * Change module name Wemos D1 mini into Generic (#1220) * Change HTML from width=100% to style=width:100% supporting HTML5 (#1358) * Change OSWATCH_RESET_TIME (Blocked loop) from 30 to 120 seconds to allow slow networks (#1556) * Change WIFI_MANAGER_SEC into WIFI_CONFIG_SEC (#1616) * Change function pointers code to save code space and memory (#1683) * Change webserver argument processing gaining 5k code space (#1705) * Change weblog memory usage (#1730, #1793, #1819) * Update TasmotaSerial library to 1.1.0 * Update language files Italian (#1594), Dutch (#1723) and Spanish (#1722) * Fix Non-English JSON temperature unit attachement * Fix Arilux RF induced exception by moving interrupt handler to iram on non ESP8266/Arduino lib v2.3.0 * Fix truncated command names and wrong response for DomoticzSwitchIdx (#1571) * Fix %-sign issue as printf escape character in Humidity and Sonoff SC (#1579) * Fix DS18B20 temperature JSON decimal dot (#1561) * Fix Energy JSON message (#1621) * Fix IRSend parameter translation (#1636) * Fix TSL2561 device detection (#1644, #1825) * Fix BME680 teleperiod resistance measuring (#1647) * Fix Energy Monitoring Energy Today and Energy Total reading after restart (#1648) * Fix IRReceive Data value (#1663) * Fix Energy Monitoring Energy Period roll-over (#1688) * Fix compiler warnings (#1774) * Fix command PWM response if no PWM channel is configured (#1783) * Add locale Decimal Separator to Web sensor page * Add ColorTemperature to light status message * Add command PowerOnState option 5 which inverts PulseTime and allows for delayed always on after power on * Add OtaMagic two step Web server OTA upgrade using filename-minimal image if OTA free space is too small * Add support for PMS5003 and PMS7003 particle concentration sensor * Add command SetOption21 1 to allow Energy Monitoring when power is off on Sonoff Pow and Sonoff S31 (#1420) * Add Chinese language file (#1551) * Add French language file (#1561) * Add Spanish language file (#1589) * Add HTTP Allow Cross Origin removed from ESP8266/Arduino lib v2.4.0 (#1572) * Add Home Assistant MQTT Discovery for switch and light to be enabled by command SetOption19 1 (#1534) or define HOME_ASSISTANT_DISCOVERY_ENABLE in user_config.h (#1685) * Add command State to retrieve device state information (same data as teleperiod state and status 11 in slightly different JSON format) * Add optional login to Webserver AP mode (#1587, #1635) * Add command Sensor15 2 to start MHZ19(B) Zero Point Calibration (#1643) * Add support for Sonoff S31 Smart Socket with Power Consumption Detection (#1626) * Add command SetOption20 to allow update of Dimmer/Color/Ct without turning power on (#1719, #1741) * Add NTP sync time slot based on chip id (#1773) * Add cursor pointer to web button (#1836)
Just flashed my Sonoff Th16 with firmware 5.12a with TSL2561 plugged in I got following error. 00:00:00 Project sonoffth16-2 Sonoff (Topic sonoffTH16-2, Fallback DVES_0DD48D, GroupTopic sonoffs) Version 5.12.0a Joba his fix: Was working fine for me. |
Strange as his fix should be in the latest versions too. Can you verify if that's the case? |
Arend around line 70 in xsns_16_tsl2561.ino There is no such thing as: uint32_t light = tsl->getFullLuminosity(); |
See #1825 |
Thnx Arend, however it's not working for me. Joba is latest firmware working for you? |
Hi joopy,
sorry, have not checked yet, only a patched 5.11.1. And that worked fine.
It could take a little time until I can test this.
Currently I work on my own Tsl2561 library. If we really want to use the
chip, we will need automatic gain, and maybe more accuracy than 1 lux.
Most is already done. Tipps welcome.
See https://github.com/joba-1/Joba_Tsl2561 if you like.
joopy <notifications@github.com> schrieb am So. 11. Feb. 2018 um 18:33:
Thnx Arend, however it's not working for me. Joba is latest firmware
working for you?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1644 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Ae8n-h8ObPnpvbzNiL6e2a2FtOQIekkGks5tTySEgaJpZM4RlAR0>
.
--
iphone so i typo
|
Thnx Joba, Looking forward. For now I will wait for a fix no hurry. When your library is finished it will be implemented in Tasmota? |
Hi @joopy, Theo was so kind to accept my pull request #1951 and add it to 5.12.0b with commit ecfa14d already. It works fine for me. Maybe you can test this, too? Just make sure to comment out #define USE_TSL2561 and uncomment the #define USE_TSL2561_JOBA instead. Btw. you know it is actually using my lib if you see milliLux accuracy. |
In that case I will remove the original driver and make jobas the standard one. Thnx for your support |
5.12.0b * Change TSL2561 driver to joba library and delete Adafruit library (#1644)
Is working fine a few weeks now can be closed. |
5.11.1i * Fix some Energy Monitoring related issues (arendst#1677) * Fix TSL2561 device detection (arendst#1644) * Fix command PWM response if no PWM channel is configured (arendst#1783)
5.12.0b * Change TSL2561 driver to joba library and delete Adafruit library (arendst#1644)
Hi I don't get a TSL2561 to work. I'm using GPIO 4 en GPIO 14
@ console
21:20:53 CMD: I2Cscan
21:20:53 MQT: stat/sonoffTH16-2/RESULT = {"I2CScan":"Device(s) found at 0x39"}
Anyone got a clue?
The text was updated successfully, but these errors were encountered: