This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LMT01: To interface with Arduino mega 2560

Part Number: LMT01

Hello community,

I am currently facing difficulties connecting a sensor to my Arduino Mega 2560. Despite trying various codes and circuit designs, I have been unable to successfully read the pulse count or temperature values from the sensor. I have attempted to use the training videos and example code from TI, but nothing seems to be working.

In the future, I am looking to connect a total of 15 LMT01 sensors to the Arduino Mega 2560, so any guidance or assistance with resolving my current issue would be greatly appreciated.

Thank you in advance for your help.

  • Dear Aravind - 

    Thanks for the post and welcome to E2E. 

    I can point you to this training material, which includes example code (second link, from product page of the LMT01).

    https://training.ti.com/how-interface-lmt01-temperature-sensor-arduino 

    https://www.ti.com/lit/zip/snic014 

    (you can replace the LCD prints with Serial.prints to the UART, since the Mega2560 does not have built in LCD)

    If you still have issues, then if you could share which pins you are connecting to / schematic of what you are doing, that would be helpful in assisting you further.  

  • Josh, Thank you for your response.

    I tried the same code you provided above with some modifications before as follows. But there is no output at Arduino serial monitor. I am using WSON package. Vp pin to 3.3 voltage, Vn to digital pin 3 of arduino mega 2560 with a shunt resistor of 6.8k.

    +3.3v----------Vp---- [LMT01]---- Vn------------------ Digital pin 3

                                                                           |

                                                                           |

                                                                   R (6.8 K)

                                                                           |

                                                                           |

                                                                    Ground

    -----------------------------------------------------------------------------------------------

    // Declare a variable to hold the pulse count, set it to 0 initially
    volatile int pulseCount = 0;
    // Declare a variable to hold the temperature, set it to 0 initially
    float temperature = 0;
    // Declare a variable to hold the previous pulse count, set it to 0 initially
    int hold = 0;

    // Setup function that runs once when the board is powered on or reset
    void setup()
    {
      // Set pin 3 as an input
      pinMode(3, INPUT);
      // Start serial communication at a baud rate of 9600
      Serial.begin(9600);
      // Set the Analog Comparator Control and Status Register to B01011010
      ACSR = B01011010;
      // Attach an interrupt to pin 3 that triggers when the signal falls from high to low (FALLING)
      attachInterrupt(digitalPinToInterrupt(3), countPulses, FALLING);
    }

    // Main loop function that runs repeatedly
    void loop()
    {
      // If the pulse count is not 0 (i.e. a pulse has been received)
      if (pulseCount != 0)
      {
        // Wait until the pulse count has stabilized (i.e. is not changing anymore)
        while (pulseCount != hold)
        {
          hold = pulseCount;
          delay(1);
        }
        // Calculate the temperature in Celsius from the pulse count
        temperature = 0.0625 * pulseCount - 50;
        // Print the pulse count and temperature to the serial monitor
        Serial.print("Pulse Count: ");
        Serial.print(pulseCount);
        Serial.print(", Temperature: ");
        Serial.print(temperature);
        Serial.println(" C");
        // Reset the pulse count to 0 to start counting again
        pulseCount = 0;
      }
      // Wait for 2 milliseconds before checking the pulse count again
      delay(2);
    }

    // Interrupt service routine that is triggered when a pulse is received on pin 3
    void countPulses()
    {
      // Increment the pulse count by 1
      pulseCount += 1;

    }

    -----------------------------------------------------------------------

  • Dear Aravind - 

    I think you need to use pins AIN0 and AIN1, as described in the video and set by the firmware to use. 

    Here, upon further inspection, unlike the UNO, AIN0 pin (positive input to comparator) is not mapped to the headers, but the AIN1 pin (negative input to comparator) is, so you may want to switch to the UNO or to an MSP430 LaunchPad.

  • Hello Josh,

    I am currently using an Arduino UNO board and I am attempting to locate the AIN0 and AIN1 pins on it, but have been unable to do so. I have been referring to a video [https://www.youtube.com/watch?v=CWDX6PdF-ZY&t=238s ] and schematic as a guide, and I have also attempted to use some code, but it did not produce the desired results.

    volatile int pulseCount = 0;
    float temperature = 0;
    int hold = 0;

    void setup()
    {
      //Setup ACSR Register, to initlize the comparator

      /*         ACSR Bit Description
      *  
      ACD  - Clear ACD to enable Analog Comparator
      ACBG - Set ACBG to 1 to use internal 1.1V Reference
      ACO  - Clear ACIO (Will be ignored - read only)
      ACI  - Reset Analog Interrupt Flag by writing 1
      ACIE - Set ACIE to enable comparator interrupt
      ACIC - Clear ACIC, no connection to Timer/counter
      ACIS1 - Set ACIS1 to trigger interrupt on falling edge
      ACIS0 - Cleat ACIS0 to trigger interrupt on falling edge
      */

     
      ACSR = B01011010;    //Set according to above bit description
     
      Serial.begin(9600);  //Initialize serial communication with a baud rate of 9600
    }

    void loop()
    {
      //don't bother entering the loop again if no pulses have been counted yet.
      if(pulseCount != 0)
      {
        //Wait for counting to be complete
        while(pulseCount != hold)
        {
          hold = pulseCount;
          delay(1);
        }
     
        //Print Pulse count to Serial Monitor
        Serial.print("PULSES: ");
        Serial.println(pulseCount);
       
        //Print Temperature to Serial Monitor
        temperature = 0.0625 * pulseCount - 50;
        Serial.print("TEMP(C): ");
        Serial.println(temperature);
       
        //reset pulseCount for next loop
        pulseCount = 0;
      }
      delay(2);
    }


    //Interrupt Service Routine, counts pulses
    ISR(ANALOG_COMP_vect)
    {
      //Increment pulse count
      pulseCount += 1;
    }
  • Josh, thank you for your assistance. I have successfully activated my sensor by connecting Vn to AIN1 on my UNO Pin D7 or MEGA Pin D5. My next goal is to connect 15 sensors in this manner to take multiple temperature readings. Is that possible with any modification on this set up itself [on MEGA]?.

  • To read multiple LMT01, you can toggle the power using GPIO as shown in LMT01 datasheet Figure 34.

    thanks,

    ren

  • Hi Ren,

    As previously stated, I obtained a reading only after connecting the Vn to the negative of the comparator AIN01 (digiatl pin 5) on the Arduino mega 2560. How do I connect Vn from 15 sensors together like this [as like the figure you provided] to a single Arduino Mega 2560? That's where I need assistance. Is it possible?

    Thank you.

  • Figure 34 shows multiple VN connected together to the same comparator. The sensor you wish to read is provided power at its VP by a GPIO while the remaining sensors receive float state at their VP. The change you need to make is at VP, not VN.

    thanks,

    ren

  • Hi Ren,

    I'm sorry to say that I'm still struggling to understand the logic you explained earlier. Could you please provide further explanation and guidance? I'm particularly interested in knowing if there are specific GPIOs that need to be connected to Vp, and if the logic you described can be used to collect outputs from multiple sensors at the same time.

    I apologize for any inconvenience, but I need to fully grasp this as I require data from multiple sensors simultaneously.

    Thank you for your assistance.

  • The problem might be that you are expecting "data from multiple sensors simultaneously." The proposed solution collects data sequentially from the sensors. Only one sensor will be powered at a time. It takes 100ms to power on an LMT01 and receive its' transmission; you can potentially receive data from 10 LMT01 sensors per second. If you need more than this, you will need more comparators, which might also require more MCUs in use at once.

    thanks,

    ren