SlideShare a Scribd company logo
1 of 30
ardiuno meetup 
8 Nov 2014
Arduino 101 
• Started 2005 
• Open-source electronics 
prototyping platform 
• Open-source hardware 
• Open-source software 
• Hardware based on 8-bit Atmel AVR 
microcontroller or 32-bit Atmel ARM 
• Very popular in the maker community 
http://arduino.cc/
51 Flavours and counting 
• Uno is current “standard”, uses ATMega328 < $20 
• Leonardo uses ATMega32u4 < $18 
• Mini/Nano uses Atmega328P < $5
Arduino Nano 
• Microcontroller Atmel ATmega328 
• Operating Voltage (logic level) 5 V 
• Input Voltage 7-12 V 
• Input Voltage (limits) 6-20 V 
• Digital I/O Pins 14 (of which 6 provide 
PWM output) 
• Analog Input Pins 8 
• DC Current per I/O Pin 40 mA 
• Flash Memory 32 KB of which 2 KB used 
by bootloader 
• SRAM 2 KB 
• EEPROM 1 KB 
• Clock Speed 16 MHz 
• Dimensions 0.73" x 1.70" 
http://arduino.cc/en/Main/ArduinoBoardNano
Arduino 
IDE 
• Integrated 
Development 
Environment (IDE) 
• All-in-one 
programming tool 
with built in 
compiler 
• Arduino language is 
C-like 
Compile 
Upload 
to Board Save 
Serial 
Monitor 
Messages 
http://arduino.cc/en/Main/Software
Hello Blinky World
HC-SR04 Ultrasonic Sensor 
• 2cm~500 cm resolution : 0.3 cm 
• Trig pin to any digital output 
• Echo pin to any digital input 
• Pulse Trig, read echo, calculate 
distance 
• Pace of Sound = 1 / Speed of 
Sound = 1 / 0.03435 = 29.1 ųs/cm
433Mhz RF Transmitter + 
Receiver Module 
Other cheap modules are: 
315/330MHz, 
2.4GHz 
FCC regulates 433MHz: 
~no more than 10 minutes 
on every hour 
o ~20-200m LOS; 4Kbps 
o Noisy, interference from door bell, garage openers, cordless phone 
o Easy to use with VirtualWire Library
Today's Task List 
• Install Arduino IDE 
• Install CH340G Driver 
• Modify Blink example to print to Serial console 
• Breadboard HC-SR04 Ultrasonic Sensor and read 
distance 
• Breadboard 433Mhz RF Transmitter and send 
distance 
• Breadboard RF Receiver and then transmit 
received messages
Stretch Goals 
• Add checksum to transmission 
• Use additional Components and Sensors 
• LEDs 
• Light Sensors 
• Pushbuttons 
• ?
Install Arduino IDE 
http://arduino.cc/en/Main/Software 
Arduino 1.0.6
Install CH340G Driver 
Some Arduino clones use a CH340G USB chip and you'll 
need to install a driver. 
https://github.com/fwin-dev/arduino_sonar_web_api/tree/master/CH340_drivers
Modify Blink example 
Print “on” and “off” as the LED blinks. 
In setup() you will need to opens serial port and set data 
rate to 9600 bps 
In loop() print “on” when the LED is on, “off” when LED is 
turned off
Breadboard HC-SR04 
Arduino D8 => sonar trigger pin 
Arduino D9 => sonar echo pin
Read HC-SR04 Distance - 
Setup 
Review the HC-SR04 slide 
Define constants for the trigger and echo pins 
In setup, set pins to OUTPUT or INPUT
Read HC-SR04 Distance - 
loop 
In the loop() you will want to trigger for 1 second and then 
read the echo. 
Handy methods would include digitalWrite and pulseIn 
Calculate distance in cm 
distance = (duration / 2 ) / pace of sound; 
Print calculated distance to the Serial console 
Add short delay of at least ½ second at end of loop
Breadboard RF Transmitter 
Arduino D12 => Xmit data pin
RF Transmitter 
Install Virtual Wire 
Virtual Wire Library 
Unzip into Arduino libraries folder
RF Transmitter - setup 
You will transmit the sonar distance using the 433MHz radio 
Define constants for the on board LED and the transmit pin 
Define a constant for the name of your arduino: “ralph12” 
Include the Virtual Wire library 
Initialize the the Virtual Wire library and bitrate 
vw_set_ptt_inverted(true); 
vw_setup(2000); 
Calculate a random value between ½ a second and 1 ½ secs 
used to avoid transmit collision 
Print the calculated random delay to the Serial console
RF Transmitter - loop 
The transmitted JSON string will need to be in a format like 
this: {"i":"joe4", "d":97} 
A useful method for formatting the JSON string is sprintf() 
char msg[50]; 
sprintf(msg, "{"i":"%s", "d":%d}", NAME, distance); 
Flash LED when transmitting 
Send json string with virtual wire 
const char* temp = msg; 
vw_send((uint8_t *)temp, strlen(temp)); 
vw_wait_tx(); 
Delay a random amount at end of loop
Breadboard RF Receiver 
Arduino D11 => either data pin
RF Receiver - setup 
You will enable the 433MHz receiver to hear other arduino 
transmissions and report them in your transmission 
Define a constant for your receiver pin 
Creat a buffer for receiving data 
uint8_t recvbuf[VW_MAX_MESSAGE_LEN]; 
uint8_t recvbuflen = VW_MAX_MESSAGE_LEN; 
Start the Virtual Wire receiver 
vw_rx_start();
RF Receiver – loop 
The transmitted JSON needs to be in a format like this: 
{"i":"joe4", "d":97, "h":"herman789"} 
Always reset the length of your buffer at the top of the loop 
recvbuflen = VW_MAX_MESSAGE_LEN; 
Check if any data was received 
vw_get_message(recvbuf, &recvbuflen)) 
If you receive data, null terminate your message 
recvbuf[recvbuflen] = 0; 
Print received data to Serial console
RF Receiver – loop cont 
You can extract the ID of the received data using indexOf() 
String h = String((char *)recvbuf); 
int idEnd = s.indexOf('"', 6); 
h.toCharArray((char *)recvbuf, recvbuflen); 
Use sprintf to format into a JSON string 
sprintf(recvmsg, ""h":"%s"", recvbuf); 
Print formatted data to Serial console 
Transmit whole JSON message at once 
{"i":"joe4", "d":97, "h":"herman789"}
Example Code 
https://github.com/fwin-dev/arduino_sonar_web_api/tree/master/arduino

