SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
THE IOT ACADEMY
Connecting LCDs
Using LCDs
#include <LiquidCrystal.h> // include the library
code
//constants for the number of rows and columns in the
LCD
const int numRows = 2;
const int numCols = 16;
// initialize the library with the numbers of the
interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
lcd.begin(numCols, numRows);
lcd.print("hello, world!"); // Print a message to the LCD.
}
Using PIR motion sensors
Using PIR motion sensors
const int ledPin = 77; // pin for the LED
const int inputPin = 2; // input pin (for
the PIR sensor)
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare pushbutton
as input
}
void loop(){
int val = digitalRead(inputPin); // read input
value
if (val == HIGH) // check if the input is HIGH
{
digitalWrite(ledPin, HIGH); // turn LED on if
motion detected
delay(500);
digitalWrite(ledPin, LOW); // turn LED off
}
}
Using ultrasonic sensors
The “ping” sound pulse is generated when the pingPin level goes
HIGH for two microseconds.
The sensor will then generate a pulse that terminates when the
sound returns.
The width of the pulse is proportional to the distance the sound
traveled.
The speed of sound is 340 meters per second, which is 29
microseconds per centimeter. The formula for the distance of the
round trip is:
RoundTrip = microseconds / 29
Using ultrasonic sensors
const int pingPin = 5;
const int ledPin = 77; // pin connected to LED
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop()
{
int cm = ping(pingPin) ;
Serial.println(cm);
digitalWrite(ledPin, HIGH);
delay(cm * 10 ); // each centimeter adds 10 milliseconds delay
digitalWrite(ledPin, LOW);
delay( cm * 10);
}
Using ultrasonic sensors
int ping(int pingPin)
{
long duration, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
// convert the time into a distance
cm = microsecondsToCentimeters(duration);
return cm ;
}
long microsecondsToCentimeters(long microseconds)
{
// The speed of sound is 340 m/s or 29 microseconds per
centimeter.
// The ping travels out and back, so to find the distance of the
// object we take half of the distance travelled.
return microseconds / 29 / 2;
}
Audio output
tone(speakerPin, frequency, duration); // play the tone
delay(duration); //wait for the tone to finish
Example
 Write a program that plays an A note (440 Hz) for 1 second when a
motion sensor detects motion.
Arduino with GPS (1/4)
 Three modes:
 Stand-alone: GPS obtains information such as position and altitude with only the
signal of the satellites
 slowest of the three modes
 AT+CGPSINFO command brings directly latitude, longitude, date, UTC time,
altitude and speed
 S-GPS: module connects to a GPS server
 module calculates the position
 A-GPS: Three modes
 MS-Assisted: Server sends data and calculates position
 MS-based: Server sends aiding data, module calculates position
 Stand-Alone: Module demodulates GPS data and calculates position
Arduino with GPS (2/4)
 AT+CGPSINFO returns the GPS info in a string:
 [<latitude>],[<N/S>],[<longitude>],[<E/W>],[<date>],[<UTC_time>],[<altitude>],[<s
peedOG>],[<course>]
Arduino with GPS (3/4)
int8_t answer;
int onModulePin= 2;
char gps_data[100]; //will perform 100 GPS data reads
int counter;
void setup(){
pinMode(onModulePin, OUTPUT);
Serial.begin(115200);
Serial.println("Starting...");
power_on();
delay(5000); // starts GPS session in stand alone mode
}
}
void power_on(){ //void power_on() should be placed AFTER void loop(), used here for lecture
digitalWrite(onModulePin,HIGH); //GPS module requires a 3 sec pulse on onModulePin
delay(3000);
digitalWrite(onModulePin,LOW);
}
Arduino with GPS (4/4)
void loop(){
answer = sendATcommand("AT+CGPSINFO","+CGPSINFO:",1000);
// request info from GPS
if (answer == 1) {
counter = 0;
do{
while(Serial.available() == 0); //reading GPS data
gps_data[counter] = Serial.read();
counter++;
}
}
Serial.print("GPS data:"); //printing GPS data
Serial.print(gps_data);
}
The IoT Academy IoT training Arduino Part 5 Arduino peripherals

Weitere ähnliche Inhalte

Was ist angesagt?

Exercises with timers and UART
Exercises with timers and UARTExercises with timers and UART
Exercises with timers and UART
Corrado Santoro
 
