LM75A Temperature Sensor with LCD1602 I2C

LM75A Temperature Sensor with LCD1602 I2C

In this tutorial, we will learn how to use the LM75A temperature sensor to display temperature readings in both Celsius and Fahrenheit on an LCD1602 screen using I2C communication. The LM75A can measure temperatures ranging from -55°C to +125°C, making it suitable for various applications. Once the setup is complete, you'll be able to see real-time temperature readings on the LCD display.

LCD1602-I2C display module with 4 wires

For this project, we will utilize the LM75A sensor and the LCD1602 module connected via I2C, which allows for simpler wiring and fewer pins used on the Arduino. The goal is to create a system that continuously reads the temperature and displays it on the LCD. If you need clarification on any part of the process, be sure to check the video tutorial (in video at 00:00).

Hardware Explained

The main components for this project include the LM75A temperature sensor and the LCD1602 display. The LM75A is an I2C temperature sensor that provides accurate temperature readings. It communicates with the Arduino over only two wires, SDA (data line) and SCL (clock line), making it easy to integrate into your projects.

The LCD1602 is a 16x2 character display that can show up to 32 characters at a time. By using the I2C interface, we can control it with just two additional wires, which greatly simplifies the wiring process. The backlight feature of the LCD can also provide better visibility in low-light environments.

Datasheet Details

ManufacturerTexas Instruments
Part numberLM75A
Logic/IO voltage2.7 V to 5.5 V
Supply voltage2.7 V to 5.5 V
Output current (per channel)N/A
Peak current (per channel)N/A
PWM frequency guidanceN/A
Input logic thresholds0.3 * Vcc (low), 0.7 * Vcc (high)
Voltage drop / RDS(on) / saturationN/A
Thermal limitsOperating: -55°C to +125°C
PackageSOT-23
Notes / variantsAvailable in multiple I2C addresses

  • Ensure proper power supply (2.7 V to 5.5 V).
  • Use pull-up resistors on SDA and SCL lines if necessary.
  • Check I2C address configuration for multiple devices.
  • Keep wiring short to minimize interference.
  • Monitor temperature range: -55°C to +125°C.
  • Use serial monitor for debugging temperature readings.
  • Handle error states in code effectively.
  • Be cautious with the display's power requirements.

Wiring Instructions

Arduino_wiring_LM75A_LCD_bb

To wire the LM75A temperature sensor and the LCD1602, begin by connecting the power supply. Connect the VCC pin of both the LM75A and the LCD1602 to the 5V pin on the Arduino. Then, connect the ground (GND) pin of both modules to the GND pin on the Arduino.

Next, connect the I2C communication lines. The SDA pin of the LM75A should be connected to the A4 pin on the Arduino, while the SCL pin should connect to the A5 pin. This allows for I2C communication between the sensor and the Arduino. Make sure the connections are secure to prevent any communication errors.

Code Examples & Walkthrough

In the code, we first include the necessary libraries for the LM75A sensor and the LCD1602 display. The following excerpt demonstrates how to create an instance of the LM75A sensor:

LM75A lm75a_sensor(false, false, false);

This line initializes the LM75A sensor object. The boolean parameters correspond to the A0, A1, and A2 pins of the LM75A, allowing for different I2C addresses if needed.

Next, we set up the serial monitor and initialize the LCD display:

void setup(void) {
  Serial.begin(9600);
  lcd.begin();  
  lcd.backlight();
  lcd.print("Robojax LM75A");
}

Here, we start the serial communication at 9600 baud and initialize the LCD display. The backlight is turned on, and an initial message is printed to the screen.

In the main loop, we continuously read the temperature and display it:

float temperature_in_degrees = lm75a_sensor.getTemperatureInDegrees();
if (temperature_in_degrees == INVALID_LM75A_TEMPERATURE) {
  Serial.println("Error while getting temperature");
}

This section retrieves the temperature from the sensor. If the reading is invalid, an error message is sent to the serial monitor. Otherwise, the temperature can be processed and displayed on the LCD.

Demonstration / What to Expect

Once everything is wired and the code is uploaded, you should see the temperature readings on the LCD1602 display, alternating between Celsius and Fahrenheit. If the LM75A sensor is functioning correctly, it will continuously update the displayed temperature every second. If there are any issues, such as reversed polarity or incorrect wiring, check the connections and ensure the correct pins are used (in video at 00:00).

图像

LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LM75a-1
LM75a-1
LM75a-3
LM75a-3
LM75a-12
LM75a-12
Arduino_wiring_LM75A_LCD_bb
Arduino_wiring_LM75A_LCD_bb
129-LM75A temperature sensor with LCD1602 I2C
语言: C++
已复制!

|||您可能需要的东西

资源与参考

文件📁

Fritzing 文件

其他文件