LM75 with Arduino, LM75 I2C, LM75A Arduino Library, CJMCU-75 temperature sensor
How to connect LM75 or CJMCU-75 temperature sensor with Arduino
Table of Contents
LM75 Temperature Sensor:
LM75 with Arduino, LM75 I2C, LM75A Arduino Library, CJMCU-75 temperature sensor- In this article, you will learn how to make a temperature monitoring system using I2C supported LM75 or CJMCU-75 or LM75A sensor module, Arduino Nano, I2C supported SSD1306 Oled display module, and a 5V buzzer.
So far, I have covered majority of the temperature sensors, including DHT11 Temperature and Humidity Sensor, BMP180 Temperature, pressure, and Altitude sensor, DS18b20 one-wire digital temperature sensor, MLX90614 infrared temperature sensor, MAX6675 K-type thermocouple, and so many other sensors.
I have these different types of sensors which I have already used in basic, intermediate, and advanced level projects. Every temperature sensor has got unique features on the basis of which it is used in different projects.
If you want to monitor temperature and humidity then you can use the popular DHT11 sensor.
If you want to measure or monitor the temperature of the water or any other liquid then you can use the DS18b20 one-wire waterproof digital temperature sensor.
If along with the temperature, you also want to measure pressure and altitude then you can use BMP180 sensor.
If you want to measure the temperature of humans, animals, or other objects without physical contact then you can use the MLX90614 infrared temperature sensor. Using this sensor, you can make a non-contact thermometer or temperature monitor for patients, for example, the Covid patients. MLX90614 is insanely fast and accurate. Recently, I used it with the ESP8266 WiFi module and I designed myself an IoT temperature monitoring system.
If you want to measure high temperatures up to 1000 degrees Celsius then you can use the MAX6675 amplifier board and K-type thermocouple.
So, this was a brief introduction to these different types of temperature sensors, and now you can decide yourself which temperature sensor you need for your project. Anyway, let’s get back to our original topic.
Before I am going to explain the features, specifications, it’s interfacing with the Arduino, and programming. First, let’s watch the LM75A temperature sensor in action.
I have connected the LM75 temperature sensor, Oled display module, and the 5V buzzer as per the circuit diagram which I will explain in a minute. I have done it’s programming in a way that it displays the temperature in Celsius and Fahrenheit on the Oled display module. Besides this, I have also added a limit; so whenever the temperature exceeds that limit the buzzer will immediately turn ON.
On the Oled display module, you can see temperature in Celsius and Fahrenheit. This is the ambient temperature, its 4th of June 2022 while I am testing this project. Nowadays the weather in Pakistan is really hot. Anyway, now I am going to place this sensor somewhere, where the sunlight will directly fall on the temperature sensor.
Just look at the temperature, the global warming is really destroying this planet and this is because of the excessive Carbon dioxide emission. Now, let’s go ahead and apply some heat to check if the buzzer will turn ON. Right now the temperature threshold value is 45 Celsius.
I applied heat to the LM75A temperature sensor and as soon as the temperature crossed the threshold value of 45 Degrees Celsius the buzzer turned ON. For the practical demonstration watch video tutorial given at the end of this article. I am sure by now, you might have got an idea of how does this system work. So, without any further delay let’s get started!!!
Amazon Links:
Arduino Nano USB-C Type (Recommended)
LM75A I2C supported Temperature Sensor
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
LM75 Temperature Sensor:
This is the CJMCU-75 I2C supported temperature sensor which is also known as LM75 or LM75A temperature sensor. With this temperature sensor, you can read temperature in both Celsius and Fahrenheit. The temperature range is from -55 Celsius to +125 degree Celsius.
The LM75A is an industrial standard digital temperature sensor with an integrated sigma-delta analog-to-digital converter (ADC). The LM75A provides 9-bit digital temperature readings with an accuracy of ±2°C from –25°C to 100°C and with an accuracy of ±3°C over –55°C to 125°C.
The LM75A operates with a single supply from 2.7 V to 5.5 V. Due to this wide range of input voltages it can be easily used with 3.3V compatible controller boards like esp8266, ESP32, etc., and 5V compatible controller boards.
Communication is accomplished over a 2-wire interface which operates up to 400 kHz. LM75A has three selectable logic address pins A0, A1, and A2, allowing up to eight LM75A devices to operate on the same 2-wire bus. A0, A1, and A2 can be used to set an I2C address. You can short any of these address pins with the VCC or ground. This way you will be able to connect 8 temperature sensors without any address conflict.
The LM75A has a dedicated over-temperature output (O.S.) with programmable limit and hysteresis.
LM75A temperature sensor can be used in base stations, electronic test equipment, office electronics, personal computers, Environmental Monitoring, and any other system in which thermal management is critical to performance. Now, let’s take a look at the circuit diagram.
LM75A interfacing with Arduino:
The SCL and SDA pins of the LM75A temperature sensor and Oled display module are connected together and then connected with the Arduino A5 and A4 pins. A5 is the SCL and A4 is the SDA. While the VCC and GND pins are connected with the Arduino 5V and GND pins.
The 5V buzzer is controlled using D3 pin of the Arduino. We use 2n2222 NPN transistor and a 10K ohm resistor to control the 5V buzzer. The transistor and resistor make the driver circuit.
On the left side is the 5V regulated power supply based on the LM7805 voltage regulator. The output of the 5V regulated power supply is connected with the Vin pin of the Arduino. Since I am using 7805 voltage regulator, so I can use voltages between 7 and 28 volts to power up the Arduino. Due to this wide input voltage range, I can use a 12V adaptor, a battery, solar panel etc. to power up the Arduino.
Required Libraries for LM75:
Before, you start the programming, first of all, make sure you download all the necessary libraries. The Adafruit_GFX.h and Adafruit_SSD1306.h libraries I have been using for quite a long time and I have already explained how to download and use these libraries.
You will also need the LM75A library.
To add this library simply click on the Sketch menu and then go to Include Library and click on the Add ZIP library… browse to the desired location and select the zip folder and then finally click on the open button.
As I have already added this library so I will click on the cancel button.
LM75A Arduino programming:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
#include <SPI.h> // include libraries #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <LM75A.h> // Create I2C LM75A instance LM75A lm75a_sensor(false, // A0 LM75A pin state (connected to ground = false) false, // A1 LM75A pin state (connected to ground = false) false); // A2 LM75A pin state (connected to ground = false) // Equivalent to "LM75A lm75a_sensor;" #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); int buzzer = 3; void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial.println("Temperatures will be displayed every second:"); display.begin(SSD1306_SWITCHCAPVCC, 0x3C); delay(2000); display.clearDisplay(); display.setTextColor(WHITE); pinMode(buzzer, OUTPUT); } void loop() { // put your main code here, to run repeatedly: float temperature_in_degrees = lm75a_sensor.getTemperatureInDegrees(); if (temperature_in_degrees == INVALID_LM75A_TEMPERATURE) { Serial.println("Error while getting temperature"); } else { Serial.print("Temperature: "); Serial.print(temperature_in_degrees); Serial.print(" degrees ("); Serial.print(LM75A::degreesToFahrenheit(temperature_in_degrees)); Serial.println(" fahrenheit)"); if ( temperature_in_degrees >= 45 ) { digitalWrite( buzzer, HIGH); Serial.println(" Temperature Alert! "); } if ( temperature_in_degrees < 45 ) { digitalWrite( buzzer, LOW); } display.clearDisplay(); display.setCursor(25,0); display.setTextSize(1); display.setTextColor(WHITE); display.println(" Temperature"); display.setCursor(10,20); display.setTextSize(2); //display.print("C: "); display.print(temperature_in_degrees); display.print((char)247); display.print("C"); display.setCursor(10,45); display.setTextSize(2); //display.print("F: "); display.print(LM75A::degreesToFahrenheit(temperature_in_degrees)); display.print((char)247); display.print("F"); display.display(); } delay(1000); } |
The purpose of this program is to read the temperature in Celsius and Fahrenheit; And to check if the temperature has above or below the threshold value. If the temperature has exceeded 45 degrees Celsius then turn ON the buzzer and if the temperature is below 45 degrees Celsius then turn OFF the buzzer. Besides this I also print the temperature values on the Oled display module. So, that’s all about the programming.
Watch Video Tutorial: