Sensor Only Outputs Constant High Value

Hello forumers!

Thanks to the help on here my code is now compiling correctly. Lesson for all: compile codes in small segments as you go!

However, I have a light intensity sensor, TEMT6000, that is only showing the high analog value, 1023, regardless of change. I posted the updated code on my gitHub since it’s too long to post here.

https://github.com/ThisNerdyGuy/ArduinoProjects.git

The code for this issue is DataLog_Sensor_Test_3.ino.

This is a fritzing of my device as it is now - not the ideal state.

Apparently I don’t know how to post pictures on here. I’ll upload it to my site after I re-size it.

http://thisnerdyguy.com

Assuming that the sensor is wired as shown in your diagram I cannot see what is wrong. Does the input reading vary if you replace the sensor with a potentiometer or 2 fixed resistors in a bridge configuration ?

Looking at this would have been simpler if you had provided a minimal program that exhibited the problem. It could have been in about a dozen lines of code instead of hundreds and would help in focussing on the problem.

That's the problem, UKHeliBob. The smaller code that I do have functions flawlessly. It only fails to work when I put on the adafruit data logger shield which is why I was hoping it would be a glaring issue or something like a mislabeled pin in the code (even though I've went over it multiple times).

I have not tried a potentiometer. I will try that now I suppose.

I just tried your suggestion and the potentiometer exhibits the same behavior. It must be a programming issue. 5V, GND, and SIG are pretty hard to screw up.

The code says SD card communicated through Pin 10, plus Pin 2 & 3 for LEDs. My analog inputs are in A0 and A1 and my two digital inputs are A4 and A5. I really am confused as to why this is happening.

Let’s look at the clues we have.

  1. The sensor works correctly when used with a small program
  2. The sensor returns the wrong value when used in a large program

Depending on the Arduino that you are using that sounds like a (lack of) memory problem.
Try commenting out some other code not associated with this sensor to free up more memory.

I'll give that a whirl and report back!

Thanks for the help thus far! :sweat_smile:

Hmm...commenting out a large portion of the code did not change the effect.

I think I am going to go back and re-combine the sensor code with the data log shield code again. Third time is a charm, right!?

I'm also noticing that the LEDs don't light up when saving like the code comments state they should.

According to the adafruit sample code, the green LED should come on when it is going through the loop section. The only green LED I see on is the power LED but I don't think that's the same one. The red LED works correctly though; it flashes when writing to SD.

I wonder if the green LED and the failing TEMT6000 sensor are related? I have re-written this code a dozen times to no avail.

https://github.com/ThisNerdyGuy/ArduinoProjects.git

Phase 2 is the most recent code. There is no point in me uploading my other minor variations; all they really are is a sort of re-order but the problem persists.

ThisNerdyGuy:
I’m also noticing that the LEDs don’t light up when saving like the code comments state they should.

The code is driving LEDs on pins 2 and 3, and your drawing shows nothing connected to either of those pins, so it’s no surprise they don’t light up. The red pin you’re seeing is probably the red LED connected to the Tx pin, being illuminated when your sketch writes to the serial port. What output are you getting on the serial port?

I assume the output value you’re concerned with is lightValueReading. Given that the output seems to consist of comma separated variables and so the data is not labeled, how absolutely positively certain are you beyond any conceivable shadow of a doubt that the data you’re looking at is actually the value of lightValueReading? Then, assuming I still don’t believe you, how would you go about proving that beyond question?