TH2_T03_5_PAU-SA_I_Ramos.ppt
TH2_T03_5_PAU-SA_I_Ramos.pptTH2_T03_5_PAU-SA_I_Ramos.ppt
TH2_T03_5_PAU-SA_I_Ramos.ppt
grssieee
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
logesh waran
 
LinuxCNC 入門簡介
LinuxCNC 入門簡介LinuxCNC 入門簡介
LinuxCNC 入門簡介
roboard
 

Was ist angesagt? (20)

Soc
SocSoc
Soc
 
Exercises with timers and UART
Exercises with timers and UARTExercises with timers and UART
Exercises with timers and UART
 
Handling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUsHandling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUs
 
Jrc gnss-testing-facilities
Jrc gnss-testing-facilitiesJrc gnss-testing-facilities
Jrc gnss-testing-facilities
 
Birds of a Feather 2017: 邀請分享 IoT, SDR, and Car Security - Aaron
Birds of a Feather 2017: 邀請分享 IoT, SDR, and Car Security - AaronBirds of a Feather 2017: 邀請分享 IoT, SDR, and Car Security - Aaron
Birds of a Feather 2017: 邀請分享 IoT, SDR, and Car Security - Aaron
 
Starting with Arduino
Starting with Arduino Starting with Arduino
Starting with Arduino
 
Pt 51 kit - Peripheral self-test
Pt 51 kit - Peripheral self-testPt 51 kit - Peripheral self-test
Pt 51 kit - Peripheral self-test
 
Weapons grade React by Ken Wheeler
Weapons grade React by Ken Wheeler Weapons grade React by Ken Wheeler
Weapons grade React by Ken Wheeler
 
12 mt06ped019
12 mt06ped019 12 mt06ped019
12 mt06ped019
 
TH2_T03_5_PAU-SA_I_Ramos.ppt
TH2_T03_5_PAU-SA_I_Ramos.pptTH2_T03_5_PAU-SA_I_Ramos.ppt
TH2_T03_5_PAU-SA_I_Ramos.ppt
 
8051 Interrupts
8051 Interrupts8051 Interrupts
8051 Interrupts
 
Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015
Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015
Trash Robotic Router Platform - David Melendez - Codemotion Rome 2015
 
Lpc 1768 timers
Lpc 1768 timersLpc 1768 timers
Lpc 1768 timers
 
Astrobot session 3
Astrobot session 3Astrobot session 3
Astrobot session 3
 
Aihro-1
Aihro-1Aihro-1
Aihro-1
 
Multi Sensory Communication 2/2
Multi Sensory Communication 2/2Multi Sensory Communication 2/2
Multi Sensory Communication 2/2
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 
LinuxCNC 入門簡介
LinuxCNC 入門簡介LinuxCNC 入門簡介
LinuxCNC 入門簡介
 
Uart
UartUart
Uart
 
Constructing circuits for boolean expressions(gate)
Constructing circuits for boolean expressions(gate)Constructing circuits for boolean expressions(gate)
Constructing circuits for boolean expressions(gate)
 

Ähnlich wie The IoT Academy IoT training Arduino Part 5 Arduino peripherals

4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
Jayanthi Kannan MK
 

Ähnlich wie The IoT Academy IoT training Arduino Part 5 Arduino peripherals (20)

Arduino radar system
Arduino radar systemArduino radar system
Arduino radar system
 
Arduino Programming
Arduino ProgrammingArduino Programming
Arduino Programming
 
AVR arduino dasar
AVR arduino dasarAVR arduino dasar
AVR arduino dasar
 
Lecture6
Lecture6Lecture6
Lecture6
 
IoT ppt(004).pptx
IoT ppt(004).pptxIoT ppt(004).pptx
IoT ppt(004).pptx
 
Arduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz RadiosArduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz Radios
 
From Arduino to LinnStrument
From Arduino to LinnStrumentFrom Arduino to LinnStrument
From Arduino to LinnStrument
 
PC based oscilloscope
PC based oscilloscopePC based oscilloscope
PC based oscilloscope
 
SENSOR DATA COMMUNICATION TO THNIGSPEAK IOT PLATFORM USING RASPBERRY P
SENSOR DATA COMMUNICATION TO THNIGSPEAK  IOT PLATFORM USING RASPBERRY PSENSOR DATA COMMUNICATION TO THNIGSPEAK  IOT PLATFORM USING RASPBERRY P
SENSOR DATA COMMUNICATION TO THNIGSPEAK IOT PLATFORM USING RASPBERRY P
 
