? I don't see the output...Output from the A0 and A1 readings.
Problem reading two sensors with analogRead()
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: Problem reading two sensors with analogRead()
- txbobs
- Posts: 22
- Joined: Wed Jan 30, 2013 3:11 pm
Re: Problem reading two sensors with analogRead()
Helps if actually paste it. :)adafruit_support_bill wrote:? I don't see the output...Output from the A0 and A1 readings.
A0 - 147 A1 - 147
A0 - 147 A1 - 147
A0 - 148 A1 - 147
A0 - 147 A1 - 147
A0 - 147 A1 - 147
A0 - 147 A1 - 147
A0 - 147 A1 - 147
A0 - 147 A1 - 147
A0 - 147 A1 - 147
A0 - 147 A1 - 147
A0 - 147 A1 - 147
I just checked and the voltage coming in from the sensors is around .67 which seems correct but I am calculating .47 for both of them. I am beginning to think it is just a code problem. Still interesting that changing Arduinos makes a difference.
Last edited by txbobs on Mon Jan 04, 2016 1:56 pm, edited 1 time in total.
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: Problem reading two sensors with analogRead()
Are those the raw readings or calculated results? Not sure about the accuracy, but they do seem pretty stable.,
- txbobs
- Posts: 22
- Joined: Wed Jan 30, 2013 3:11 pm
Re: Problem reading two sensors with analogRead()
They are raw readings. I guess the instability comes only when I had only one sensor connected but was reading both inputs still. Since the open pin was floating, its readings varied greatly. That didn't happen on the raspio though which had me confused.adafruit_support_bill wrote:Are those the raw readings or calculated results? Not sure about the accuracy, but they do seem pretty stable.,
I guess now I am just left with the puzzle of the two platforms behaving/reporting differently. Thanks for your help, Bill.
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: Problem reading two sensors with analogRead()
A floating analog pin makes a pretty good random number generator on an Arduino. I'm not familiar with the internals of the RasPiO or what they may be doing differently. One possible difference might be the analog reference voltage. It is 5v by default on most Arduinos, but the Pi is a 3.3v device.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Problem reading two sensors with analogRead()
Try the double-read thing. I don't know why the RasPiIO doesn't do it. This is an AVR thing.
- txbobs
- Posts: 22
- Joined: Wed Jan 30, 2013 3:11 pm
Re: Problem reading two sensors with analogRead()
I am feeding the sensors with the 3.3v line on the Metro. The .7v on the raspio is returning a raw 220 while the Metro only reports the 148.adafruit_support_bill wrote:A floating analog pin makes a pretty good random number generator on an Arduino. I'm not familiar with the internals of the RasPiO or what they may be doing differently. One possible difference might be the analog reference voltage. It is 5v by default on most Arduinos, but the Pi is a 3.3v device.
I decided to see what the extremes are on the metro. Connecting A0 to ground and A1 to 3.3 I get the following.
A0 - 0 A1 - 692
A0 - 0 A1 - 694
A0 - 0 A1 - 693
A0 - 0 A1 - 693
A0 - 0 A1 - 693
Is the Metro ADC expecting 5v? Sure seems like that is the case.
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: Problem reading two sensors with analogRead()
But the default analog reference is 5v. This can be changed to 3.3v if desired.I am feeding the sensors with the 3.3v line on the Metro.
https://www.arduino.cc/en/Reference/AnalogReference
- txbobs
- Posts: 22
- Joined: Wed Jan 30, 2013 3:11 pm
Re: Problem reading two sensors with analogRead()
Thanks, Bill. I added a 3.3v connection to the aref pin and added analogReference(EXTERNAL); to the code. Seems to be working now. Thanks for the newbie interruption. :)adafruit_support_bill wrote:But the default analog reference is 5v. This can be changed to 3.3v if desired.I am feeding the sensors with the 3.3v line on the Metro.
https://www.arduino.cc/en/Reference/AnalogReference
- WarthogARJ
- Posts: 2
- Joined: Sun Jan 27, 2019 11:51 pm
Re: Problem reading two sensors with analogRead()
Is this person still working at Adafruit?
If so, I really hope they were told that this specific response was a very poor one.
The guy you replied to was doing a good job of looking into a problem, but Adafruit Admin was pretty insulting and derogatory in their reply.
The issue is indeed a general one, and this sort of investigation needs to be encouraged.
I was thinking I should support Adafruit due to their general support, but this sort of reply doesn't dosn't do that.
If so, I really hope they were told that this specific response was a very poor one.
The guy you replied to was doing a good job of looking into a problem, but Adafruit Admin was pretty insulting and derogatory in their reply.
The issue is indeed a general one, and this sort of investigation needs to be encouraged.
I was thinking I should support Adafruit due to their general support, but this sort of reply doesn't dosn't do that.
adafruit wrote:not sure how else we can say that it wasnt stable because it wasnt stable. maybe they didnt want to spend more money on it? regardless, its not in the tutorial anymore because it didnt work well - which means you should probably stop thinking about it :mrgreen:bswift5528 wrote:Yeah, I just finished that up now. Works great! Still don't know why the bandgap reference isn't stable, or why the 1.05 was in the original calculation,
electronic temperature sensors are precise to only about 1 or 2 degrees.Still, Sensor 2 seems to be acting up...this time, reading a few deg higher than the other two, and not just being noisy. Has anyone had problems of this nature with a TMP36 before? Thanks again!
Please be positive and constructive with your questions and comments.