Sensor Saturation Warning as Final V1 Feature of My AS7341 App
It's been fun playing with my AS7341 interactive UI web app, seeing what the sensor sees and what the app guesses my eyes would see. They're similar but rarely agree, as should be expected of a quick hack job. Occasionally I would see something wildly inaccurate, and it would take a few seconds for me to realize the problem: one or more AS7341 channels had hit their saturation (ADCfullscale) values. This "peg the scale" value (a.k.a. "off-scale high") is no longer accurate. In photography this causes overexposure.
Since the raw server response JSON is printed at the bottom of my app, I could see sensor values that are at their ADCfullscale value. But this means mentally calculating ADCfullscale (which isn't always 65535) and comparing them against those printed numbers. I could do it, but I wouldn't know to do it unless I suspect something is wrong with the output. I want notification of sensor saturation whenever it happens, even (or especially!) when the result looks reasonable but are actually wrong.
The JavaScript code to detect saturation on a sensor channel was straightforward and can be performed in a loop over values for sensors F1-F8. Though it's more likely to happen on Clear or NIR first, so I checked those as well. But then I had to show the result in a way that I would notice.
My first modification was to change the header text for server response JSON. Normally displaying "Sensor data OK" but switch to "Sensor saturation (overexposure) detected" as notification. This is an improvement, but I found I don't always notice when my eyes are glued to the spectrum chart. To make sure I can't miss it I changed the chart. Every bar was given a white border and, if saturation is detected, that border turns red. This was an improvement, but I might be focused on one channel and miss the fact another channel had saturated. As I understand it, when one channel is saturated, every reading is unreliable. So if this is a global problem, I'll make the indicator global. The third modification changes every border to red if any channel had saturated. Now I can't miss it!
With this sensor saturation notification feature, I think my AS7341 interactive web app is at a good place to wrap up for version 1.0. Before I put my sensor away, though, I wanted to make the hardware more compact and portable.
Code for this project is publicly available on GitHub