这是indexloc提供的服务,不要输入任何密码
SlideShare a Scribd company logo
Go and Get Physical with
the Cloud
Using Arduino with Google App Engine for Go
!
Justin Grammens
justin@arduino.mn
I Want to Build Something!
Goal : Track movement using a motion sensor
Technology Requirements:
Use Go
Use Google App Engine
Use Arduino
Send text message when movement occurs
What We’ll Cover
Go Programming Language
Deployment on Google App Engine ( using Go )
REST interface on App Engine ( using go-restful )
Reading sensor data on Arduino
Sending data to our application on App Engine
Send message to 3rd party SMS provider ( Twillio )
Block Diagram
App
Engine
ArduinoBrowser
SMS
Service
Go Programming Language
Developed by Google in 2007
Statically typed language, loosely derived from C.
Automatic memory management
FAST compilation and execution!
Download at: https://code.google.com/p/go/
Go Language Key Points
Some dynamic typing ( “x:= 0” instead of “int x = 0” )
Remote package management ( “go get” )
Built in mechanisms for concurrency
Able to produce statically linked native binaries
Strong focus on support for concurrency
Go Language Key Points
No type inheritance
No method overloading
Has pointers, but no pointer arithmetic (ie. can’t be
changed)
No generics (a la List<String> in Java for instance)
No Exceptions - instead uses an error return type
func Open(name string) (file *File, err error)
Workspaces
Designed from the ground up to work with code in
public repositories
$GOPATH variable points to your workspace location
Put your code in a unique path
convention is: $GOPATH/src/github/user/project
Example Workspace
bin/
hello # command executable
pkg/
darwin_amd64/github.com/justingrammens
mydate.a # package object
src/
github.com/justingrammens/
hello/
.git/		 	 	 # git repository metadata
hello.go		 	 # package source
mydate/
.git/ # git repository metadata
mydate.go # package source
IDEs / Editors with Plugins
Emacs
Eclipse - ( GoClipse )
IntelliJ IDEA
Sublime Text
TextMate
Vim
Example: hello.go
git clone https://github.com/justingrammens/
gdev
!
package main
import "fmt"
func main() {
fmt.Println("hello world")
}
!
Example: hello-world.go
usage: type “go” on command line
$: go run hello.go
hello world
!
$: go install
$: $GOPATH/bin/hello
!
$ go build
./hello ( note the size of the executable )
Writing a Library
package mydate
!
import "time"
!
func Birthdate() time.Time {
d := time.Date(2014, time.May, 6, 0, 0, 0, 0, time.UTC)
return d
}
Return type
Capital letter means
public access
Calling function
Publish Library
git push to public repository: https://github.com/
justingrammens/gdev
Access with:
import “github.com/justingrammens/gdev/go-
examples/mydate”
Anyone can install to their workspace with:
go get github.com/justingrammens/gdev/go-
examples/mydate
Calling Library
package main
!
import "fmt"
import "github.com/justingrammens/gdev/mydate"
import "time"
!
func main() {
	 now := time.Now()
	 birthday := mydate.Birthdate()
	 diff := birthday.YearDay() - now.YearDay()
	 fmt.Printf("There are only %d days to my birthday!n", diff )
}
Example:
Functions can return multiple values:
	 func AddandSub(x, y int) (sum, difference int) {
	 	 sum = x + y
	 	 difference = x - y
	 	 return
	 }
Called with:
sum, difference := mydate.AddandSub(10, 11)
App Engine Using Go
Platform as a Service (PaSS)
Run applications in Google’s infrastructure
Frees you up to develop, not system admin
Develop and test locally, deploy globally
Beware - Go is Experimental!
https://developers.google.com/appengine/downloads
App Engine Using Go
Deployed to [your_app_id].appspot.com
Quotas:
Request & Response Size - 32 MB
Request Duration - 60 sec
Max total files - 10,000 total : 1,000 per directory
Max size files - 32 MB
App Engine Using Go
Run “goapp” to see commands
goapp serve : runs local server
goapp deploy : upload to App Engine
App Engine Using Go
Run Hello World Example
cd appengine-examples
goapp server
Local service: http://localhost:8080
Local datastore viewer: http://localhost:8000
App Engine Using Go
No standard REST framework out of the box
Use “go-restful” project
Easy install and setup with “go get” command
Resources:
“Events”
“Sms”
App Engine Using Go
Run DevFest App
cd devfest
goapp server
Access swagger for API at http://localhost:8080/apidocs
Push update to google app engine at:
appcfg.py --oauth2 update my app
Manage at: https://appengine.google.com
Test Web Service
Simple REST Client
Verify the values are being stored
Toggle values for SMS notifications
Arduino
Open source microcontroller board
Started in Italy in 2005 as a college student project
Based on a simplified version of C++ ( Wiring )
Allows for adding additional boards via “shields”
WIFI shield is added for our project
Many readily available sensors and libraries!
Arduino Wifi Shield
Hardware Parts
PIR Motion Sensor -
$9.95
Arduino R3 Board -
$30.00
Official Arduino WIFI
Shield - $70.00
Schematic
Arduino Basics
Only 2 functions are required
!
void setup() {
// put your setup code here, to run once.
}
!
void loop() {
// put your main code here, to run repeatedly.
}
Motion Sample Code
Motion activated by:
Takes an infrared “snapshot” of the room
If anything changes, pin #2 goes LOW
Use the digitalRead of values
Use WifiClient to Post JSON to our web service.
Print the status to the serial monitor.
Resources
Play with Go Code! http://tour.golang.org/
https://groups.google.com/forum/m/#!forum/google-
appengine-go
https://developers.google.com/appengine/docs/go/
http://arduino.mn - Local Arduino user’s group!
Thanks!
Questions?

More Related Content

What's hot (10)

PDF
Ogdk
Akira Sasaki
 
PDF
Windows 10 on Raspberry PI 2
Mirco Vanini
 
PPTX
Cross platform mobile apps using rhomobile and jquery mobile
SPRITLE SOFTWARE PRIVATE LIMIT ED
 
PPTX
Node red workshop
Mohamed Ali May
 
PDF
Hacking with the Raspberry Pi and Windows 10 IoT Core
Nick Landry
 
PPTX
Introduction to Node-RED
nodered_ug_jp
 
PDF
Humix community kick off
Jeffrey Liu
 
PPT
Gwt training presentation
MUFIX Community
 
PDF
Language Matters: JavaScript 
from IoT Product Concept 
to Production
Kinoma
 
PPTX
Mobile CICD
Gurzu Inc
 
Windows 10 on Raspberry PI 2
Mirco Vanini
 
Cross platform mobile apps using rhomobile and jquery mobile
SPRITLE SOFTWARE PRIVATE LIMIT ED
 
Node red workshop
Mohamed Ali May
 
Hacking with the Raspberry Pi and Windows 10 IoT Core
Nick Landry
 
Introduction to Node-RED
nodered_ug_jp
 
Humix community kick off
Jeffrey Liu
 
Gwt training presentation
MUFIX Community
 
Language Matters: JavaScript 
from IoT Product Concept 
to Production
Kinoma
 
Mobile CICD
Gurzu Inc
 

Similar to Physical Computing Using Go and Arduino (20)

PDF
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
KAI CHU CHUNG
 
PDF
Serverless Computing with Google Cloud
wesley chun
 
PDF
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
Diego Freniche Brito
 
PDF
Introduction to Cloud Computing with Google Cloud
wesley chun
 
PDF
Introduction to Google Cloud Endpoints: Speed Up Your API Development
Colin Su
 
PDF
Developing for Google Glass
Mark Billinghurst
 
PPT
Introduction to go
Anthony Chow
 
PPT
Introduction to Software Development
Zeeshan MIrza
 
ODP
PyQt Application Development On Maemo
achipa
 
PDF
Javascript, the GNOME way (JSConf EU 2011)
Igalia
 
PPTX
Introduction to Google App Engine with Python
Brian Lyttle
 
PDF
Android is going to Go! Android and Golang
Almog Baku
 
PDF
Android is going to Go! - Android and goland - Almog Baku
DroidConTLV
 
PDF
Playing with parse.com
JUG Genova
 
KEY
Intro to PhoneGap
Ryan Stewart
 
PDF
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
wesley chun
 
PPTX
How to Build Your First Web App in Go
All Things Open
 
PPTX
GAE as Android Test Portal. Part 1.
Åsa Pehrsson
 
PPTX
Scaling applications with go
Vimlesh Sharma
 
PPTX
Trying out the Go language with Google App Engine
Lynn Langit
 
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
KAI CHU CHUNG
 
Serverless Computing with Google Cloud
wesley chun
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
Diego Freniche Brito
 
Introduction to Cloud Computing with Google Cloud
wesley chun
 
Introduction to Google Cloud Endpoints: Speed Up Your API Development
Colin Su
 
Developing for Google Glass
Mark Billinghurst
 
Introduction to go
Anthony Chow
 
Introduction to Software Development
Zeeshan MIrza
 
PyQt Application Development On Maemo
achipa
 
Javascript, the GNOME way (JSConf EU 2011)
Igalia
 
Introduction to Google App Engine with Python
Brian Lyttle
 
Android is going to Go! Android and Golang
Almog Baku
 
Android is going to Go! - Android and goland - Almog Baku
DroidConTLV
 
Playing with parse.com
JUG Genova
 
Intro to PhoneGap
Ryan Stewart
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
wesley chun
 
How to Build Your First Web App in Go
All Things Open
 
GAE as Android Test Portal. Part 1.
Åsa Pehrsson
 
Scaling applications with go
Vimlesh Sharma
 
Trying out the Go language with Google App Engine
Lynn Langit
 
Ad

More from Justin Grammens (18)

PDF
Scope Creep - Damned if I Do, Damned if I Don't
Justin Grammens
 
PPTX
Deep Learning with TensorFlow
Justin Grammens
 
PPTX
Speaking at John Carrol University on the Internet of Things
Justin Grammens
 
PPTX
NDC Minnesota 2019 - Fundamentals of Azure IoT
Justin Grammens
 
PDF
This Time, It’s Personal: Why Security and the IoT Is Different
Justin Grammens
 
PDF
Looking into the Future: Using Google's Prediction API
Justin Grammens
 
PDF
The Internet of Things - What It Is, Where Its Headed and Its Applications
Justin Grammens
 
PDF
Internet of Things: What It Is, Where's Headed and Its Applications
Justin Grammens
 
PDF
Collaborative Learning - The Role Communities Play in IoT
Justin Grammens
 
PDF
Internet of Things: What it is, where it is going and how it is being applied.
Justin Grammens
 
PDF
Arduino, Open Source and The Internet of Things Landscape
Justin Grammens
 
PDF
The State of Arduino and IoT
Justin Grammens
 
PDF
Android Minnebar
Justin Grammens
 
PDF
Android TCJUG
Justin Grammens
 
PDF
Voice Enabled Applications
Justin Grammens
 
PDF
Android Intro
Justin Grammens
 
PDF
Adhearsion and Telegraph Framework Presentation
Justin Grammens
 
PDF
Asterisk-Java Framework Presentation
Justin Grammens
 
Scope Creep - Damned if I Do, Damned if I Don't
Justin Grammens
 
Deep Learning with TensorFlow
Justin Grammens
 
Speaking at John Carrol University on the Internet of Things
Justin Grammens
 
NDC Minnesota 2019 - Fundamentals of Azure IoT
Justin Grammens
 
This Time, It’s Personal: Why Security and the IoT Is Different
Justin Grammens
 
Looking into the Future: Using Google's Prediction API
Justin Grammens
 
The Internet of Things - What It Is, Where Its Headed and Its Applications
Justin Grammens
 
