reading analog pins of udoo

Discussion in 'General Discussion' started by Abhishek, Apr 14, 2015.

  1. Abhishek

    Abhishek New Member

    Joined:
    Apr 9, 2015
    Messages:
    4
    Likes Received:
    0
    My analog pin always reading 0 for LM35 temperature sensor.
    what would be tha issue??

    same issue i am facing with LDR sensor
     
  2. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    Hi Abhishek,
    what is the value you read when you plug nothing in the pin?
     
  3. Abhishek

    Abhishek New Member

    Joined:
    Apr 9, 2015
    Messages:
    4
    Likes Received:
    0
    hi Andrea Roval,
    i am reading random values
     
  4. Andrea Rovai

    Andrea Rovai Well-Known Member

    Joined:
    Oct 27, 2014
    Messages:
    1,703
    Likes Received:
    240
    Hi Abhishek,
    if you want to be sure that your UDOO doesn't have problems, connect the analog pin once to ground, once to the 3.3. and check if values are the same you expect.
    Cheers!
    Andrea
     
  5. fetcher

    fetcher Member

    Joined:
    Mar 9, 2014
    Messages:
    166
    Likes Received:
    20
    I found that I get better accuracy if I do a dummy analogRead() of a different pin just prior to the one(s) I'm interested in, with a delay(4) in between. I'm not sure why, and the actual difference isn't that great, so if you're getting wildly varying results it's probably something else.

    Unconnected analog inputs seem to float at close to +3.3V (full-scale reading), at least on my boards. The short-to-ground test Andrea recommended is a good idea.
     
  6. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Hi Abhisnek, I am also reading temperature through an LM35.

    What PIN on Arduino you are using for that?

    @Fetcher: I can not approve you suggestion: Whatever I read in front or not, the values on Analog In are alwas the same for me.
     
  7. Abhishek

    Abhishek New Member

    Joined:
    Apr 9, 2015
    Messages:
    4
    Likes Received:
    0
    hi,
    TomFreudenberg,
    I am connecting my LM35 temperaure sensor on udoo's A0
     
  8. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Hi, this is how I can successfully read from LM35

    Code:
    /* Analog attributes */
    #define def_analogReference        AR_DEFAULT
    #define def_analogReferenceVoltage 3.3
    #define def_analogReadResolution   12
    #define def_analogWriteResolution  8
    #define LM35 A0
    
    // the setup routine runs once when you press reset:
    void setup() {
      // set analog reference voltage
      analogReference(def_analogReference);
      // set analog read + write resolution
      analogReadResolution(def_analogReadResolution);
      analogWriteResolution(def_analogWriteResolution);
    
      pinMode(LM35, INPUT);
    
      Serial.begin(9600);
    }
    
    void loop() {
      Serial.println(analogRead(LM35));
      delay(1000);
    }
    
     
  9. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    Otherwise just check another LM35 (I had also defect once)

    Maybe you have a voltometer to check if gives some signals?

    Or just use A1-A7
     
  10. Abhishek

    Abhishek New Member

    Joined:
    Apr 9, 2015
    Messages:
    4
    Likes Received:
    0
    thanks TomFreudenberg,
    i tried your solution but didn't had any success.
     

Share This Page