More Related Content

What's hot

NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1Andy Gelme
 
NodeMCU with Blynk and Firebase
NodeMCU with Blynk and FirebaseNodeMCU with Blynk and Firebase
NodeMCU with Blynk and FirebaseEueung Mulyana
 
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...David Fowler
 
lesson1 - Getting Started with ESP8266
lesson1 -  Getting Started with ESP8266lesson1 -  Getting Started with ESP8266
lesson1 - Getting Started with ESP8266Elaf A.Saeed
 
Espresso Lite v2 - ESP8266 Overview
Espresso Lite v2 - ESP8266 OverviewEspresso Lite v2 - ESP8266 Overview
Espresso Lite v2 - ESP8266 OverviewThe World Bank
 
Adafruit Huzzah Esp8266 WiFi Board
Adafruit Huzzah Esp8266 WiFi BoardAdafruit Huzzah Esp8266 WiFi Board
Adafruit Huzzah Esp8266 WiFi BoardBiagio Botticelli
 
Internet of Things
Internet of ThingsInternet of Things
Internet of ThingsAndy Gelme
 
Programming esp8266
Programming esp8266Programming esp8266
Programming esp8266Baoshi Zhu
 
ESP8266 and IOT
ESP8266 and IOTESP8266 and IOT
ESP8266 and IOTdega1999
 
Programando o ESP8266 com Python
Programando o ESP8266 com PythonProgramando o ESP8266 com Python
Programando o ESP8266 com PythonRelsi Maron
 
Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]Alwin Arrasyid
 
Cassiopeia Ltd - ESP8266+Arduino workshop
Cassiopeia Ltd - ESP8266+Arduino workshopCassiopeia Ltd - ESP8266+Arduino workshop
Cassiopeia Ltd - ESP8266+Arduino workshoptomtobback
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218CAVEDU Education
 

What's hot (20)

NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1
 
lwM2M OTA for ESP8266
lwM2M OTA for ESP8266lwM2M OTA for ESP8266
lwM2M OTA for ESP8266
 
WiFi SoC ESP8266
WiFi SoC ESP8266WiFi SoC ESP8266
WiFi SoC ESP8266
 
NodeMCU with Blynk and Firebase
NodeMCU with Blynk and FirebaseNodeMCU with Blynk and Firebase
NodeMCU with Blynk and Firebase
 
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
 
lesson1 - Getting Started with ESP8266
lesson1 -  Getting Started with ESP8266lesson1 -  Getting Started with ESP8266
lesson1 - Getting Started with ESP8266
 
Espresso Lite v2 - ESP8266 Overview
Espresso Lite v2 - ESP8266 OverviewEspresso Lite v2 - ESP8266 Overview
Espresso Lite v2 - ESP8266 Overview
 
Adafruit Huzzah Esp8266 WiFi Board
Adafruit Huzzah Esp8266 WiFi BoardAdafruit Huzzah Esp8266 WiFi Board
Adafruit Huzzah Esp8266 WiFi Board
 
Arduino & NodeMcu
Arduino & NodeMcuArduino & NodeMcu
Arduino & NodeMcu
 
Node MCU Fun
Node MCU FunNode MCU Fun
Node MCU Fun
 
Internet of Things
Internet of ThingsInternet of Things
Internet of Things
 
Espressif Introduction
Espressif IntroductionEspressif Introduction
Espressif Introduction
 
Programming esp8266
Programming esp8266Programming esp8266
Programming esp8266
 
Esp8266 Workshop
Esp8266 WorkshopEsp8266 Workshop
Esp8266 Workshop
 
ESP8266 and IOT
ESP8266 and IOTESP8266 and IOT
ESP8266 and IOT
 
Programando o ESP8266 com Python
Programando o ESP8266 com PythonProgramando o ESP8266 com Python
Programando o ESP8266 com Python
 
Esp8266 basics
Esp8266 basicsEsp8266 basics
Esp8266 basics
 
Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]Introduction to ESP32 Programming [Road to RIoT 2017]
Introduction to ESP32 Programming [Road to RIoT 2017]
 
Cassiopeia Ltd - ESP8266+Arduino workshop
Cassiopeia Ltd - ESP8266+Arduino workshopCassiopeia Ltd - ESP8266+Arduino workshop
Cassiopeia Ltd - ESP8266+Arduino workshop
 