Internet of Things: What It Is, Where's Headed and Its Applications
Justin Grammens
 
Collaborative Learning - The Role Communities Play in IoT
Justin Grammens
 
Internet of Things: What it is, where it is going and how it is being applied.
Justin Grammens
 
Arduino, Open Source and The Internet of Things Landscape
Justin Grammens
 
The State of Arduino and IoT
Justin Grammens
 
Android Minnebar
Justin Grammens
 
Android TCJUG
Justin Grammens
 
Voice Enabled Applications
Justin Grammens
 
Android Intro
Justin Grammens
 
Adhearsion and Telegraph Framework Presentation
Justin Grammens
 
Asterisk-Java Framework Presentation
Justin Grammens
 
Ad

Recently uploaded (9)

PDF
Company Introduction of XY Power in EV Charging Segment
Sam Geoff
 
PPTX
White and Blue Illustrated Technology Cybersecurity Presentation.pptx
sysybituin27
 
PPTX
Dental-Occlusion-Assihgvjvvbngnment.pptx
mkurdi133
 
PPTX
Computer based speed tracking passively.pptx
jn4bmprgvt
 
DOCX
What Is Zoning Map Software and Why It Matters for Communities
riffatparveenseo
 
PDF
HUAWEI MOBILE PHONE IMPORTED FROM CHINA TO THAILAND REPORT.pdf.pdf
youyou851038
 
PPTX
CP_CorpOverview_2025-check point 2025.pptx
gary518500
 
PDF
Switchboard Maintenance Checklist with eAuditor Audits & Inspections
eAuditor Audits & Inspections
 
PDF
4 Tips for Reducing Tool Deflection in CNC Machining.pdf
Content Swap
 
Company Introduction of XY Power in EV Charging Segment
Sam Geoff
 
White and Blue Illustrated Technology Cybersecurity Presentation.pptx
sysybituin27
 
Dental-Occlusion-Assihgvjvvbngnment.pptx
mkurdi133
 
Computer based speed tracking passively.pptx
jn4bmprgvt
 
What Is Zoning Map Software and Why It Matters for Communities
riffatparveenseo
 
HUAWEI MOBILE PHONE IMPORTED FROM CHINA TO THAILAND REPORT.pdf.pdf
youyou851038
 
CP_CorpOverview_2025-check point 2025.pptx
gary518500
 
Switchboard Maintenance Checklist with eAuditor Audits & Inspections
eAuditor Audits & Inspections
 
4 Tips for Reducing Tool Deflection in CNC Machining.pdf
Content Swap
 