Distance measurement using Ultrasonic sensor on Arduino Uno
Distance measurement using Ultrasonic sensor on Arduino UnoDistance measurement using Ultrasonic sensor on Arduino Uno
Distance measurement using Ultrasonic sensor on Arduino Uno
 
GNU Radio
GNU RadioGNU Radio
GNU Radio
 
Internet of things laboratory
Internet of things laboratoryInternet of things laboratory
Internet of things laboratory
 
Distance measuring unit with zigbee protocol, Ultra sonic sensor
Distance measuring unit with zigbee protocol, Ultra sonic sensorDistance measuring unit with zigbee protocol, Ultra sonic sensor
Distance measuring unit with zigbee protocol, Ultra sonic sensor
 
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf4 IOT 18ISDE712  MODULE 4 IoT Physical Devices and End Point-Aurdino  Uno.pdf
4 IOT 18ISDE712 MODULE 4 IoT Physical Devices and End Point-Aurdino Uno.pdf
 
Arduino and Robotics
Arduino and RoboticsArduino and Robotics
Arduino and Robotics
 
Ultrsonic sensor_Arduino_DRKG.pptx
Ultrsonic sensor_Arduino_DRKG.pptxUltrsonic sensor_Arduino_DRKG.pptx
Ultrsonic sensor_Arduino_DRKG.pptx
 
Ov3425972602
Ov3425972602Ov3425972602
Ov3425972602
 
4th-Yr-PROJECT-REPORT
4th-Yr-PROJECT-REPORT4th-Yr-PROJECT-REPORT
4th-Yr-PROJECT-REPORT
 
Embedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseEmbedded system course projects - Arduino Course
Embedded system course projects - Arduino Course
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
 

Mehr von The IOT Academy

Mehr von The IOT Academy (20)

Embedded Systems Programming
Embedded Systems ProgrammingEmbedded Systems Programming
Embedded Systems Programming
 
Introduction to Digital Marketing Certification Course.pdf
Introduction to Digital Marketing Certification Course.pdfIntroduction to Digital Marketing Certification Course.pdf
Introduction to Digital Marketing Certification Course.pdf
 
Google SEO 2023: Complete SEO Guide
Google SEO 2023: Complete SEO GuideGoogle SEO 2023: Complete SEO Guide
Google SEO 2023: Complete SEO Guide
 
Embedded C The IoT Academy
Embedded C The IoT AcademyEmbedded C The IoT Academy
Embedded C The IoT Academy
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
MachineLlearning introduction
MachineLlearning introductionMachineLlearning introduction
MachineLlearning introduction
 
IoT Node-Red Presentation
IoT  Node-Red PresentationIoT  Node-Red Presentation
IoT Node-Red Presentation
 
IoT Introduction Architecture and Applications
IoT Introduction Architecture and ApplicationsIoT Introduction Architecture and Applications
IoT Introduction Architecture and Applications
 
UCT IoT Deployment and Challenges
UCT IoT Deployment and ChallengesUCT IoT Deployment and Challenges
UCT IoT Deployment and Challenges
 
UCT Electrical Vehicle Infrastructure
UCT Electrical Vehicle InfrastructureUCT Electrical Vehicle Infrastructure
UCT Electrical Vehicle Infrastructure
 
Uct 5G Autonomous Cars
Uct 5G Autonomous CarsUct 5G Autonomous Cars
Uct 5G Autonomous Cars
 
Fdp uct industry4.0_talk
Fdp uct industry4.0_talkFdp uct industry4.0_talk
Fdp uct industry4.0_talk
 
Success ladder to the Corporate world
Success ladder to the Corporate worldSuccess ladder to the Corporate world
Success ladder to the Corporate world
 
The iot academy_lpwan_lora
The iot academy_lpwan_loraThe iot academy_lpwan_lora
The iot academy_lpwan_lora
 
The iot academy_embeddedsystems_training_circuitdesignpart3
The iot academy_embeddedsystems_training_circuitdesignpart3The iot academy_embeddedsystems_training_circuitdesignpart3
The iot academy_embeddedsystems_training_circuitdesignpart3
 
The iot academy_embeddedsystems_training_basicselectronicspart2
The iot academy_embeddedsystems_training_basicselectronicspart2The iot academy_embeddedsystems_training_basicselectronicspart2
The iot academy_embeddedsystems_training_basicselectronicspart2
 
The iot academy_embeddedsystems_training_basicelectronicspart1
The iot academy_embeddedsystems_training_basicelectronicspart1The iot academy_embeddedsystems_training_basicelectronicspart1
The iot academy_embeddedsystems_training_basicelectronicspart1
 
