0% found this document useful (0 votes)
14 views7 pages

Arduino Temperature Sensor Integration

The document describes an assignment to read temperature using an LM35 temperature sensor connected to an Arduino board and trigger LED alerts if the temperature exceeds 26 degrees Celsius. The objectives are to demonstrate the connectivity of the temperature sensor to the Arduino and implement a program where high temperature is indicated by LEDs. The hardware used is a MicroATmega328 microcontroller development board and the software is Arduino IDE. The theory section provides an overview of the Arduino platform and ATmega328 microcontroller. The code reads the temperature, compares it to the threshold, and uses digitalWrite() to control LEDs if needed.

Uploaded by

callhimsid
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)
14 views7 pages

Arduino Temperature Sensor Integration

The document describes an assignment to read temperature using an LM35 temperature sensor connected to an Arduino board and trigger LED alerts if the temperature exceeds 26 degrees Celsius. The objectives are to demonstrate the connectivity of the temperature sensor to the Arduino and implement a program where high temperature is indicated by LEDs. The hardware used is a MicroATmega328 microcontroller development board and the software is Arduino IDE. The theory section provides an overview of the Arduino platform and ATmega328 microcontroller. The code reads the temperature, compares it to the threshold, and uses digitalWrite() to control LEDs if needed.

Uploaded by

callhimsid
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

PART – II

ELECTIVE I

Internet of Things and Embedded Systems

ASSIGNMENT NO: 02

Title: Understanding the connectivity of Raspbeery pi/Adurnio board circuit with temperature
sensor. Write an application to read the environment temperature. If temperature crosses a threshold
value, generate alerts using LEDs.

Objectives:

- To demonstrate connectivity of temperature sensor LM35 and Arduino board


- To implement a program in which temperature beyond 26 degree Celsius would be indicated by
LED.

Outcomes:

Temperature is observed using temperature sensor and display the result on serial monitor.

Hardware : MicroATmega328 Microcontroller development Board.

Software: Arduino IDE

Theory:

Introduction To Arduino

Arduino is an open-source platform used for building electronics projects. Arduino consists of both a
physical programmable circuit board (often referred to as a microcontroller) and a piece of software,
or IDE (Integrated Development Environment) that runs on your computer, used to write and upload
computer code to the physical board. Accepts analog and digital signals as input and gives desired
output.

MicroATmega328-ATmega328 Microcontroller Development Board

The MicroATmega328 is a Arduino compatible Hardware Development Platform from


MicroEmbedded Technologies. It is a full featured board for the beginner as well as the expert user
who is accustomed to the Arduino platform and or the ATmega series microcontroller development.
The MicroATmega328 development board retains all the features of the Arduino Uno board and adds
to it additional interfaces like the 16x2 character LCD, on-board LED’s, USB-to-Serial adaptors, 16
key keypad arranged in 4x4 matrix circuit, on-board Temperature sensor, I2C interface Real Time
Clock, external interrupt, Stepper Motor / DC Motor, SPI based flash programming interface, dual
power source, header for accelerometer and also a Arduino Uno board compatible Header to
interface the easily available Arduino Shield boards. All these features make the MicroAtmega328 a
very versatile and a more robust educational tool for the learner as well as the trainer.

Figure 1 Block Diagram of the MicroATmega328 Board

The ATmega328 is a high-performance 8-bit AVR RISC-based microcontroller. It combines 32KB


ISP flash memory with read-while-write capabilities, 1KB EEPROM, 2KB SRAM, 23 general
purpose I/O lines, 32 general purpose working registers, three flexible timer/counters with compare
modes, internal and external interrupts, serial programmable USART, a byte-oriented 2-wire serial
interface, SPI serial port, 6-channel 10-bit A/D converter, programmable watchdog timer with
internal oscillator, and five software selectable power saving modes. The device operates between
1.8-5.5 volts.

The ATmega328 AVR Microcontroller


Figure 2 ATmega328 AVR Microcontroller

Hardware: Functional Description and Interfacing

Light Emitting Diode (LED)


Light Emitting Diode (LED) is a semiconductor device which emits light at a very low power. They
are highly efficient devices and require very low current in order to operate. A voltage of 5v and
current of 10mA is enough to turn the LED on. The LED has a positive side called the Anode and a
negative side called the Cathode. The current must flow from the Anode to Cathode for the LED to
turn on. On the MicroATmega328 board there are 4 LEDs. The LED’s are connected in the common
cathode method, i.e. all the cathodes are connected together and grounded. The individual Anodes
are connected to the individual Pins of the microcontroller. To turn the LED “ON” the user has to
program the port pin to “HIGH” i.e.”1”.
Note: switch SW20 must be in position 2-3 to operate the LED’s.
Figure 3 LED