Physical Computing Using Go and Arduino

  • 1. Go and Get Physical with the Cloud Using Arduino with Google App Engine for Go ! Justin Grammens justin@arduino.mn
  • 2. I Want to Build Something! Goal : Track movement using a motion sensor Technology Requirements: Use Go Use Google App Engine Use Arduino Send text message when movement occurs
  • 3. What We’ll Cover Go Programming Language Deployment on Google App Engine ( using Go ) REST interface on App Engine ( using go-restful ) Reading sensor data on Arduino Sending data to our application on App Engine Send message to 3rd party SMS provider ( Twillio )
  • 5. Go Programming Language Developed by Google in 2007 Statically typed language, loosely derived from C. Automatic memory management FAST compilation and execution! Download at: https://code.google.com/p/go/
  • 6. Go Language Key Points Some dynamic typing ( “x:= 0” instead of “int x = 0” ) Remote package management ( “go get” ) Built in mechanisms for concurrency Able to produce statically linked native binaries Strong focus on support for concurrency
  • 7. Go Language Key Points No type inheritance No method overloading Has pointers, but no pointer arithmetic (ie. can’t be changed) No generics (a la List<String> in Java for instance) No Exceptions - instead uses an error return type func Open(name string) (file *File, err error)
  • 8. Workspaces Designed from the ground up to work with code in public repositories $GOPATH variable points to your workspace location Put your code in a unique path convention is: $GOPATH/src/github/user/project
  • 9. Example Workspace bin/ hello # command executable pkg/ darwin_amd64/github.com/justingrammens mydate.a # package object src/ github.com/justingrammens/ hello/ .git/ # git repository metadata hello.go # package source mydate/ .git/ # git repository metadata mydate.go # package source
  • 10. IDEs / Editors with Plugins Emacs Eclipse - ( GoClipse ) IntelliJ IDEA Sublime Text TextMate Vim
  • 11. Example: hello.go git clone https://github.com/justingrammens/ gdev ! package main import "fmt" func main() { fmt.Println("hello world") } !
  • 12. Example: hello-world.go usage: type “go” on command line $: go run hello.go hello world ! $: go install $: $GOPATH/bin/hello ! $ go build ./hello ( note the size of the executable )
  • 13. Writing a Library package mydate ! import "time" ! func Birthdate() time.Time { d := time.Date(2014, time.May, 6, 0, 0, 0, 0, time.UTC) return d } Return type Capital letter means public access Calling function
  • 14. Publish Library git push to public repository: https://github.com/ justingrammens/gdev Access with: import “github.com/justingrammens/gdev/go- examples/mydate” Anyone can install to their workspace with: go get github.com/justingrammens/gdev/go- examples/mydate
  • 15. Calling Library package main ! import "fmt" import "github.com/justingrammens/gdev/mydate" import "time" ! func main() { now := time.Now() birthday := mydate.Birthdate() diff := birthday.YearDay() - now.YearDay() fmt.Printf("There are only %d days to my birthday!n", diff ) }
  • 16. Example: Functions can return multiple values: func AddandSub(x, y int) (sum, difference int) { sum = x + y difference = x - y return } Called with: sum, difference := mydate.AddandSub(10, 11)
  • 17. App Engine Using Go Platform as a Service (PaSS) Run applications in Google’s infrastructure Frees you up to develop, not system admin Develop and test locally, deploy globally Beware - Go is Experimental! https://developers.google.com/appengine/downloads
  • 18. App Engine Using Go Deployed to [your_app_id].appspot.com Quotas: Request & Response Size - 32 MB Request Duration - 60 sec Max total files - 10,000 total : 1,000 per directory Max size files - 32 MB
  • 19. App Engine Using Go Run “goapp” to see commands goapp serve : runs local server goapp deploy : upload to App Engine
  • 20. App Engine Using Go Run Hello World Example cd appengine-examples goapp server Local service: http://localhost:8080 Local datastore viewer: http://localhost:8000
  • 21. App Engine Using Go No standard REST framework out of the box Use “go-restful” project Easy install and setup with “go get” command Resources: “Events” “Sms”
  • 22. App Engine Using Go Run DevFest App cd devfest goapp server Access swagger for API at http://localhost:8080/apidocs Push update to google app engine at: appcfg.py --oauth2 update my app Manage at: https://appengine.google.com
  • 23. Test Web Service Simple REST Client Verify the values are being stored Toggle values for SMS notifications
  • 24. Arduino Open source microcontroller board Started in Italy in 2005 as a college student project Based on a simplified version of C++ ( Wiring ) Allows for adding additional boards via “shields” WIFI shield is added for our project Many readily available sensors and libraries!
  • 26. Hardware Parts PIR Motion Sensor - $9.95 Arduino R3 Board - $30.00 Official Arduino WIFI Shield - $70.00
  • 28. Arduino Basics Only 2 functions are required ! void setup() { // put your setup code here, to run once. } ! void loop() { // put your main code here, to run repeatedly. }
  • 29. Motion Sample Code Motion activated by: Takes an infrared “snapshot” of the room If anything changes, pin #2 goes LOW Use the digitalRead of values Use WifiClient to Post JSON to our web service. Print the status to the serial monitor.
  • 30. Resources Play with Go Code! http://tour.golang.org/ https://groups.google.com/forum/m/#!forum/google- appengine-go https://developers.google.com/appengine/docs/go/ http://arduino.mn - Local Arduino user’s group!