SlideShare a Scribd company logo
Embedded System Design Jigar Makhija
1 17-Jul-19
Device: TM4C123G
Description
The TM4C123G Launchpad Evaluation Kit is a low-cost evaluation platform for ARM Cortex-M4F
based microcontrollers from Texas Instruments. The design of the TM4C123G Launchpad highlights
the TM4C123GH6PM microcontroller with a USB 2.0 device interface and hibernation module.
Figure 1.1- Basic Architecture of ARM Cortex TM4C123G
Embedded System Design Jigar Makhija
2 17-Jul-19
Figure 1.2: Detail Pin Diagram for TM4C123G
Configuration & Tools:
Energia IDE: https://energia.nu/download/
Note: Install Appropriate Drivers
Reference : https://energia.nu/pinmaps/ek-tm4c123gxl/
Embedded System Design Jigar Makhija
3 17-Jul-19
Basic Programs:
1) Blinking LED:
Code:
/*
Blink
The basic Energia example.
Turns on an LED on for one second, then off for one second, repeatedly.
Change the LED define to blink other LEDs.
Hardware Required:
* LaunchPad with an LED
This example code is in the public domain.
*/
// most launchpads have a red LED
#define LED RED_LED
//see pins_energia.h for more LED definitions
//#define LED GREEN_LED
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(LED, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Embedded System Design Jigar Makhija
4 17-Jul-19
2) Digital Serial Read:
Code:
/*
DigitalReadSerial with on-board Pushbutton
Reads a digital input on pin 31, prints the result to the serial monitor
// digital pin 5 has a pushbutton attached to it. Give it a name:
int pushButton = 31;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600); // msp430g2231 must use 4800
// make the on-board pushbutton's pin an input pullup:
pinMode(pushButton, INPUT_PULLUP);
}
// the loop routine runs over and over again forever:
void loop() {
Embedded System Design Jigar Makhija
5 17-Jul-19
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
Serial.println(buttonState);
delay(1); // delay in between reads for stability
}
3) Temperature Humidity:
Device Required: DHT11
Package need to be installed and imported:
Install:
- Adafruit Unified Sensor Library: https://github.com/adafruit/Adafruit_Sensor
- DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library
Importing Library: Sketch->Include Library->Add. Zip Library
Embedded System Design Jigar Makhija
6 17-Jul-19
Code:
// DHT Temperature & Humidity Sensor
// Unified Sensor Library Example
// - Adafruit Unified Sensor Library: https://github.com/adafruit/Adafruit_Sensor
// - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 05 // Pin which is connected to the DHT sensor.
// Uncomment the type of sensor in use:
#define DHTTYPE DHT11 // DHT 11
// See guide for details on sensor wiring and usage:
// https://learn.adafruit.com/dht/overview
DHT_Unified dht(DHTPIN, DHTTYPE);
uint32_t delayMS;
void setup() {
Serial.begin(9600);
// Initialize device.
dht.begin();
Serial.println("DHTxx Unified Sensor Example");
// Print temperature sensor details.
sensor_t sensor;
dht.temperature().getSensor(&sensor);
Serial.println("------------------------------------");
Serial.println("Temperature");
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" *C");
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" *C");
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" *C");
Serial.println("------------------------------------");
// Print humidity sensor details.
dht.humidity().getSensor(&sensor);
Serial.println("------------------------------------");
Embedded System Design Jigar Makhija
7 17-Jul-19
Serial.println("Humidity");
Serial.print ("Sensor: "); Serial.println(sensor.name);
Serial.print ("Driver Ver: "); Serial.println(sensor.version);
Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id);
Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println("%");
Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println("%");
Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println("%");
Serial.println("------------------------------------");
// Set delay between sensor readings based on sensor details.
delayMS = sensor.min_delay / 1000;
}
void loop() {
delay(delayMS);
sensors_event_t event;
dht.temperature().getEvent(&event); /* Read temperature value */
if (isnan(event.temperature)) { /* If temperature value is not a number */
Serial.println("Error reading temperature!");
}
else {
Serial.print("Temperature : ");
Serial.print(event.temperature);
Serial.println(" *C");
}
dht.humidity().getEvent(&event); /* Read humidity value */
if (isnan(event.relative_humidity)) { /* If humidity value is not a number */
Serial.println("Error reading humidity!");
}
else {
Serial.print("Humidity : ");
Serial.print(event.relative_humidity);
Serial.println("%");
}
}
Embedded System Design Jigar Makhija
8 17-Jul-19
4) LED Blink through Bluetooth Terminal from Mobile
Hardware: HC-05
Mobile App: Any HC-05 Terminal Application from Play store
Code:
#define LED RED_LED
void setup() {
Serial1.begin(9600); /* Define baud rate for serial communication */
pinMode(LED, OUTPUT);
}
void loop() {
if (Serial1.available()) /* If data is available on serial port */
{
char data_received;
data_received = Serial1.read(); /* Data received from bluetooth */
if (data_received == '1')
{
digitalWrite(LED, HIGH);
Serial1.write("nLED turned ON");
Embedded System Design Jigar Makhija
9 17-Jul-19
}
else if (data_received == '2')
{
digitalWrite(LED, LOW);
Serial1.write("nLED turned OFF");
}
else
{
Serial1.write("nSelect either 1 or 2");
}
}
}
5) A6 GSM Module for Calling and Messaging.
Hardware: A6 GSM/GPRS
Resources: 2G or 3G Sim Card
Embedded System Design Jigar Makhija
10 17-Jul-19
Code – Testing AT Commands:
void setup() {
//Begin serial communication (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Energia and A6
Serial1.begin(9600);
Serial.println("Initializing...");
delay(1000);
Serial1.println("AT"); //Once the handshake test is successful, it will back to OK
updateSerial();
Serial1.println("AT+CSQ"); //Signal quality test, value range is 0-31 , 31 is the best
updateSerial();
Serial1.println("AT+CCID"); //Read SIM information to confirm whether the SIM is plugged
updateSerial();
Serial1.println("AT+CREG?"); //Check whether it has registered in the network
updateSerial();
}
void loop() {
updateSerial();
}
void updateSerial()
{
delay(500);
while (Serial.available())
{
Serial1.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(Serial1.available())
{
Serial.write(Serial1.read());
//Forward what Software Serial received to Serial Port
}
}
Embedded System Design Jigar Makhija
11 17-Jul-19
AT – It is the most basic AT command. It also initializes Auto-baud’er. If it works
you should see the AT characters echo and then OK, telling you it’s OK and it’s
understanding you correctly! You can then send some commands to query the
module and get information about it such as
AT+CSQ – Check the ‘signal strength’ – the first # is dB strength, it should be
higher than around 5. Higher is better. Of course, it depends on your antenna
and location!
AT+CCID – get the SIM card number – this tests that the SIM card is found OK
and you can verify the number is written on the card.
AT+CREG? Check that you’re registered on the network. The second # should
be 1 or 5. 1 indicates you are registered to home network and 5 indicates
roaming network. Other than these two numbers indicate you are not registered
to any network.
ATI – Get the module name and revision
AT+COPS? – Check which network you are connected to, in this case 40466
(BSNL)
AT+COPS=? – Return the list of operators present in the network.
Embedded System Design Jigar Makhija
12 17-Jul-19
Code – Sending SMS/ Reading SMS
void setup() {
//Begin serial communication with Energia and Energia IDE (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Energia and A6
Serial1.begin(9600);
Serial.println("Initializing...");
delay(1000);
Serial1.println("AT"); //Once the handshake test is successful, it will back to OK
updateSerial();
Serial1.println("AT+CMGF=1"); // Configuring TEXT mode
updateSerial();
//Module to Send Message
/*Serial1.println("AT+CMGS="+91xxXXXXXXXX"");//change ZZ with country code and xxxxxxxxxxx
with phone number to sms
updateSerial();
Serial1.print("Last Minute TEST | Successful"); //text content
*/
//Code to Read Current New Messages
Serial1.println("AT+CNMI=1,2,0,0,0"); // Decides how newly arrived SMS messages should be handled
Embedded System Design Jigar Makhija
13 17-Jul-19
updateSerial();
// Serial1.write(26); //Remove Comment for Serial write to Send Message
}
void loop() {
updateSerial();
}
void updateSerial()
{
delay(500);
while (Serial.available())
{
Serial1.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(Serial1.available())
{
Serial.write(Serial1.read());//Forward what Software Serial received to Serial Port
}
}
Sending:
The sketch is almost same as earlier except below code snippet. Once the
connection is established, we send below AT commands:
AT+CMGF=1 – Selects SMS message format as text. Default format
is Protocol Data Unit (PDU)
AT+CMGS=+ZZxxxxxxxxxx – Sends SMS to the phone number specified. Once
we send a message.
Receiving:
The sketch is similar as earlier except below code snippet. Once the connection
is established, we send below AT commands:
Embedded System Design Jigar Makhija
14 17-Jul-19
AT+CMGF=1 – Selects SMS message format as text. Default format
is Protocol Data Unit (PDU)
AT+CNMI=1,2,0,0,0 – specifies how newly arrived SMS messages should be
handled. This way you can tell the A6 module either to forward newly arrived
SMS messages directly to the PC, or to save them in message storage and then
notify the PC about their locations in message storage.
Its response starts with +CMT: All the fields in the response are comma-
separated with first field being phone number. The second field is the name of
person sending SMS. Third field is a timestamp while forth field is the actual
message.
Sending
Receiving
Embedded System Design Jigar Makhija
15 17-Jul-19
Code – Making Call/ Receiving Call
void setup() {
//Begin serial communication with Energia and Energia IDE (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Energia and A6
Serial1.begin(9600);
Serial.println("Initializing...");
delay(1000);
Serial1.println("AT"); //Once the handshake test is successful, it will back to OK
updateSerial();
//Highlighted Code to Make a Call or Remove Highlighted code to Receive the calls
Serial1.println("ATD+91XXXXXXXXXX"); // change ZZ with country code and xxxxxxxxxxx with phone
number to dial
updateSerial();
delay(20000); // wait for 20 seconds...
Serial1.println("ATH"); //hang up
updateSerial();
}
void loop() {
updateSerial();
}
void updateSerial()
{
delay(500);
while (Serial.available())
{
Serial1.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(Serial1.available())
{
Serial.write(Serial1.read());//Forward what Software Serial received to Serial Port
}
}
ATD+ZZxxxxxxxxxx; – Dials a specified number.
Embedded System Design Jigar Makhija
16 17-Jul-19
ATH – Hangs up the call
Sending Calls:
Receiving Call:

More Related Content

What's hot

Static and Dynamic Read/Write memories
Static and Dynamic Read/Write memoriesStatic and Dynamic Read/Write memories
Static and Dynamic Read/Write memories
Abhilash Nair
 

What's hot (20)

Arm architecture
Arm architectureArm architecture
Arm architecture
 
Arm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furberArm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furber
 
Uart
UartUart
Uart
 
Microprocessor fundamentals
Microprocessor fundamentalsMicroprocessor fundamentals
Microprocessor fundamentals
 
ARM7-ARCHITECTURE
ARM7-ARCHITECTURE ARM7-ARCHITECTURE
ARM7-ARCHITECTURE
 
Unit4.tms320c54x
Unit4.tms320c54xUnit4.tms320c54x
Unit4.tms320c54x
 
Displacement addressing
Displacement addressingDisplacement addressing
Displacement addressing
 
Wallace tree multiplier.pptx1
Wallace tree multiplier.pptx1Wallace tree multiplier.pptx1
Wallace tree multiplier.pptx1
 
hardwired control unit ppt
hardwired control unit ppthardwired control unit ppt
hardwired control unit ppt
 
An FPGA application of home security code using verilog
An FPGA application of home security code using verilogAn FPGA application of home security code using verilog
An FPGA application of home security code using verilog
 
ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC Machine
 
AVRTIMER.pptx
AVRTIMER.pptxAVRTIMER.pptx
AVRTIMER.pptx
 
ARM Processors
ARM ProcessorsARM Processors
ARM Processors
 
ASk,FSK,PSK
ASk,FSK,PSKASk,FSK,PSK
ASk,FSK,PSK
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
Static and Dynamic Read/Write memories
Static and Dynamic Read/Write memoriesStatic and Dynamic Read/Write memories
Static and Dynamic Read/Write memories
 
CMOS Logic Circuits
CMOS Logic CircuitsCMOS Logic Circuits
CMOS Logic Circuits
 
ARM Micro-controller
ARM Micro-controllerARM Micro-controller
ARM Micro-controller
 
Programmable Logic Devices
Programmable Logic DevicesProgrammable Logic Devices
Programmable Logic Devices
 
Arm cortex (lpc 2148) based motor speed
Arm cortex (lpc 2148) based motor speedArm cortex (lpc 2148) based motor speed
Arm cortex (lpc 2148) based motor speed
 

Similar to Embedded system lab work

Lalit Singh FPGA resume
Lalit Singh FPGA resumeLalit Singh FPGA resume
Lalit Singh FPGA resume
Lalit singh
 
Quantum composers white paper ethernet connectivity
Quantum composers white paper  ethernet connectivityQuantum composers white paper  ethernet connectivity
Quantum composers white paper ethernet connectivity
Quantum Composers
 

Similar to Embedded system lab work (20)

Intel galileo gen 2
Intel galileo gen 2Intel galileo gen 2
Intel galileo gen 2
 
Gas leakage detection system
Gas leakage detection systemGas leakage detection system
Gas leakage detection system
 
40120140504013
4012014050401340120140504013
40120140504013
 
Fpg as 11 body
Fpg as 11 bodyFpg as 11 body
Fpg as 11 body
 
A design of FPGA based intelligent data handling interfacing card.
A design of FPGA based intelligent data handling interfacing card.A design of FPGA based intelligent data handling interfacing card.
A design of FPGA based intelligent data handling interfacing card.
 
FPGA Implementation of Real Time Data Acquisition System Using Micro blaze Pr...
FPGA Implementation of Real Time Data Acquisition System Using Micro blaze Pr...FPGA Implementation of Real Time Data Acquisition System Using Micro blaze Pr...
FPGA Implementation of Real Time Data Acquisition System Using Micro blaze Pr...
 
HOME AUTOMATION SYSTEM DESIGN USING ROUND ROBIN SCHEDULING ALGORITHM
HOME AUTOMATION SYSTEM DESIGN USING ROUND ROBIN SCHEDULING ALGORITHMHOME AUTOMATION SYSTEM DESIGN USING ROUND ROBIN SCHEDULING ALGORITHM
HOME AUTOMATION SYSTEM DESIGN USING ROUND ROBIN SCHEDULING ALGORITHM
 
Lalit Singh FPGA resume
Lalit Singh FPGA resumeLalit Singh FPGA resume
Lalit Singh FPGA resume
 
P3APS19001EN IEC 61850_Configuration_Instructions.pdf
P3APS19001EN IEC 61850_Configuration_Instructions.pdfP3APS19001EN IEC 61850_Configuration_Instructions.pdf
P3APS19001EN IEC 61850_Configuration_Instructions.pdf
 
Prayat hegde resume_firmware_embedded
Prayat hegde resume_firmware_embeddedPrayat hegde resume_firmware_embedded
Prayat hegde resume_firmware_embedded
 
FPGA Based IP Core Initialization for Ps2-Vga Peripherals Using Microblaze Pr...
FPGA Based IP Core Initialization for Ps2-Vga Peripherals Using Microblaze Pr...FPGA Based IP Core Initialization for Ps2-Vga Peripherals Using Microblaze Pr...
FPGA Based IP Core Initialization for Ps2-Vga Peripherals Using Microblaze Pr...
 
Fpga implementation of multi protocol data
Fpga implementation of multi protocol dataFpga implementation of multi protocol data
Fpga implementation of multi protocol data
 
Network Based Data Acquisition and Logging System using PIC Microcontroller
Network Based Data Acquisition and Logging System using PIC MicrocontrollerNetwork Based Data Acquisition and Logging System using PIC Microcontroller
Network Based Data Acquisition and Logging System using PIC Microcontroller
 
Quantum composers white paper ethernet connectivity
Quantum composers white paper  ethernet connectivityQuantum composers white paper  ethernet connectivity
Quantum composers white paper ethernet connectivity
 
[IJET-V1I3P17] Authors :Prof. U. R. More. S. R. Adhav
[IJET-V1I3P17] Authors :Prof. U. R. More. S. R. Adhav[IJET-V1I3P17] Authors :Prof. U. R. More. S. R. Adhav
[IJET-V1I3P17] Authors :Prof. U. R. More. S. R. Adhav
 
Device replacement in eip with lldp
Device replacement in eip with lldpDevice replacement in eip with lldp
Device replacement in eip with lldp
 
Verilog Implementation of 32-Bit CISC Processor
Verilog Implementation of 32-Bit CISC ProcessorVerilog Implementation of 32-Bit CISC Processor
Verilog Implementation of 32-Bit CISC Processor
 
A STUDY OF AN ENTRENCHED SYSTEM USING INTERNET OF THINGS
A STUDY OF AN ENTRENCHED SYSTEM USING INTERNET OF THINGSA STUDY OF AN ENTRENCHED SYSTEM USING INTERNET OF THINGS
A STUDY OF AN ENTRENCHED SYSTEM USING INTERNET OF THINGS
 
Design of a usb based data acquisition system
Design of a usb based data acquisition systemDesign of a usb based data acquisition system
Design of a usb based data acquisition system
 
Design of a usb based data acquisition system
Design of a usb based data acquisition systemDesign of a usb based data acquisition system
Design of a usb based data acquisition system
 

More from JIGAR MAKHIJA

More from JIGAR MAKHIJA (20)

Php gd library
Php gd libraryPhp gd library
Php gd library
 
Php pattern matching
Php pattern matchingPhp pattern matching
Php pattern matching
 
Php cookies
Php cookiesPhp cookies
Php cookies
 
Php functions
Php functionsPhp functions
Php functions
 
Php sessions
Php sessionsPhp sessions
Php sessions
 
Php server variables
Php server variablesPhp server variables
Php server variables
 
Db function
Db functionDb function
Db function
 
C++ version 1
C++  version 1C++  version 1
C++ version 1
 
C++ Version 2
C++  Version 2C++  Version 2
C++ Version 2
 
SAP Ui5 content
SAP Ui5 contentSAP Ui5 content
SAP Ui5 content
 
Solution doc
Solution docSolution doc
Solution doc
 
Overview on Application protocols in Internet of Things
Overview on Application protocols in Internet of ThingsOverview on Application protocols in Internet of Things
Overview on Application protocols in Internet of Things
 
125 green iot
125 green iot125 green iot
125 green iot
 
Msp430 g2 with ble(Bluetooth Low Energy)
Msp430 g2 with ble(Bluetooth Low Energy)Msp430 g2 with ble(Bluetooth Low Energy)
Msp430 g2 with ble(Bluetooth Low Energy)
 
Presentation on iot- Internet of Things
Presentation on iot- Internet of ThingsPresentation on iot- Internet of Things
Presentation on iot- Internet of Things
 
Oracle
OracleOracle
Oracle
 
Learn Japanese -Basic kanji 120
Learn Japanese -Basic kanji 120Learn Japanese -Basic kanji 120
Learn Japanese -Basic kanji 120
 
View Alignment Techniques
View Alignment TechniquesView Alignment Techniques
View Alignment Techniques
 
Letters (complaints & invitations)
Letters (complaints & invitations)Letters (complaints & invitations)
Letters (complaints & invitations)
 
Letter Writing invitation-letter
Letter Writing invitation-letterLetter Writing invitation-letter
Letter Writing invitation-letter
 

Recently uploaded

Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptxslides CapTechTalks Webinar May 2024 Alexander Perry.pptx
slides CapTechTalks Webinar May 2024 Alexander Perry.pptx
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...The impact of social media on mental health and well-being has been a topic o...
The impact of social media on mental health and well-being has been a topic o...
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 2 STEPS Using Odoo 17
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 

Embedded system lab work

  • 1. Embedded System Design Jigar Makhija 1 17-Jul-19 Device: TM4C123G Description The TM4C123G Launchpad Evaluation Kit is a low-cost evaluation platform for ARM Cortex-M4F based microcontrollers from Texas Instruments. The design of the TM4C123G Launchpad highlights the TM4C123GH6PM microcontroller with a USB 2.0 device interface and hibernation module. Figure 1.1- Basic Architecture of ARM Cortex TM4C123G
  • 2. Embedded System Design Jigar Makhija 2 17-Jul-19 Figure 1.2: Detail Pin Diagram for TM4C123G Configuration & Tools: Energia IDE: https://energia.nu/download/ Note: Install Appropriate Drivers Reference : https://energia.nu/pinmaps/ek-tm4c123gxl/
  • 3. Embedded System Design Jigar Makhija 3 17-Jul-19 Basic Programs: 1) Blinking LED: Code: /* Blink The basic Energia example. Turns on an LED on for one second, then off for one second, repeatedly. Change the LED define to blink other LEDs. Hardware Required: * LaunchPad with an LED This example code is in the public domain. */ // most launchpads have a red LED #define LED RED_LED //see pins_energia.h for more LED definitions //#define LED GREEN_LED // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. pinMode(LED, OUTPUT); } // the loop routine runs over and over again forever: void loop() { digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second }
  • 4. Embedded System Design Jigar Makhija 4 17-Jul-19 2) Digital Serial Read: Code: /* DigitalReadSerial with on-board Pushbutton Reads a digital input on pin 31, prints the result to the serial monitor // digital pin 5 has a pushbutton attached to it. Give it a name: int pushButton = 31; // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); // msp430g2231 must use 4800 // make the on-board pushbutton's pin an input pullup: pinMode(pushButton, INPUT_PULLUP); } // the loop routine runs over and over again forever: void loop() {
  • 5. Embedded System Design Jigar Makhija 5 17-Jul-19 // read the input pin: int buttonState = digitalRead(pushButton); // print out the state of the button: Serial.println(buttonState); delay(1); // delay in between reads for stability } 3) Temperature Humidity: Device Required: DHT11 Package need to be installed and imported: Install: - Adafruit Unified Sensor Library: https://github.com/adafruit/Adafruit_Sensor - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library Importing Library: Sketch->Include Library->Add. Zip Library
  • 6. Embedded System Design Jigar Makhija 6 17-Jul-19 Code: // DHT Temperature & Humidity Sensor // Unified Sensor Library Example // - Adafruit Unified Sensor Library: https://github.com/adafruit/Adafruit_Sensor // - DHT Sensor Library: https://github.com/adafruit/DHT-sensor-library #include <Adafruit_Sensor.h> #include <DHT.h> #include <DHT_U.h> #define DHTPIN 05 // Pin which is connected to the DHT sensor. // Uncomment the type of sensor in use: #define DHTTYPE DHT11 // DHT 11 // See guide for details on sensor wiring and usage: // https://learn.adafruit.com/dht/overview DHT_Unified dht(DHTPIN, DHTTYPE); uint32_t delayMS; void setup() { Serial.begin(9600); // Initialize device. dht.begin(); Serial.println("DHTxx Unified Sensor Example"); // Print temperature sensor details. sensor_t sensor; dht.temperature().getSensor(&sensor); Serial.println("------------------------------------"); Serial.println("Temperature"); Serial.print ("Sensor: "); Serial.println(sensor.name); Serial.print ("Driver Ver: "); Serial.println(sensor.version); Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" *C"); Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" *C"); Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" *C"); Serial.println("------------------------------------"); // Print humidity sensor details. dht.humidity().getSensor(&sensor); Serial.println("------------------------------------");
  • 7. Embedded System Design Jigar Makhija 7 17-Jul-19 Serial.println("Humidity"); Serial.print ("Sensor: "); Serial.println(sensor.name); Serial.print ("Driver Ver: "); Serial.println(sensor.version); Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println("%"); Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println("%"); Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println("%"); Serial.println("------------------------------------"); // Set delay between sensor readings based on sensor details. delayMS = sensor.min_delay / 1000; } void loop() { delay(delayMS); sensors_event_t event; dht.temperature().getEvent(&event); /* Read temperature value */ if (isnan(event.temperature)) { /* If temperature value is not a number */ Serial.println("Error reading temperature!"); } else { Serial.print("Temperature : "); Serial.print(event.temperature); Serial.println(" *C"); } dht.humidity().getEvent(&event); /* Read humidity value */ if (isnan(event.relative_humidity)) { /* If humidity value is not a number */ Serial.println("Error reading humidity!"); } else { Serial.print("Humidity : "); Serial.print(event.relative_humidity); Serial.println("%"); } }
  • 8. Embedded System Design Jigar Makhija 8 17-Jul-19 4) LED Blink through Bluetooth Terminal from Mobile Hardware: HC-05 Mobile App: Any HC-05 Terminal Application from Play store Code: #define LED RED_LED void setup() { Serial1.begin(9600); /* Define baud rate for serial communication */ pinMode(LED, OUTPUT); } void loop() { if (Serial1.available()) /* If data is available on serial port */ { char data_received; data_received = Serial1.read(); /* Data received from bluetooth */ if (data_received == '1') { digitalWrite(LED, HIGH); Serial1.write("nLED turned ON");
  • 9. Embedded System Design Jigar Makhija 9 17-Jul-19 } else if (data_received == '2') { digitalWrite(LED, LOW); Serial1.write("nLED turned OFF"); } else { Serial1.write("nSelect either 1 or 2"); } } } 5) A6 GSM Module for Calling and Messaging. Hardware: A6 GSM/GPRS Resources: 2G or 3G Sim Card
  • 10. Embedded System Design Jigar Makhija 10 17-Jul-19 Code – Testing AT Commands: void setup() { //Begin serial communication (Serial Monitor) Serial.begin(9600); //Begin serial communication with Energia and A6 Serial1.begin(9600); Serial.println("Initializing..."); delay(1000); Serial1.println("AT"); //Once the handshake test is successful, it will back to OK updateSerial(); Serial1.println("AT+CSQ"); //Signal quality test, value range is 0-31 , 31 is the best updateSerial(); Serial1.println("AT+CCID"); //Read SIM information to confirm whether the SIM is plugged updateSerial(); Serial1.println("AT+CREG?"); //Check whether it has registered in the network updateSerial(); } void loop() { updateSerial(); } void updateSerial() { delay(500); while (Serial.available()) { Serial1.write(Serial.read());//Forward what Serial received to Software Serial Port } while(Serial1.available()) { Serial.write(Serial1.read()); //Forward what Software Serial received to Serial Port } }
  • 11. Embedded System Design Jigar Makhija 11 17-Jul-19 AT – It is the most basic AT command. It also initializes Auto-baud’er. If it works you should see the AT characters echo and then OK, telling you it’s OK and it’s understanding you correctly! You can then send some commands to query the module and get information about it such as AT+CSQ – Check the ‘signal strength’ – the first # is dB strength, it should be higher than around 5. Higher is better. Of course, it depends on your antenna and location! AT+CCID – get the SIM card number – this tests that the SIM card is found OK and you can verify the number is written on the card. AT+CREG? Check that you’re registered on the network. The second # should be 1 or 5. 1 indicates you are registered to home network and 5 indicates roaming network. Other than these two numbers indicate you are not registered to any network. ATI – Get the module name and revision AT+COPS? – Check which network you are connected to, in this case 40466 (BSNL) AT+COPS=? – Return the list of operators present in the network.
  • 12. Embedded System Design Jigar Makhija 12 17-Jul-19 Code – Sending SMS/ Reading SMS void setup() { //Begin serial communication with Energia and Energia IDE (Serial Monitor) Serial.begin(9600); //Begin serial communication with Energia and A6 Serial1.begin(9600); Serial.println("Initializing..."); delay(1000); Serial1.println("AT"); //Once the handshake test is successful, it will back to OK updateSerial(); Serial1.println("AT+CMGF=1"); // Configuring TEXT mode updateSerial(); //Module to Send Message /*Serial1.println("AT+CMGS="+91xxXXXXXXXX"");//change ZZ with country code and xxxxxxxxxxx with phone number to sms updateSerial(); Serial1.print("Last Minute TEST | Successful"); //text content */ //Code to Read Current New Messages Serial1.println("AT+CNMI=1,2,0,0,0"); // Decides how newly arrived SMS messages should be handled
  • 13. Embedded System Design Jigar Makhija 13 17-Jul-19 updateSerial(); // Serial1.write(26); //Remove Comment for Serial write to Send Message } void loop() { updateSerial(); } void updateSerial() { delay(500); while (Serial.available()) { Serial1.write(Serial.read());//Forward what Serial received to Software Serial Port } while(Serial1.available()) { Serial.write(Serial1.read());//Forward what Software Serial received to Serial Port } } Sending: The sketch is almost same as earlier except below code snippet. Once the connection is established, we send below AT commands: AT+CMGF=1 – Selects SMS message format as text. Default format is Protocol Data Unit (PDU) AT+CMGS=+ZZxxxxxxxxxx – Sends SMS to the phone number specified. Once we send a message. Receiving: The sketch is similar as earlier except below code snippet. Once the connection is established, we send below AT commands:
  • 14. Embedded System Design Jigar Makhija 14 17-Jul-19 AT+CMGF=1 – Selects SMS message format as text. Default format is Protocol Data Unit (PDU) AT+CNMI=1,2,0,0,0 – specifies how newly arrived SMS messages should be handled. This way you can tell the A6 module either to forward newly arrived SMS messages directly to the PC, or to save them in message storage and then notify the PC about their locations in message storage. Its response starts with +CMT: All the fields in the response are comma- separated with first field being phone number. The second field is the name of person sending SMS. Third field is a timestamp while forth field is the actual message. Sending Receiving
  • 15. Embedded System Design Jigar Makhija 15 17-Jul-19 Code – Making Call/ Receiving Call void setup() { //Begin serial communication with Energia and Energia IDE (Serial Monitor) Serial.begin(9600); //Begin serial communication with Energia and A6 Serial1.begin(9600); Serial.println("Initializing..."); delay(1000); Serial1.println("AT"); //Once the handshake test is successful, it will back to OK updateSerial(); //Highlighted Code to Make a Call or Remove Highlighted code to Receive the calls Serial1.println("ATD+91XXXXXXXXXX"); // change ZZ with country code and xxxxxxxxxxx with phone number to dial updateSerial(); delay(20000); // wait for 20 seconds... Serial1.println("ATH"); //hang up updateSerial(); } void loop() { updateSerial(); } void updateSerial() { delay(500); while (Serial.available()) { Serial1.write(Serial.read());//Forward what Serial received to Software Serial Port } while(Serial1.available()) { Serial.write(Serial1.read());//Forward what Software Serial received to Serial Port } } ATD+ZZxxxxxxxxxx; – Dials a specified number.
  • 16. Embedded System Design Jigar Makhija 16 17-Jul-19 ATH – Hangs up the call Sending Calls: Receiving Call: