SlideShare a Scribd company logo
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
Arduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz Radios
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
Arduino Meetup with Sonar and 433Mhz Radios
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

PPTX
Esp8266 NodeMCU
PDF
lesson2 - Nodemcu course - NodeMCU dev Board
PPTX
Nodemcu - introduction
PDF
Making wearables with NodeMCU - FOSDEM 2017
PPTX
Esp8266 - Intro for dummies
PPTX
ESP8266 Wifi Nodemcu
PPTX
IoT Hands-On-Lab, KINGS, 2019
PDF
Esp8266 hack sonoma county 4/8/2015
Esp8266 NodeMCU
lesson2 - Nodemcu course - NodeMCU dev Board
Nodemcu - introduction
Making wearables with NodeMCU - FOSDEM 2017
Esp8266 - Intro for dummies
ESP8266 Wifi Nodemcu
IoT Hands-On-Lab, KINGS, 2019
Esp8266 hack sonoma county 4/8/2015

What's hot (20)

PDF
NodeMCU ESP8266 workshop 1
PDF
lwM2M OTA for ESP8266
PDF
WiFi SoC ESP8266
PDF
NodeMCU with Blynk and Firebase
PDF
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
PDF
lesson1 - Getting Started with ESP8266
PDF
Espresso Lite v2 - ESP8266 Overview
PDF
Adafruit Huzzah Esp8266 WiFi Board
PPTX
Arduino & NodeMcu
PDF
Node MCU Fun
KEY
Internet of Things
PPTX
Programming esp8266
PPTX
Esp8266 Workshop
PDF
ESP8266 and IOT
PDF
Programando o ESP8266 com Python
PDF
Esp8266 basics
PDF
Introduction to ESP32 Programming [Road to RIoT 2017]
PDF
Cassiopeia Ltd - ESP8266+Arduino workshop
PPTX
[5]投影片 futurewad樹莓派研習會 141218
PPTX
Arduino IDE
NodeMCU ESP8266 workshop 1
lwM2M OTA for ESP8266
WiFi SoC ESP8266
NodeMCU with Blynk and Firebase
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
lesson1 - Getting Started with ESP8266
Espresso Lite v2 - ESP8266 Overview
Adafruit Huzzah Esp8266 WiFi Board
Arduino & NodeMcu
Node MCU Fun
Internet of Things
Programming esp8266
Esp8266 Workshop
ESP8266 and IOT
Programando o ESP8266 com Python
Esp8266 basics
Introduction to ESP32 Programming [Road to RIoT 2017]
Cassiopeia Ltd - ESP8266+Arduino workshop
[5]投影片 futurewad樹莓派研習會 141218
Arduino IDE
Ad

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

PDF
Stay away from me
PPTX
robotics and embedded system ppt
PDF
Sonar Project Report
PPTX
Final year Engineering project
PDF
Digital home automation with arduino bluetooth
PDF
FinalThesisdraft
PPTX
avoiding accidents on ghat roads and u turns by using IOT
PDF
Wireless humidity and temperature monitoring system
PDF
Arduino
PDF
Arduino
PPTX
IoT Platform
PPTX
IoT Platform
PPTX
Robotic Car Controlled over Bluetooth with Obstacle Avoidance
PPTX
Lecture2- Smart Parking Assistant using Arduino
KEY
Scottish Ruby Conference 2010 Arduino, Ruby RAD
PDF
Advanced View Arduino Projects List - Use Arduino for Projects {4}.pdf
PDF
Arduino Workshop @ MSA University
PDF
Arduino projects &amp; tutorials
PPTX
Self Obstacle Avoiding Rover
PPTX
PPT Missile Radar System introduction.pptx
Stay away from me
robotics and embedded system ppt
Sonar Project Report
Final year Engineering project
Digital home automation with arduino bluetooth
FinalThesisdraft
avoiding accidents on ghat roads and u turns by using IOT
Wireless humidity and temperature monitoring system
Arduino
Arduino
IoT Platform
IoT Platform
Robotic Car Controlled over Bluetooth with Obstacle Avoidance
Lecture2- Smart Parking Assistant using Arduino
Scottish Ruby Conference 2010 Arduino, Ruby RAD
Advanced View Arduino Projects List - Use Arduino for Projects {4}.pdf
Arduino Workshop @ MSA University
Arduino projects &amp; tutorials
Self Obstacle Avoiding Rover
PPT Missile Radar System introduction.pptx
Ad

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Cloud computing and distributed systems.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
MYSQL Presentation for SQL database connectivity
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Machine learning based COVID-19 study performance prediction
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
cuic standard and advanced reporting.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Big Data Technologies - Introduction.pptx
Spectroscopy.pptx food analysis technology
NewMind AI Weekly Chronicles - August'25 Week I
Cloud computing and distributed systems.
20250228 LYD VKU AI Blended-Learning.pptx
Review of recent advances in non-invasive hemoglobin estimation
MYSQL Presentation for SQL database connectivity
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Machine learning based COVID-19 study performance prediction
The AUB Centre for AI in Media Proposal.docx
MIND Revenue Release Quarter 2 2025 Press Release
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx

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
  • 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
  • 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"}