joba-1 / joba_tsl2561 Goto Github PK
View Code? Open in Web Editor NEWArduino/PlatformIO library for Tsl2561 luminosity sensor
License: GNU Lesser General Public License v3.0
Arduino/PlatformIO library for Tsl2561 luminosity sensor
License: GNU Lesser General Public License v3.0
compile fails with an error ‘class CDCSerialClass’ has no member named ‘printf’. The Serial library does not implement printf().
When the sensor gets very high light level (direct sunlight) it will loops forever in the bool autoGain sub.
Did some debugging myself, but can't find the solution.
The problem is in this part of the code (I think):
if( (full < 1000 && ++curr < sizeof(sensitivity)/sizeof(sensitivity[0])) || (full > limit && curr-- > 0) ) { if( !tsl.setSensitivity(sensitivity[curr].gain, sensitivity[curr].exposure) ) { return false; } gain = sensitivity[curr].gain; exposure = sensitivity[curr].exposure; } else { if( ++curr > 0 && retryOnSaturated-- == 0 ) { return true; // saturated, but best we can do } }
With high light level the first if is not true, code will then jump to the else, the if here is also not true and the code will jump to the begin of the sub and starts over. There will no false returned.
Added some debugging in front of this part code.
Serial.printf("full=%u, curr=%u, limit=%u, sizeof=%u \n", full, curr, limit, sizeof(sensitivity)/sizeof(sensitivity[0]));
And that will print full=5047, curr=0, limit=3783, sizeof=6
If you need more data let me know.
When it's dark, the autogain readout can take several seconds. During this time the system is busy mostly in the following section of code:
void waitNext( Tsl2561::exposure_t exposure ) {
switch( exposure ) {
case Tsl2561::EXP_14: delay(Tsl2561Util::DELAY_EXP_14); break;
case Tsl2561::EXP_101: delay(Tsl2561Util::DELAY_EXP_101); break;
default: delay(Tsl2561Util::DELAY_EXP_402); break;
}
}
The problem is that delay()
is not very well-behaved, so that other code that depends on regular calls to maintain connections and event loops is being crowded out. While delay()
does the basics such as feeding watchdogs, a typical problem example is MQTT using the PubSubClient
library (as outlined in this article). I regularly see lost MQTT connections and missed messages when it's dark because the system cannot respond to them.
I see two main ways out of this:
autoGain()
routine into a state machine. I call it regularly from the main loop()
and it maintains timers internally so that there is no use of delay()
and no lockups at all. That's a rather heavyweight solution, though.delay()
functions that makes the necessary callbacks.Heya,
someone found some usage bugs of the wire library
File "Sonoff-Tasmota/lib/Joba_Tsl2561/src/Tsl2561.cpp", the "readByte()" and "readWord()" have extra Wire.endTranmission() in the return.
Credits @Koepel
arendst/Tasmota#2442
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.