Interfacing Analog temperature sensor with Bharat Pi
INTERFACING ANALOG TEMP SENSOR USING BHARATHPI
Introduction of BHARATPI:
A single board architecture with compute, network and storage designed to build any IoT idea into a product. The board comes with a ESP32 Wroom 4MB memory + WiFi + Bluetooth + SD card slot. You can program the board using Arduino IDE or microPython. All ESP programs are compatible with Bharat Pi boards.
Introduction of Analog Sensor:
The LM35 or analog temp sesnor is a low voltage, precision centigrade temperature sensor manufactured by Texas Instruments. It is a chip that provides a voltage output that is linearly proportional to the temperature in °C .This temperature sensor is fairly precise, never wears out, works under many environmental conditions and requires no external components to work. In addition, this sensor does not require calibration and provides a typical accuracy of ±0.5°C at room temperature and ±1°C over a full −55°C to +155°C temperature range.
STEP 1:How Analog Sensor Works?
The
LM35 temperature sensor uses the basic principle of a diode to measure known
temperature value. As we all know from semiconductor physics, as the
temperature increases the voltage across a diode increases at a known rate. By
accurately amplifying the voltage change, we can easily generate a voltage
signal that is directly proportional to the surrounding temperature.
STEP
2:Analog Temp Pinout
· Vcc
- Connect to the 3.3v or 5v
· Gnd
- Connect to the gnd
· Signal
– Any GPIO pin ( pin 34)
STEP 3:Requirements
·
Analog Temperature Sensor
· Connecting wires
Arduino IDE
STEP 4:Interfacing Analog
Temp with Bharathpi
Steps:
- Connect the Temperature Sensor to Arduino:
- Connect the analog temperature sensor to the Arduino as follows:
- Connect the sensor's VCC pin to the Arduino's 5V pin.
- Connect the sensor's GND (Ground) pin to the Arduino's GND pin.
- Connect the sensor's OUT (Analog Output) pin to any of the Arduino's analog pins (e.g., A0).
- Write a simple Arduino sketch to read the analog voltage from the temperature sensor and convert it to temperature in degrees Celsius or Fahrenheit, depending on the sensor's datasheet.
- Connect Arduino to Bharat Pi
- You can connect your Arduino to the Bharat Pi board using a USB cable. The Arduino will communicate with the Bharat Pi board via the USB connection.
- Monitor Temperature Data:
- Open the Arduino IDE Serial Monitor to see the temperature data being printed by the Arduino. The data will be displayed in both Celsius and Fahrenheit.
- This setup will allow you to read temperature data from the analog sensor using the Arduino and then connect the Arduino to the Bharat Pi board to further process or display the temperature data as needed for your project.
STEP 5:Source Code and
Programming
// Include
the necessary libraries
#include <Arduino.h>
// Define
the analog pin to which the LM35 sensor is connected
const int analogPin = 34; // You can use any available
analog pin on your ESP32
void setup() {
Serial.begin(115200); // Initialize serial
communication for debugging
}
void loop() {
//
Read the analog value from the LM35 sensor
int rawValue = analogRead(analogPin);
//
Convert the raw analog value to temperature in Celsius
float voltage = (rawValue / 4095.0) * 3.3; // Convert to voltage (3.3V is
the ESP32 reference voltage)
float temperatureC = (voltage - 0.5) * 100.0; // LM35 has a scale factor of
10 mV/°C
//
Print the temperature value to the serial monitor
Serial.print("Temperature (Celsius):
");
Serial.println(temperatureC);
delay(1000); // Delay for 1 second before
taking the next reading
}
GitHub link:https://github.com/PuneeethG/Sensor-Interfacing/blob/main/analogtemp/analogtemp.ino
STEP 6:Application
HVAC Systems: Controlling indoor climate in buildings.
Industrial Process
Control: Monitoring and regulating temperatures in manufacturing.
Environmental Monitoring:
Providing data for weather forecasting and climate research.
Medical Devices:
Measuring body and environment temperatures.
Comments
Post a Comment