[go: up one dir, main page]

0% found this document useful (0 votes)
11 views20 pages

Arduino 5th Day

The document provides an overview of working with analog and digital data in Arduino, highlighting the differences between the two types of data and how to use analogRead() for reading sensor values. It discusses temperature and humidity sensors, their working principles, and includes a project example for monitoring compost conditions. Key takeaways include understanding data types, using analogRead(), and converting sensor readings to voltage.

Uploaded by

monteban314
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views20 pages

Arduino 5th Day

The document provides an overview of working with analog and digital data in Arduino, highlighting the differences between the two types of data and how to use analogRead() for reading sensor values. It discusses temperature and humidity sensors, their working principles, and includes a project example for monitoring compost conditions. Key takeaways include understanding data types, using analogRead(), and converting sensor readings to voltage.

Uploaded by

monteban314
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Working with

Analog and
Digital Data in
Arduino
● Analog Data vs Digital Data
Overview ● Using analogRead()
● Temperature and Humidity
Sensors
Analog Data vs Digital Data
Analog Data:

● Continuous data representing physical quantities.

Digital Data:

● Discrete data using sampling to represent analog values.

Analog Data vs Examples:

Digital ●

Analog: Picture, sound waves.
Digital: Digital images, binary code.

Data(revision)
Analog Sensors:

● Measure physical quantities like temperature, humidity, or light.


Working with Digital Conversion:

Analog Data on ● Arduino can convert analog signals to digital and vice versa
using converters.
Arduino
Function:

● Converts analog signals to digital values.


Analog to Digital Usage in Arduino:

Converter (ADC) ● Analog pins (A0-A5) read analog signals.


Function:

● Converts digital values back to analog signals.


Digital to Analog Usage in Arduino:

Converter (DAC) ● DAC is used in generating analog output signals.


Using analogRead()
analogRead()
Function:

● Reads analog values from analog pins.

Syntax:

● int sensorValue = analogRead(sensorPin);

Range:

● Returns values between 0 and 1023.


Converting Sensor
Readings to
Voltage Conversion Formula:

● voltage = sensorValue * (5.0 / 1023.0);

Example:

● For a sensor reading of 512, the voltage is approximately 2.5V.


● Exercise:

Exercise: Sensor ●

Steps:
Calculate the voltage for a sensor reading of 512.

Use the formula voltage = sensorValue * (5.0


Reading to Voltage ○
/ 1023.0);
● Answer:
Conversion ○ Voltage ≈ 2.5V.
Temperature and Humidity
Sensors
● Definition:
○ Measures environmental temperature.

Temperature ● Working Principle:


○ Voltage across a diode changes with temperature.

Sensor Amplification:

● Voltage change is amplified to generate an analog signal.


● Definition:
○ Measures water vapor in the air.

Humidity Sensor ● Working Principle:


○ Changes in resistance, capacitance, or temperature
caused by moisture.

Examples:

● TMP36, LM35.

TMP36:

● Outputs voltage proportional to temperature in degrees Celsius.

Different Types of
Temperature
Sensors
Project: Compost
Monitoring System
Objective:

● Monitor temperature and humidity levels in compost.


Project Overview Components:

● Arduino, TMP36 temperature sensor, humidity sensor.


Steps:

Building the Circuit ● Connect the TMP36 sensor and humidity sensor to the Arduino.

Connections:

● TMP36: VCC to 5V, GND to GND, Signal to A0.


● Humidity Sensor: VCC to 5V, GND to GND, Signal to A1.
Writing the Code

Explanation:

● Reads analog values, converts to


temperature and humidity, and prints
to Serial Monitor.
● Learned about analog and digital data.
Key Takeaways ● Used analogRead() to read sensor
values.
● Converted sensor readings to voltage.
● Built a project to monitor compost
conditions.

You might also like