- The document describes the Full Stack Meat Project called 'GrillLog', which is a custom-built dual probe BBQ thermometer that connects to cloud services.
- It uses an Arduino Yun device to read temperatures every 10 seconds and send the data to AWS IoT. Lambda functions then process the data and store it in DynamoDB.
- Notifications are sent using SNS, and interfaces include a web app, iOS app, and Alexa skill to view temperatures and statuses. The goal is to learn new technologies while building a useful grill monitoring tool.
2. What are we talking about?
Creating a custom built dual probe BBQ
thermometer instead of buying one
3. Motivation
● Learn Arduino and basic electronics
● Be able to see grill temperatures on my devices
● Get notified when it was ready
● Learn AWS
● I thought it’d be similar in cost...
4. About Me
● http://www.kevinkaz.com
● @kazmiekr
● Solutions Architect for Universal Mind
● Two Alexa skills published
○ TechBuzz - MBTA Alerts
● 4 Apple Apps - Download them!
Taptronome FuelMate Battle Pet
Galaxy
MadBombz
12. Arduino Basics
● 14 Digital I/O Pins ( 6 PWM )
● 6 Analog
● 5V
● Embedded code written in C/C++ as a ‘Sketch’
13. Arduino Yun
● Device details
○ Built in wifi
○ Two processors, traditional ATmega and AR9331 (Linux)
○ Linux processor handles all the more CPU intensive tasks ( wifi / data processing )
○ ATmega handles reading/writing outputs
● How does it compare to others?
● Could you replace this with a RPi?
15. GrillLog Implementation
● Every 10 seconds the device reads two
analog inputs
● Using a Steinhart–Hart equation, it
converts the analog resistance to
temperature
● Equation coefficients calibrated by
taking 3 different temperatures and
plugged into an online calculator
● Current readings are dumped to Serial
and the LCD display
16.
17. AWS Fine Print
● Sign up for a free tier trial account
● One year of free tier account services
● Some of the core services have very generous free limits even
without a trial account
● Pay for what you use
● Security
○ Ensure that there are roles setup that have access to execute the pieces of the
different services
18. AWS IoT
● Allows device to communicate over MQTT with encrypted traffic
● MQTT - Lightweight messaging protocol, think JMS or Pub/Sub
● Each device gets a signed certificate to use with messaging
● Devices can have shadows for offline sync
● Compatible devices - Anything that can do secure MQTT
● Use command line mosquitto to simulate device messaging
20. AWS IoT Rules
● Rules can filter messages into different channels
● SQL query like syntax to set them up
● Use built in actions
● Lambda is most flexible action
21. GrillLog Implementation
● Yun has certificates installed
● Yun constructs JSON document of
temps
● Yun posts message on ‘templogs’ topic
● AWS has a rule that all incoming
‘templog’ messages are forwarded to a
lambda function
● Tweaked AWS config to solve memory
issues
22. AWS Lambda
● Runs code in response to events
● Pay for what you consume
● Develop in Javascript/Java/Python
● No servers to manage or scale
● Core service used to integrate across AWS
● Pricing
○ First 1 million requests per month are free
○ $0.20 per 1 million requests thereafter ($0.0000002 per request)
23. Lamba Basics
● Can start from one of their many templates
○ Language specific
○ Voice templates
○ Microservices
○ Hello world
● Export a ‘handler’ that takes and event, context, callback
● Do whatever
exports.handler = function(event, context, callback) {
console.log("value1 = " + event.key1);
console.log("value2 = " + event.key2);
callback(null, "some success message");
// or
// callback("some error type");
}
24. GrillLog Implementation
● Three lambda functions
○ Handle incoming IoT messages
○ Handle web requests
○ Handle voice requests
● All three lambdas just forward
into a custom
controller/service layer written
in Node.js
25. Custom Service Layer
● AWS supports Node 4.3 (finally!!!)
○ ES2016 (ES6) features
■ Promises/arrow functions/etc - check for support before using
● Controller processes input and utilizes services needed
○ Could swap out service implementations later if needed
● Promise based - AWS sdk methods can return a promise
● Easy to test via command line locally
● Use any packages you need via npm
● Service layer gets packaged with lambda
26. GrillLog Implementation
● Utilizes the aws-sdk package
● Deployed via shell script
○ Creates a zip file of required files
○ Calls AWS specific CLI tooling
○ Cleans up
● Uploads a zip per each lambda
endpoint
27. AWS DynamoDB
● NoSQL database similar to MongoDB
○ Schema-less
● Event driven hooks
● Easy to save data, not as easy to query
● Integration with other AWS services with streams/triggers
● Pricing
○ 25 GB in free tier, pay per usage
○ “For a little less than $0.25/day ($7.50/month), you could support an application
that performs 1 million writes and reads per day”
28. DynamoDB Basics
● Each table has a primary key (hash key) - Most unique
● Optional sort key - What will I most likely sort on?
● Get data out via either a ‘scan’ or ‘query’
○ ‘query’ requires primary key then you add filter criteria
● Indexes are required to speed up queries
● Sorting is tricky
● No date datatype, have to use a timestamp number
● Save whatever!
29. GrillLog Implementation
● Contains 3 tables
○ DeviceStatus
■ Current status information per device
○ TempLogs
■ Raw temp data from device
○ CookLogs
■ Archived cook data
30. AWS SNS - Simple Notification Service
● Pub-sub messaging
● Deliver across multiple protocols
○ iOS/Android
○ Email
○ SMS
● Hooks into other services
● Pricing
○ Your first 1 million push requests are free
○ $0.50 per 1 million Amazon SNS requests thereafter.
31. SNS Basics
● Create platform application
○ Need certificates to handle push integration with Apple/Google
● Devices can register to application with token
● Messages can be sent to the endpoints registered
● Raw or JSON
● Can tie multiple endpoints together via subscriptions
○ Topic could post to email and push together
● Push messages via AWS dashboard
32. GrillLog Implementation
● Devices are manually registered with
device token on dashboard
● Application endpoint created with
Apple push certificates from iTunes
provisioning portal
● Custom services push JSON formatted
messages for Apple devices
33. AWS API Gateway
● Deploy a customized API
● Define the resources that can be called
● SDK generation
● Authentication - keys, IAM, CORS
● Pricing
○ Free tier includes one million API calls per month for up to 12 months
○ $3.50 per million API calls received, plus the cost of data transfer out, in gigabytes.
34. API Gateway Basics
● You can create an API endpoint from the lambda ‘API endpoints’ tab
● Create resources as endpoints like
○ /status or /logs
● Add methods to those resources
○ GET/POST/PUT
● Point those endpoints to a lambda or proxy
● Configure the mappings - How will data pass through
● Customize as needed
● Create multiple ‘stages’ that you can deploy to
35. GrillLog Implementation
● Exposes REST endpoints
○ status/logs/startgrill/startcook/endgrill
● CORS enabled on status/logs for web
● Mobile clients handle state movement
● Entire request information is
forwarded to a lambda
● Lambda determines what the URL
should do and call proper controller
method in custom services
36. Alexa Integration
● Registered skill on amazon developer site
● Forward to lambda or custom deployed services (HTTPS)
● Register intents ( voice input formats )
● Deploy to app store - Requires approval
○ They are VERY strict that you follow the guidelines
○ You could get a free t-shirt
● Test on developer site
○ Lets you hear responses and see source JSON
● Detailed skill creation walkthrough
38. GrillLog Implementation
● Registered skill forwarding to lambda
● Simple ‘what’s the status’ intent
● Calls into custom services to grab
current status
● Converts response into a text string
passed back to voice services
40. iOS Application
● Apple developer account - $99
○ Be able to deploy to devices and provision
● Configured app in iTunes connect
● Generate APNS certs imported to SNS
● Written in Swift
● Polls for temp status every 10 sec
● Regenerates chart every 30 sec
● Uses ‘Charts’ project for charting
● Sends push notifications
○ Warm temperature threshold
○ Food temperature
● Background fetch to detect offline situations
41. Web Application
● Deployed on http://grilllog.kevinkaz.com
● Written in ES2016 transpiled in webpack
● Uses D3 to handle charting
● Uses a fetch polyfill
● Styling done in Less
42. Android Application
● Written by coworker, Chris Scott
● Mortar and Flow for view lifecycles
● Dagger for dependency injection
● RxJava and Retrofit for service integration
43. Future Plans
● PID Controller for fan controlled temperature
control
● Apple Watch Complication
● Waterproof case
● More notifications
● Review past cooks
● Archive condensed logs