Table 1 LED Interfacing Details

LED
Device ATmega328 Pin Arduino Pin Description
LED1 PB2 10 Common Cathode
LED
LED2 PB3 11 Common Cathode
LED
LED3 PB4 12 Common Cathode
LED
LED4 PB5 13 Common Cathode
LED

LM35 Temperature Sensor.

The LM35 is an integrated circuit sensor that can be used to measure temperature with an
electrical output proportional to the temperature (in oC), i.e. it generates a electrical
voltage which is proportional to temperature. The LM35 does not require any calibration
or trimming. The LM35 gives a linear output of 10 mV per degree Centigrade (10mV/ oC)
change in temperature. It operated from -55 oC to 155 oC temperature range. Note: To
use the LM35 temperature sensor on the MicroATmega328 board the switch SW23
must be connected in position 1-2.

Figure 4 Temperature Sensor


LM35 Temperature sensor
Device ATmega328 Pin Arduino Pin Description
LM35 PC0 A0 LM35 sensor
output

ARDINO IDE OVERVIEW

1. To create a new sketchFile -> New


• To open an existing sketch File -> open ->
• There are some basic ready-to-use sketches available in the EXAMPLES section
• File -> Examples -> select any program

Program coded in Arduino IDE is called a SKETCH
2. Verify: Checks the code for compilation errors
3. Upload: Uploads the final code to the controller board
4. New: Creates a new blank sketch with basic structure
5. Open: Opens an existing sketch
6. Save: Saves the current sketch

Serial Monitor: Opens the serial console


All the data printed to the console are displayed here
Figure 5 Structure of Sketch

A sketch can be divided into two parts:


Setup ()
Loop()
The function setup() is the point where the code starts, just like the main() function in C and C++
I/O Variables, pin modes are initialized in the Setup() function Loop() function, as the name
suggests, iterates the specified task in the program
DATA TYPES:
Void ,Long, Int ,Char ,Boolean, Unsigned char ,Byte, Unsigned int, Word ,Unsigned long ,Float,
Double, Array ,String-char array, String-object, Short
Arduino Function libraries
Input/Output Functions:
The arduino pins can be configured to act as input or output pins using the pinMode() function
Void setup ()
{
pinMode (pin , mode);
}
Pin- pin number on the Arduino board Mode- INPUT/OUTPUT
digitalWrite() : Writes a HIGH or LOW value to a digital pin
analogRead() : Reads from the analog input pin i.e., voltage applied across the pin
Character functions such as isdigit(), isalpha(), isalnum(), isxdigit(), islower(), isupper(), isspace()
return 1(true) or 0(false)
Delay() function is one of the most common time manipulation function used to provide a delay of
specified time. It accepts integer value (time in miliseconds)

Program

Write down code which we have implemented in practical and paste screenshot which we have done
in practical.

Common questions

Powered by AI

The Arduino IDE facilitates the development of IoT applications on platforms like the MicroATmega328 board by providing a user-friendly environment for writing, verifying, and uploading code. It includes an integrated serial monitor for debugging, built-in libraries for various sensors and modules, and a straightforward setup() and loop() program structure that simplifies coding tasks. The IDE also offers example sketches and a supportive online community, which accelerates the learning curve for developers. These features enable efficient development and testing of IoT applications that involve sensor data collection and actuator control, such as monitoring temperature and triggering alerts .

Digital signal processing in the Arduino platform involves converting analog signals from sensors into digital signals that the microcontroller can interpret and process. In a typical IoT application scenario, such as monitoring environmental temperature using an LM35 sensor, the Arduino board reads the analog voltage output from the sensor through an analog pin using the analogRead() function. This function converts the analog voltage to a digital value, which can then be used in calculations or comparisons within the program. This digital signal processing is crucial for executing control actions, such as activating LEDs when the temperature exceeds a predetermined threshold, enabling real-time monitoring and control in IoT systems .

In the Arduino IDE, applications for the MicroATmega328 board are developed using a combination of programming constructs such as the setup() and loop() functions, data types, and input/output libraries. The setup() function initializes the board's configuration, including setting pins as INPUT or OUTPUT using pinMode(). The loop() function contains the code to be executed repeatedly, which is essential for tasks like continuously monitoring sensor data and controlling LEDs. Data types like int, boolean, and float manage variables. Input/output libraries provide functions such as digitalWrite() for setting pin states, analogRead() for reading sensor values, and delay() for timing control. Together, these constructs allow for creating robust applications that perform specific tasks based on sensor inputs and actuator outputs .

The integration of the LM35 temperature sensor with the MicroATmega328 board allows for temperature monitoring by utilizing the sensor's ability to measure temperature as an electrical output that is linearly proportional to temperature changes (10mV/°C). The LM35 sensor's output is connected to the PC0 pin (A0 in Arduino terms) on the MicroATmega328 board. For temperature monitoring, the software part is handled by the Arduino IDE, which is used to write and upload the program to the MicroATmega328. The IDE provides functions such as analogRead() to read the sensor's output voltage, which corresponds to the measured temperature. The setup() function initializes the environment, including setting up input/output modes, and the loop() function continuously checks the temperature and, if necessary, triggers an alert by turning on an LED if the temperature exceeds a set threshold .

In an Arduino sketch, the setup() block is used to initialize variables, pin modes, and any libraries needed for the program. It is executed only once, when the sketch starts, ensuring that the environment is correctly set up before any operation begins. The loop() block, on the other hand, contains the core logic and is executed repeatedly. For a temperature monitoring system, the setup() function would configure the temperature sensor pin as INPUT and set up serial communication for logging data. The loop() would continuously read temperature values, check if they exceed a threshold, and turn on an LED alert if necessary, simulating an ongoing monitoring system. This structure facilitates real-time sensor data processing and control actions in IoT applications .

The benefits of using the LM35 temperature sensor with a microcontroller like the ATmega328 in IoT applications include precise and linear temperature readings, minimal need for calibration, and a wide operating range from -55°C to 155°C. The LM35 outputs a voltage linearly proportional to the temperature, allowing for simple interfacing with microcontrollers via analog input pins. When connected to an ATmega328, the sensor can be used to implement temperature-based controls and alerts, effectively enabling real-time monitoring and response systems. This integration is particularly advantageous for developing efficient, reliable, and responsive IoT solutions .

The common cathode configuration in LED interfacing enhances the functionality of the MicroATmega328 board by simplifying the control of multiple LEDs. In this setup, all the cathodes of the LEDs are connected together and grounded. Each individual LED can be controlled by applying a digital signal to its anode, which is connected to a corresponding pin on the microcontroller (e.g., LEDs 1-4 are connected to PB2-PB5, corresponding to Arduino pins 10-13). This configuration allows efficient control of multiple LEDs while reducing the number of necessary ground connections, and it enables the use of fewer digital I/O lines to control a larger number of outputs .

The MicroATmega328 board is suitable for both beginners and expert users due to its compatibility with the Arduino platform and additional features that enhance its versatility. This includes interfaces such as a 16x2 character LCD, on-board LEDs, a USB-to-Serial adaptor, a 16-key keypad, a real-time clock, and a temperature sensor. It also supports both digital and analog signal inputs. The board's compatibility with external shields and multiple communication protocols (e.g., I2C, SPI, USART) further enhances its flexibility. These features provide a robust educational tool for learners to experiment with various components while allowing expert users to develop more complex applications .

The MicroATmega328 board handles power supply variations through its ability to operate over a voltage range of 1.8-5.5 volts and by providing multiple power supply options, including a dual power source. This flexibility in power management allows the board to maintain stable operation despite variations in external power sources. The advantages of these features include increased reliability and versatility, particularly for applications in environments with fluctuating power conditions. Additionally, having multiple power supply options enables the board to seamlessly transition between power sources, reducing the risk of system resets or failures during power supply changes .

The MicroATmega328 board enhances learning and prototyping capabilities by offering a versatile platform with features that support a wide range of educational and development activities. Its compatibility with the Arduino ecosystem allows access to numerous tutorials and community knowledge. Additionally, the board provides built-in components such as a character LCD, temperature sensor, real-time clock, keypad, and various communication interfaces (like I2C and SPI), allowing for immediate hands-on experimentation across different projects without additional hardware. This feature set supports learning by doing, enabling seamless transition from theoretical concepts to practical applications in IoT development .

You might also like