Soluții

Arduino Temperature Sensor

You’ll build a simple digital thermometer that measures ambient temperature using a temperature sensor (like the LM35, TMP36, or DHT11) and displays the reading via the Serial Monitor or LCD screen.

We’ll cover two main versions:

  1. Basic Version — Using an analog temperature sensor (LM35 or TMP36).

  2. Advanced Version — Using a digital sensor (DHT11 or DHT22) with humidity support.

Materials Needed

Component Quantity Description
Arduino Uno (or Nano/Mega) 1 The main microcontroller board
LM35 or TMP36 sensor 1 Analog temperature sensor
Breadboard 1 For easy circuit assembly
Jumper wires ~6 Male-to-male wires
USB cable 1 To connect Arduino to your computer
(Optional) 16×2 LCD Display 1 For local display
(Optional) 10kΩ Potentiometer 1 LCD contrast control

Step 1: Understand the Sensor

 LM35 Pinout

Pin Label Function
1 VCC +5V from Arduino
2 VOUT Analog output (connect to Arduino analog input)
3 GND Ground

The LM35 outputs 10 mV per °C.
So if the output voltage = 250 mV → temperature = 25°C.

Step 2: Wiring the LM35 to Arduino

Connections

LM35 Pin Connects To
VCC 5V on Arduino
GND GND on Arduino
VOUT A0 on Arduino

Circuit Diagram (Text Form)

[Arduino 5V] ---- [LM35 VCC]
[Arduino GND] ---- [LM35 GND]
[Arduino A0] ---- [LM35 OUT]

Step 3: Arduino Code (LM35 Version)

// Simple Temperature Sensor with LM35

const int sensorPin = A0; // LM35 connected to A0
float temperatureC;

void setup() {
Serial.begin(9600);
Serial.println(“LM35 Temperature Sensor”);
}

void loop() {
int sensorValue = analogRead(sensorPin); // Read analog value
float voltage = sensorValue * (5.0 / 1023.0); // Convert to voltage
temperatureC = voltage * 100; // 10mV per degree C (LM35)

Serial.print(“Temperature: “);
Serial.print(temperatureC);
Serial.println(” °C”);

delay(1000); // Update every second
}

Explanation

  • analogRead(A0): reads 0–1023 corresponding to 0–5V.

  • Voltage calculation: (value * 5.0) / 1023.0.

  • LM35 output scaling: 10 mV = 1°C → multiply voltage by 100.

Step 4: Viewing Data

  • Open Arduino IDE → Tools → Serial Monitor.

  • Set baud rate = 9600.

  • You’ll see continuous readings like:

    Temperature: 24.87 °C
    Temperature: 25.02 °C

Step 5: Calibration (Optional)

Real sensors may have small offsets.
You can adjust the output manually:

temperatureC = (voltage * 100) - 0.5; // Adjust by small offset

Compare readings with a known thermometer and tweak the offset until accurate.

Advanced: Using DHT11 / DHT22 (Digital Sensor)

Required Library

  • Install “DHT sensor library” by Adafruit from Arduino Library Manager.

Wiring (DHT11)

DHT11 Pin Connects To
VCC 5V
GND GND
DATA Digital Pin 2

Code (DHT11)

#include "DHT.h"

#define DHTPIN 2 // Data pin connected to digital pin 2
#define DHTTYPE DHT11 // or DHT22

DHT dht(DHTPIN, DHTTYPE);

void setup() {
Serial.begin(9600);
dht.begin();
}

void loop() {
float tempC = dht.readTemperature();
float humidity = dht.readHumidity();

if (isnan(tempC) || isnan(humidity)) {
Serial.println(“Failed to read from DHT sensor!”);
return;
}

Serial.print(“Temperature: “);
Serial.print(tempC);
Serial.print(” °C, Humidity: “);
Serial.print(humidity);
Serial.println(” %”);

delay(2000);
}

Step 6: (Optional) Display on LCD

If using a 16×2 LCD (I2C):

  1. Install “LiquidCrystal_I2C” library.

  2. Connect SDA → A4, SCL → A5.

  3. Example snippet:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
lcd.init();
lcd.backlight();
}

void loop() {
lcd.setCursor(0, 0);
lcd.print(“Temp: “);
lcd.print(temperatureC);
lcd.print(“C”);
}

Troubleshooting Guide

Issue Possible Cause Solution
No readings / 0°C Wrong wiring or pin Check sensor pins
Negative readings Wrong sensor type (TMP36 needs offset) Adjust formula
Unstable readings Noisy analog signal Add capacitor (0.1 µF) between VOUT & GND
“nan” or “Failed to read” DHT library issue Check sensor type & connections

Next Steps & Enhancements

  • Add OLED / LCD display for portable thermometer

  • Store data using SD card module

  • Upload readings to the cloud via ESP8266 / WiFi module

  • Use RGB LED to indicate temperature range (blue/cool, red/hot)

  • Build an IoT dashboard (ThingSpeak, Blynk, etc.).

[mai mult...]

How to find and remove ‘Stalkerware’ from your Phone

While your mobile device has a lot of built-in features to keep your data secure and protect your privacy, it may still be vulnerable to snooping if someone you know has access to your accounts or manages to install hidden apps—known as stalkerware—that track your every move. These malicious programs may exploit built-in features and permissions on your iPhone or Android to spy on you.

[mai mult...]

How to tell if a Phone App is invading your Privacy

If you have a smartphone and spend any time on the internet, it’s likely that at least some of your personal data has been collected, shared, and sold at some point. Many apps you use every day are highly invasive—but you don’t have to make it easy for companies and data brokers to obtain and use your information.

[mai mult...]

Your iPhone’s Camera comes with a hidden translator

I recently took a trip to Europe, hopping across a few countries that all spoke languages I didn’t understand. As such, in order to interpret menus, signs, and packaging, I needed to translate the text back into English. While you might assume you need to use a specific translator app of choice to get this done, you really only need one thing: your iPhone’s camera.

[mai mult...]