LM35 to Arduino malfunctioning after connecting GSM

Discussion in 'Embedded Systems and Microcontrollers' started by Chetan_Jadhav, Jul 19, 2019.

  1. Chetan_Jadhav

    Thread Starter Member

    Mar 2, 2017
    44
    1
    Hi,
    I am building a temperature monitoring system using lm35, GSM Sim900a and Arduino.
    LM35 was working good when connected with Arduino and readings were as expected. (without connecting GSM)
    But as I connected GSM Module to the same circuit, Temperature readings started fluctuating in a wide range (24>>38>>31>>50>>etc.)
    I am using USB Power for Arduino,separate 12v adapter for GSM and simple male to female connecting wires for other connections.
    Please help me with the solution.
    thanks.
     
  2. ericgibbs

    Moderator

    Jan 29, 2010
    8,133
    1,643
    hi,
    Have you tried a simple R/C filter on the input to the ADC pin.?
    Say a 470R in series with the input and a 10n or 47n to 0V from the input pin.
    E
     
    Chetan_Jadhav likes this.
  3. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    5,298
    2,000
    Is the GSM module a shield or separate module?

    What pin is the LM35 connected?

    Are there any pin conflicts between the two peripherals?

    If the GSM module is a shield, it may be using the same pin you’ve assigned to the LM35. The library for the GSM should document the required pins. In this case, the easiest solution would be to reassign the pin(s) for the LM35.

    I built a system with several shields... SD card, MP3 player, amplifier, RTC and LCD backpack. I ran into several pin conflicts and had to reassign several pins to get everything to work.
     
    Chetan_Jadhav likes this.
  4. Chetan_Jadhav

    Thread Starter Member

    Mar 2, 2017
    44
    1
    Hi,
    no shield. I am using separate module SIM900a with tx,rx,gnd to 9,10,gnd pin of arduino uno respectively. LM35 to A0 of arduino.
    Thanks
     
  5. Chetan_Jadhav

    Thread Starter Member

    Mar 2, 2017
    44
    1
    Not yet,
    But I will surely try now.
    With all respect sir, May i please know the reason of using RC filter and what is the reason behind these malfunctioning?
    Because I might find it's need in other areas.
    ShowThanks
     
    Last edited by a moderator: Jul 19, 2019
  6. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    5,298
    2,000
    Sounds simple enough.

    Which Arduino model are you using? Is serial communication on pins 9 & 10 implemented by hardware or software
     
    Chetan_Jadhav likes this.
  7. Chetan_Jadhav

    Thread Starter Member

    Mar 2, 2017
    44
    1
    Arduino Uno.

    Software implementation on pins 9,10(PWM enabled)
    pls find the code attached below
    thanks
     
  8. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    5,298
    2,000
    Thanks for supplying your code.

    You do know that you need to initialize analog reads by performing a read and throwing away the first result?

    The Arduino ADC needs to initialize it’s internal capacitor and hence the first read is not reliable. And if you’re using multiple analog pins (you’re not, but I’m mentioning this for future designs), you need to perform this sacrificial read every time when switching between Arduino analog pins. In your design, I would put a call to analogRead() in the setup() routine.
     
    JohnInTX and Chetan_Jadhav like this.
  9. Chetan_Jadhav

    Thread Starter Member

    Mar 2, 2017
    44
    1
    I just tried it.
    But now working, There were still variations in readings.
    when i simply disconnected the power to GSM module and the readings were quit stable.
    Without GSM powered on the code runs fine. It's all after GSM connection. Please have a look at results.
    without GSM.png with gsm.png
     
  10. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    5,298
    2,000
    One more try, ok?

    Perform a double read EVERY time.
     
    Chetan_Jadhav likes this.
  11. Chetan_Jadhav

    Thread Starter Member

    Mar 2, 2017
    44
    1
    OMG. It workded. Thanks a lot. I didn't even think that an additional line in code could help with accuracy.
    Although there are variations (around 1 degree Cen.) but much better than before.
    with gsm2.png
     
  12. Phil-S

    Member

    Dec 4, 2015
    123
    11
    Hard to get an LM35 wrong, but a good read of the datasheet and application notes will give plenty of information on driving the output down difficult lines. It might be worth buffering the output of the LM35 at source.
     
Loading...