The iot academy_lpwan
The iot academy_lpwanThe iot academy_lpwan
The iot academy_lpwan
 
The iotacademy industry4.0_talk_slideshare
The iotacademy industry4.0_talk_slideshareThe iotacademy industry4.0_talk_slideshare
The iotacademy industry4.0_talk_slideshare
 
The iot acdemy_awstraining_part4_aws_lab
The iot acdemy_awstraining_part4_aws_labThe iot acdemy_awstraining_part4_aws_lab
The iot acdemy_awstraining_part4_aws_lab
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 

The IoT Academy IoT training Arduino Part 5 Arduino peripherals

  • 3. Using LCDs #include <LiquidCrystal.h> // include the library code //constants for the number of rows and columns in the LCD const int numRows = 2; const int numCols = 16; // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(numCols, numRows); lcd.print("hello, world!"); // Print a message to the LCD. }
  • 5. Using PIR motion sensors const int ledPin = 77; // pin for the LED const int inputPin = 2; // input pin (for the PIR sensor) void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare pushbutton as input } void loop(){ int val = digitalRead(inputPin); // read input value if (val == HIGH) // check if the input is HIGH { digitalWrite(ledPin, HIGH); // turn LED on if motion detected delay(500); digitalWrite(ledPin, LOW); // turn LED off } }
  • 6. Using ultrasonic sensors The “ping” sound pulse is generated when the pingPin level goes HIGH for two microseconds. The sensor will then generate a pulse that terminates when the sound returns. The width of the pulse is proportional to the distance the sound traveled. The speed of sound is 340 meters per second, which is 29 microseconds per centimeter. The formula for the distance of the round trip is: RoundTrip = microseconds / 29
  • 7. Using ultrasonic sensors const int pingPin = 5; const int ledPin = 77; // pin connected to LED void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); } void loop() { int cm = ping(pingPin) ; Serial.println(cm); digitalWrite(ledPin, HIGH); delay(cm * 10 ); // each centimeter adds 10 milliseconds delay digitalWrite(ledPin, LOW); delay( cm * 10); }
  • 8. Using ultrasonic sensors int ping(int pingPin) { long duration, cm; pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW); pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH); // convert the time into a distance cm = microsecondsToCentimeters(duration); return cm ; } long microsecondsToCentimeters(long microseconds) { // The speed of sound is 340 m/s or 29 microseconds per centimeter. // The ping travels out and back, so to find the distance of the // object we take half of the distance travelled. return microseconds / 29 / 2; }
  • 9. Audio output tone(speakerPin, frequency, duration); // play the tone delay(duration); //wait for the tone to finish
  • 10. Example  Write a program that plays an A note (440 Hz) for 1 second when a motion sensor detects motion.
  • 11. Arduino with GPS (1/4)  Three modes:  Stand-alone: GPS obtains information such as position and altitude with only the signal of the satellites  slowest of the three modes  AT+CGPSINFO command brings directly latitude, longitude, date, UTC time, altitude and speed  S-GPS: module connects to a GPS server  module calculates the position  A-GPS: Three modes  MS-Assisted: Server sends data and calculates position  MS-based: Server sends aiding data, module calculates position  Stand-Alone: Module demodulates GPS data and calculates position
  • 12. Arduino with GPS (2/4)  AT+CGPSINFO returns the GPS info in a string:  [<latitude>],[<N/S>],[<longitude>],[<E/W>],[<date>],[<UTC_time>],[<altitude>],[<s peedOG>],[<course>]
  • 13. Arduino with GPS (3/4) int8_t answer; int onModulePin= 2; char gps_data[100]; //will perform 100 GPS data reads int counter; void setup(){ pinMode(onModulePin, OUTPUT); Serial.begin(115200); Serial.println("Starting..."); power_on(); delay(5000); // starts GPS session in stand alone mode } } void power_on(){ //void power_on() should be placed AFTER void loop(), used here for lecture digitalWrite(onModulePin,HIGH); //GPS module requires a 3 sec pulse on onModulePin delay(3000); digitalWrite(onModulePin,LOW); }
  • 14. Arduino with GPS (4/4) void loop(){ answer = sendATcommand("AT+CGPSINFO","+CGPSINFO:",1000); // request info from GPS if (answer == 1) { counter = 0; do{ while(Serial.available() == 0); //reading GPS data gps_data[counter] = Serial.read(); counter++; } } Serial.print("GPS data:"); //printing GPS data Serial.print(gps_data); }