[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218[5]投影片 futurewad樹莓派研習會 141218
[5]投影片 futurewad樹莓派研習會 141218
 

Similar to Arduino Meetup with Sonar and 433Mhz Radios

Software Defined Radio (SDR)
Software Defined Radio (SDR)Software Defined Radio (SDR)
Software Defined Radio (SDR)Drew Fustini
 
Multi Sensory Communication 2/2
Multi Sensory Communication 2/2Multi Sensory Communication 2/2
Multi Sensory Communication 2/2Satoru Tokuhisa
 
Introduction to Arduino Webinar
Introduction to Arduino WebinarIntroduction to Arduino Webinar
Introduction to Arduino WebinarFragiskos Fourlas
 
Embedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseEmbedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseElaf A.Saeed
 
Internet of things laboratory
Internet of things laboratoryInternet of things laboratory
Internet of things laboratorySoumee Maschatak
 
Embedded &amp; pcb design
Embedded &amp; pcb designEmbedded &amp; pcb design
Embedded &amp; pcb designTanveer Behl
 
Do you know what your digital pins are "really" saying
Do you know what your digital pins are "really" sayingDo you know what your digital pins are "really" saying
Do you know what your digital pins are "really" sayingLeroy Levin
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacingRAMPRAKASHT1
 
Arduino projects &amp; tutorials
Arduino projects &amp; tutorialsArduino projects &amp; tutorials
Arduino projects &amp; tutorialsAnshu Pandey
 
Heart rate monitor system
Heart rate monitor systemHeart rate monitor system
Heart rate monitor systemSkyinthe Raw
 

Similar to Arduino Meetup with Sonar and 433Mhz Radios (20)

Software Defined Radio (SDR)
Software Defined Radio (SDR)Software Defined Radio (SDR)
Software Defined Radio (SDR)
 
Multi Sensory Communication 2/2
Multi Sensory Communication 2/2Multi Sensory Communication 2/2
Multi Sensory Communication 2/2
 
Arduino
ArduinoArduino
Arduino
 
Introduction to Arduino Webinar
Introduction to Arduino WebinarIntroduction to Arduino Webinar
Introduction to Arduino Webinar
 
Embedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseEmbedded system course projects - Arduino Course
Embedded system course projects - Arduino Course
 
Internet of things laboratory
Internet of things laboratoryInternet of things laboratory
Internet of things laboratory
 
Lab2ppt
Lab2pptLab2ppt
Lab2ppt
 
Embedded &amp; pcb design
Embedded &amp; pcb designEmbedded &amp; pcb design
Embedded &amp; pcb design
 
Assembler4
Assembler4Assembler4
Assembler4
 
Do you know what your digital pins are "really" saying
Do you know what your digital pins are "really" sayingDo you know what your digital pins are "really" saying
Do you know what your digital pins are "really" saying
 
Avr report
Avr reportAvr report
Avr report
 
Avr microcontroller
Avr microcontrollerAvr microcontroller
Avr microcontroller
 
Peripherals and interfacing
Peripherals  and interfacingPeripherals  and interfacing
Peripherals and interfacing
 
Arduino projects &amp; tutorials
Arduino projects &amp; tutorialsArduino projects &amp; tutorials
Arduino projects &amp; tutorials
 
Thesis_Pijpers_PDF
Thesis_Pijpers_PDFThesis_Pijpers_PDF
Thesis_Pijpers_PDF
 
ES UNIT3.pptx
ES UNIT3.pptxES UNIT3.pptx
ES UNIT3.pptx
 
Microcontroller 8051 gs
Microcontroller 8051 gsMicrocontroller 8051 gs
Microcontroller 8051 gs
 
UART
UARTUART
UART
 
Iot Workshop NITT 2015
Iot Workshop NITT 2015Iot Workshop NITT 2015
Iot Workshop NITT 2015
 
Heart rate monitor system
Heart rate monitor systemHeart rate monitor system
Heart rate monitor system
 

Recently uploaded

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Arduino Meetup with Sonar and 433Mhz Radios

  • 1. ardiuno meetup 8 Nov 2014
  • 2. Arduino 101 • Started 2005 • Open-source electronics prototyping platform • Open-source hardware • Open-source software • Hardware based on 8-bit Atmel AVR microcontroller or 32-bit Atmel ARM • Very popular in the maker community http://arduino.cc/
  • 3. 51 Flavours and counting • Uno is current “standard”, uses ATMega328 < $20 • Leonardo uses ATMega32u4 < $18 • Mini/Nano uses Atmega328P < $5
  • 4. Arduino Nano • Microcontroller Atmel ATmega328 • Operating Voltage (logic level) 5 V • Input Voltage 7-12 V • Input Voltage (limits) 6-20 V • Digital I/O Pins 14 (of which 6 provide PWM output) • Analog Input Pins 8 • DC Current per I/O Pin 40 mA • Flash Memory 32 KB of which 2 KB used by bootloader • SRAM 2 KB • EEPROM 1 KB • Clock Speed 16 MHz • Dimensions 0.73" x 1.70" http://arduino.cc/en/Main/ArduinoBoardNano
  • 5. Arduino IDE • Integrated Development Environment (IDE) • All-in-one programming tool with built in compiler • Arduino language is C-like Compile Upload to Board Save Serial Monitor Messages http://arduino.cc/en/Main/Software
  • 6.
  • 7.
  • 8.
  • 9.
  • 11. HC-SR04 Ultrasonic Sensor • 2cm~500 cm resolution : 0.3 cm • Trig pin to any digital output • Echo pin to any digital input • Pulse Trig, read echo, calculate distance • Pace of Sound = 1 / Speed of Sound = 1 / 0.03435 = 29.1 ųs/cm
  • 12. 433Mhz RF Transmitter + Receiver Module Other cheap modules are: 315/330MHz, 2.4GHz FCC regulates 433MHz: ~no more than 10 minutes on every hour o ~20-200m LOS; 4Kbps o Noisy, interference from door bell, garage openers, cordless phone o Easy to use with VirtualWire Library
  • 13.
  • 14. Today's Task List • Install Arduino IDE • Install CH340G Driver • Modify Blink example to print to Serial console • Breadboard HC-SR04 Ultrasonic Sensor and read distance • Breadboard 433Mhz RF Transmitter and send distance • Breadboard RF Receiver and then transmit received messages
  • 15. Stretch Goals • Add checksum to transmission • Use additional Components and Sensors • LEDs • Light Sensors • Pushbuttons • ?
  • 16. Install Arduino IDE http://arduino.cc/en/Main/Software Arduino 1.0.6
  • 17. Install CH340G Driver Some Arduino clones use a CH340G USB chip and you'll need to install a driver. https://github.com/fwin-dev/arduino_sonar_web_api/tree/master/CH340_drivers
  • 18. Modify Blink example Print “on” and “off” as the LED blinks. In setup() you will need to opens serial port and set data rate to 9600 bps In loop() print “on” when the LED is on, “off” when LED is turned off
  • 19. Breadboard HC-SR04 Arduino D8 => sonar trigger pin Arduino D9 => sonar echo pin
  • 20. Read HC-SR04 Distance - Setup Review the HC-SR04 slide Define constants for the trigger and echo pins In setup, set pins to OUTPUT or INPUT
  • 21. Read HC-SR04 Distance - loop In the loop() you will want to trigger for 1 second and then read the echo. Handy methods would include digitalWrite and pulseIn Calculate distance in cm distance = (duration / 2 ) / pace of sound; Print calculated distance to the Serial console Add short delay of at least ½ second at end of loop
  • 22. Breadboard RF Transmitter Arduino D12 => Xmit data pin
  • 23. RF Transmitter Install Virtual Wire Virtual Wire Library Unzip into Arduino libraries folder
  • 24. RF Transmitter - setup You will transmit the sonar distance using the 433MHz radio Define constants for the on board LED and the transmit pin Define a constant for the name of your arduino: “ralph12” Include the Virtual Wire library Initialize the the Virtual Wire library and bitrate vw_set_ptt_inverted(true); vw_setup(2000); Calculate a random value between ½ a second and 1 ½ secs used to avoid transmit collision Print the calculated random delay to the Serial console
  • 25. RF Transmitter - loop The transmitted JSON string will need to be in a format like this: {"i":"joe4", "d":97} A useful method for formatting the JSON string is sprintf() char msg[50]; sprintf(msg, "{"i":"%s", "d":%d}", NAME, distance); Flash LED when transmitting Send json string with virtual wire const char* temp = msg; vw_send((uint8_t *)temp, strlen(temp)); vw_wait_tx(); Delay a random amount at end of loop
  • 26. Breadboard RF Receiver Arduino D11 => either data pin
  • 27. RF Receiver - setup You will enable the 433MHz receiver to hear other arduino transmissions and report them in your transmission Define a constant for your receiver pin Creat a buffer for receiving data uint8_t recvbuf[VW_MAX_MESSAGE_LEN]; uint8_t recvbuflen = VW_MAX_MESSAGE_LEN; Start the Virtual Wire receiver vw_rx_start();
  • 28. RF Receiver – loop The transmitted JSON needs to be in a format like this: {"i":"joe4", "d":97, "h":"herman789"} Always reset the length of your buffer at the top of the loop recvbuflen = VW_MAX_MESSAGE_LEN; Check if any data was received vw_get_message(recvbuf, &recvbuflen)) If you receive data, null terminate your message recvbuf[recvbuflen] = 0; Print received data to Serial console
  • 29. RF Receiver – loop cont You can extract the ID of the received data using indexOf() String h = String((char *)recvbuf); int idEnd = s.indexOf('"', 6); h.toCharArray((char *)recvbuf, recvbuflen); Use sprintf to format into a JSON string sprintf(recvmsg, ""h":"%s"", recvbuf); Print formatted data to Serial console Transmit whole JSON message at once {"i":"joe4", "d":97, "h":"herman789"}