Plugin _P015_TLS2561 - division by zero possible

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
beegee
New user
Posts: 3
Joined: 03 Dec 2015, 14:56
Location: Manila, Philippines
Contact:

Plugin _P015_TLS2561 - division by zero possible

#1 Post by beegee » 03 Dec 2015, 15:04

I am using the TLS2561 plugin and stumbled over following problem:

When the sensor is completely covered (no light at all) a division by zero exception can occur.
The problem is in line 293 of the _P015_TLS2561.ino file.

Code: Select all

if( ch0/ch1 < 2 && ch0 > 4900)
If there is no light at all, ch1 will be 0. This exception is not caught. Possible change:

Code: Select all

  // ch1 out of range. the lux is not valid in this situation.
  if (ch1 == 0) {
  	return -1; 
  }

  // ch0 out of range, but ch1 not. the lux is not valid in this situation.
  if( ch0/ch1 < 2 && ch0 > 4900) {
Hope this helps!

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 31 guests