Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Wrong voltage value

  1. #1
    Junior Member
    Join Date
    Dec 2016
    Posts
    18

    Wrong voltage value

    Hi,
    I'm getting the wrong voltage value from an analog input. With my multimeter (and with an Arduino mega) I got 2.565V. Using my T3.5 in the serial monitor I get 3.87V and my multimeter got 2.565V. Any ideas?
    Code:
    float sensorValue = 0;
    void setup(void)
    {
    Serial.begin(9600);
    }
    
    void loop(){
    sensorValue = ((analogRead(A8)*5.0)/1023.0);
    Serial.println(sensorValue,5);
    }

  2. #2
    Senior Member Wozzy's Avatar
    Join Date
    Jan 2013
    Location
    Philadelphia, Pennsylvania USA
    Posts
    354
    Kammateo,

    While the T3.5 is 5V tolerant, the A/Ds only read to 3.3 V.

    Try changing the conversion line to:
    Code:
    sensorValue = ((analogRead(A8)*3.3)/1023.0);
    Note that it will fix at 3.3V with any input beyond 3.3V.

    You can also consider adding the following lines to your setup subroutine:
    Code:
    analogReadRes(12);
    analogReadAveraging(10);
    This will fix your resolution at 12 bits, and average 10 readings together.
    Last edited by Wozzy; 01-19-2017 at 04:28 PM.

  3. #3
    Junior Member
    Join Date
    Dec 2016
    Posts
    18
    Woozy, thank you very much for your reply. I changed the conversion line and it works. I'm using the example LowLatencyLoggerMPU6050 from SDfat. When you said:

    Quote Originally Posted by Wozzy View Post
    You can also consider adding the following lines to your setup subroutine:
    Code:
    analogReadRes(12);
    analogReadAveraging(10);
    This will fix your resolution at 10 bits, and average 10 readings together.
    Do I have to use the ADC library? Because I need to read this analog input at 200Hz.

  4. #4
    Senior Member Wozzy's Avatar
    Join Date
    Jan 2013
    Location
    Philadelphia, Pennsylvania USA
    Posts
    354
    Sorry,
    I don't have experience with either the example LowLatencyLoggerMPU6050 from SDfat, or the ADC Library.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •