SlideShare a Scribd company logo
1 of 23
Riaan Cornelius
Project Hoptimus – Automating the home brewing process
What will we be covering
> Beer brewing 101
> Project Hoptimus
> Challenges when developing IOT solutions
> Clean architecture
> What’s next
Beer brewing 101
Beer brewing 101
Malting
Mashing
Lautering Boiling
Whirlpooling
Fermenting Conditioning
Filtering
Packaging
Beer brewing 101
Beer brewing process - simplified
Mashing
• Extracting sugars from malted barley
• Separating wort from grains
Boiling
• Boiling wort
• Adding hops, spices or other additives
Fermenting
• Adding yeast to boiled (and cooled) wort
• Fermenting at a specific temperature until all sugar is converted
Packaging
• Getting beer into some vessel (Bottle or keg usually)
• Enjoy once beer is carbonated
Project Hoptimus - Requirements
Recipe
•Import recipe (BeerXML standard)
•Display overview and current brew process
Mashing
•Pump in correct amount of water
•Monitor temperature for mash duration
•Pump wort to boil kettle
Boil
•Boil water for boil duration
•Alarms to add hops / additives
•Pump wort to fermenter once wort is cooled
Ferment
•Monitor and control temperature for duration of fermentation
•Monitor specific gravity to determine when fermentation is done
•Log all measurements to cloud database
Challenges when developing IOT applications
> Hardware is difficult to emulate
> Testing physical sensors is hard
> God objects abound in Android
> Behaviour tends to spread across classes
Clean Architecture
Hexagonal architecture
> Not a silver bullet
> Separates contract from implementation
> Makes code easier to test
> Allows running your IOT app on an emulator
Hexagonal Architecture
Hexagonal architecture on Android Things
> We need to create a standard Android Things project and make two
simple changes:
1. Add a provided dependency to your build.gradle
2. Add an intent filter to your manifest
> For each service / piece of hardware
1. Create a port (the contract)
2. Create an adapter for a mock implementation
3. Create an adapter for the real implementation
Project setup – build.gradle
apply plugin: 'com.android.application'
android {
...
}
dependencies {
...
compileOnly 'com.google.android.things:androidthings:0.7-devpreview'
...
}
Project setup – intent filter
<activity android:name=".HomeActivity"
android:label="@string/app_name">
<!-- This allows launching on an emulator -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- This is to launch at boot on AndroidThings -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.IOT_LAUNCHER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Hardware setup – Port (contract)
public interface TemperatureSensor {
Float read();
void close();
}
Hardware setup – Adapter (mock implementation)
public class MockTemperatureSensor implements TemperatureSensor {
private static final String TAG = MockTemperatureSensor.class.getSimpleName();
@Override
public Float read() {
return 23.3F;
}
@Override
public void close() {
Log.d(TAG, "close");
}
}
Hardware setup – Adapter (real implementation)
public class BMP280TemperatureSensor implements TemperatureSensor {
private Bmx280SensorDriver driver;
// ...
private Float temperature;
public BMP280TemperatureSensor(Context context) {
// ...
driver = new Bmx280SensorDriver("I2C1");
driver.registerTemperatureSensor();
}
@Override
public Float read() {
return temperature;
}
@Override
public void close() {
// ...
driver.close();
}
private class TemperatureListener implements SensorEventListener { ... }
}
Hardware setup – Activity
class TemperatureActivity : Activity() {
private lateinit var temperatureSensor: TemperatureSensor
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_temperature)
temperatureSensor = getTempSensor()
val button = findViewById<Button>(R.id.button)
val text = findViewById<TextView>(R.id.textTemperature)
button.setOnClickListener({ text.text = temperatureSensor.read().toString() })
}
private fun getTempSensor(): TemperatureSensor {
return if (BuildConfig.MOCK_BUILD) {
MockTemperatureSensor()
} else {
BMP280TemperatureSensor(this)
}
}
}
Hardware setup – BuildTypes
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "MOCK_BUILD", "false"
}
debug {
minifyEnabled false
buildConfigField "boolean", "MOCK_BUILD", "true"
}
}
Hardware setup – Testing
@LargeTest
@RunWith(AndroidJUnit4.class)
public class TemperatureActivityTest {
@Rule
public ActivityTestRule<TemperatureActivity> mActivityTestRule =
new ActivityTestRule<>(TemperatureActivity.class);
@Test
public void temperatureActivityTest() {
// Click button to read temperature
ViewInteraction button = onView(allOf(withId(R.id.button), withText("Read"),
childAtPosition(childAtPosition(withId(android.R.id.content), 0), 0),
isDisplayed()));
button.perform(click());
// Check temperature was read from port
ViewInteraction textView2 = onView(allOf(withId(R.id.textTemperature),
childAtPosition(childAtPosition(withId(android.R.id.content), 0), 1),
isDisplayed()));
textView2.check(matches(withText("23.3")));
}
}
Hardware setup - Testing
What’s next?
> Gluing it all together
> More complex sensors
> Google Nearby API to get alarms / reminders on my phone
/* THANK YOU*/
Riaan Cornelius
http://riaancornelius.com/
riaan.cornelius@entelect.co.za
@riaancornelius
http://www.devconf.co.za/

More Related Content

What's hot

Git workflows
Git workflowsGit workflows
Git workflowsXpand IT
 
Git Workflow With Gitflow
Git Workflow With GitflowGit Workflow With Gitflow
Git Workflow With GitflowJosh Dvir
 
Git Ready! Workflows
Git Ready! WorkflowsGit Ready! Workflows
Git Ready! WorkflowsAtlassian
 
CocoaPods introduction
CocoaPods introductionCocoaPods introduction
CocoaPods introductionJordi Giménez
 
Chef at Etsy
Chef at EtsyChef at Etsy
Chef at EtsyJon Cowie
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGeoff Hoffman
 
Git-flow workflow and pull-requests
Git-flow workflow and pull-requestsGit-flow workflow and pull-requests
Git-flow workflow and pull-requestsBartosz Kosarzycki
 
Chef Intro @ SF Bay Area LSPE meetup
Chef Intro @ SF Bay Area LSPE meetupChef Intro @ SF Bay Area LSPE meetup
Chef Intro @ SF Bay Area LSPE meetupmdxp
 
Chef for beginners module 1
Chef for beginners   module 1Chef for beginners   module 1
Chef for beginners module 1Chef
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation WorkshopChef
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshareRakesh Sukumar
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflowsArthur Shvetsov
 
Rise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentRise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentSven Peters
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategiesjstack
 
Michelin Starred Cooking with Chef
Michelin Starred Cooking with ChefMichelin Starred Cooking with Chef
Michelin Starred Cooking with ChefJon Cowie
 

What's hot (20)

Git workflows
Git workflowsGit workflows
Git workflows
 
Using Cocoapods
Using CocoapodsUsing Cocoapods
Using Cocoapods
 
Git Workflow With Gitflow
Git Workflow With GitflowGit Workflow With Gitflow
Git Workflow With Gitflow
 
Git Ready! Workflows
Git Ready! WorkflowsGit Ready! Workflows
Git Ready! Workflows
 
CocoaPods introduction
CocoaPods introductionCocoaPods introduction
CocoaPods introduction
 
Chef at Etsy
Chef at EtsyChef at Etsy
Chef at Etsy
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Git-flow workflow and pull-requests
Git-flow workflow and pull-requestsGit-flow workflow and pull-requests
Git-flow workflow and pull-requests
 
Chef Intro @ SF Bay Area LSPE meetup
Chef Intro @ SF Bay Area LSPE meetupChef Intro @ SF Bay Area LSPE meetup
Chef Intro @ SF Bay Area LSPE meetup
 
Chef for beginners module 1
Chef for beginners   module 1Chef for beginners   module 1
Chef for beginners module 1
 
Compliance Automation Workshop
Compliance Automation WorkshopCompliance Automation Workshop
Compliance Automation Workshop
 
Behat sauce
Behat sauceBehat sauce
Behat sauce
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Git collaboration
Git collaborationGit collaboration
Git collaboration
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
Rise of the Machines - Automate your Development
Rise of the Machines - Automate your DevelopmentRise of the Machines - Automate your Development
Rise of the Machines - Automate your Development
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
Michelin Starred Cooking with Chef
Michelin Starred Cooking with ChefMichelin Starred Cooking with Chef
Michelin Starred Cooking with Chef
 
Gitflow
GitflowGitflow
Gitflow
 
Git and git hub
Git and git hubGit and git hub
Git and git hub
 

Similar to Project Hoptimus - Brewing beer using Android Things

Auto Code Generation and Rapid Brewery/Distillery Automation
Auto Code Generation and Rapid Brewery/Distillery AutomationAuto Code Generation and Rapid Brewery/Distillery Automation
Auto Code Generation and Rapid Brewery/Distillery AutomationDMC, Inc.
 
Flamingo Hello World Tutorial
Flamingo Hello World TutorialFlamingo Hello World Tutorial
Flamingo Hello World Tutoriali-love-flamingo
 
AAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
AAI-3218 Production Deployment Best Practices for WebSphere Liberty ProfileAAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
AAI-3218 Production Deployment Best Practices for WebSphere Liberty ProfileWASdev Community
 
A Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef SupermarketA Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef SupermarketNell Shamrell-Harrington
 
Get started with docker &amp; dev ops
Get started with docker &amp; dev opsGet started with docker &amp; dev ops
Get started with docker &amp; dev opsAsya Dudnik
 
Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Amazon Web Services
 
InSpec at DevOps ATL Meetup January 22, 2020
InSpec at DevOps ATL Meetup January 22, 2020InSpec at DevOps ATL Meetup January 22, 2020
InSpec at DevOps ATL Meetup January 22, 2020Mandi Walls
 
Beta testing iPhone apps
Beta testing iPhone appsBeta testing iPhone apps
Beta testing iPhone appsShawn Grimes
 
Prescriptive System Security with InSpec
Prescriptive System Security with InSpecPrescriptive System Security with InSpec
Prescriptive System Security with InSpecAll Things Open
 
Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019Mandi Walls
 
Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3kidtangerine
 
Managed Beans: When, Why and How
Managed Beans: When, Why and HowManaged Beans: When, Why and How
Managed Beans: When, Why and HowRussell Maher
 
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsDevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsAmazon Web Services
 
Get started with docker &amp; dev ops
Get started with docker &amp; dev opsGet started with docker &amp; dev ops
Get started with docker &amp; dev opsAsya Dudnik
 
Dev ops &amp; laas fundamental
Dev ops &amp; laas fundamentalDev ops &amp; laas fundamental
Dev ops &amp; laas fundamentalKanin Kearpimy
 
WordPress Acceptance Testing, Solved!
WordPress Acceptance Testing, Solved!WordPress Acceptance Testing, Solved!
WordPress Acceptance Testing, Solved!Taylor Lovett
 

Similar to Project Hoptimus - Brewing beer using Android Things (20)

Auto Code Generation and Rapid Brewery/Distillery Automation
Auto Code Generation and Rapid Brewery/Distillery AutomationAuto Code Generation and Rapid Brewery/Distillery Automation
Auto Code Generation and Rapid Brewery/Distillery Automation
 
Flamingo Hello World Tutorial
Flamingo Hello World TutorialFlamingo Hello World Tutorial
Flamingo Hello World Tutorial
 
Maven
MavenMaven
Maven
 
AAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
AAI-3218 Production Deployment Best Practices for WebSphere Liberty ProfileAAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
AAI-3218 Production Deployment Best Practices for WebSphere Liberty Profile
 
A Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef SupermarketA Supermarket of Your Own: Running a Private Chef Supermarket
A Supermarket of Your Own: Running a Private Chef Supermarket
 
Get started with docker &amp; dev ops
Get started with docker &amp; dev opsGet started with docker &amp; dev ops
Get started with docker &amp; dev ops
 
Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Maven advanced
Maven advancedMaven advanced
Maven advanced
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
 
InSpec at DevOps ATL Meetup January 22, 2020
InSpec at DevOps ATL Meetup January 22, 2020InSpec at DevOps ATL Meetup January 22, 2020
InSpec at DevOps ATL Meetup January 22, 2020
 
Beta testing iPhone apps
Beta testing iPhone appsBeta testing iPhone apps
Beta testing iPhone apps
 
CICD_1670665418.pdf
CICD_1670665418.pdfCICD_1670665418.pdf
CICD_1670665418.pdf
 
Prescriptive System Security with InSpec
Prescriptive System Security with InSpecPrescriptive System Security with InSpec
Prescriptive System Security with InSpec
 
Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019Prescriptive Security with InSpec - All Things Open 2019
Prescriptive Security with InSpec - All Things Open 2019
 
Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3
 
Managed Beans: When, Why and How
Managed Beans: When, Why and HowManaged Beans: When, Why and How
Managed Beans: When, Why and How
 
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer ToolsDevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
DevOps on AWS: Accelerating Software Delivery with the AWS Developer Tools
 
Get started with docker &amp; dev ops
Get started with docker &amp; dev opsGet started with docker &amp; dev ops
Get started with docker &amp; dev ops
 
Dev ops &amp; laas fundamental
Dev ops &amp; laas fundamentalDev ops &amp; laas fundamental
Dev ops &amp; laas fundamental
 
WordPress Acceptance Testing, Solved!
WordPress Acceptance Testing, Solved!WordPress Acceptance Testing, Solved!
WordPress Acceptance Testing, Solved!
 

Recently uploaded

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
[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.pdfhans926745
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Recently uploaded (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
[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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Project Hoptimus - Brewing beer using Android Things

  • 1. Riaan Cornelius Project Hoptimus – Automating the home brewing process
  • 2. What will we be covering > Beer brewing 101 > Project Hoptimus > Challenges when developing IOT solutions > Clean architecture > What’s next
  • 4. Beer brewing 101 Malting Mashing Lautering Boiling Whirlpooling Fermenting Conditioning Filtering Packaging
  • 6. Beer brewing process - simplified Mashing • Extracting sugars from malted barley • Separating wort from grains Boiling • Boiling wort • Adding hops, spices or other additives Fermenting • Adding yeast to boiled (and cooled) wort • Fermenting at a specific temperature until all sugar is converted Packaging • Getting beer into some vessel (Bottle or keg usually) • Enjoy once beer is carbonated
  • 7. Project Hoptimus - Requirements Recipe •Import recipe (BeerXML standard) •Display overview and current brew process Mashing •Pump in correct amount of water •Monitor temperature for mash duration •Pump wort to boil kettle Boil •Boil water for boil duration •Alarms to add hops / additives •Pump wort to fermenter once wort is cooled Ferment •Monitor and control temperature for duration of fermentation •Monitor specific gravity to determine when fermentation is done •Log all measurements to cloud database
  • 8. Challenges when developing IOT applications > Hardware is difficult to emulate > Testing physical sensors is hard > God objects abound in Android > Behaviour tends to spread across classes
  • 10. Hexagonal architecture > Not a silver bullet > Separates contract from implementation > Makes code easier to test > Allows running your IOT app on an emulator
  • 12. Hexagonal architecture on Android Things > We need to create a standard Android Things project and make two simple changes: 1. Add a provided dependency to your build.gradle 2. Add an intent filter to your manifest > For each service / piece of hardware 1. Create a port (the contract) 2. Create an adapter for a mock implementation 3. Create an adapter for the real implementation
  • 13. Project setup – build.gradle apply plugin: 'com.android.application' android { ... } dependencies { ... compileOnly 'com.google.android.things:androidthings:0.7-devpreview' ... }
  • 14. Project setup – intent filter <activity android:name=".HomeActivity" android:label="@string/app_name"> <!-- This allows launching on an emulator --> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <!-- This is to launch at boot on AndroidThings --> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.IOT_LAUNCHER" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
  • 15. Hardware setup – Port (contract) public interface TemperatureSensor { Float read(); void close(); }
  • 16. Hardware setup – Adapter (mock implementation) public class MockTemperatureSensor implements TemperatureSensor { private static final String TAG = MockTemperatureSensor.class.getSimpleName(); @Override public Float read() { return 23.3F; } @Override public void close() { Log.d(TAG, "close"); } }
  • 17. Hardware setup – Adapter (real implementation) public class BMP280TemperatureSensor implements TemperatureSensor { private Bmx280SensorDriver driver; // ... private Float temperature; public BMP280TemperatureSensor(Context context) { // ... driver = new Bmx280SensorDriver("I2C1"); driver.registerTemperatureSensor(); } @Override public Float read() { return temperature; } @Override public void close() { // ... driver.close(); } private class TemperatureListener implements SensorEventListener { ... } }
  • 18. Hardware setup – Activity class TemperatureActivity : Activity() { private lateinit var temperatureSensor: TemperatureSensor override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_temperature) temperatureSensor = getTempSensor() val button = findViewById<Button>(R.id.button) val text = findViewById<TextView>(R.id.textTemperature) button.setOnClickListener({ text.text = temperatureSensor.read().toString() }) } private fun getTempSensor(): TemperatureSensor { return if (BuildConfig.MOCK_BUILD) { MockTemperatureSensor() } else { BMP280TemperatureSensor(this) } } }
  • 19. Hardware setup – BuildTypes buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' buildConfigField "boolean", "MOCK_BUILD", "false" } debug { minifyEnabled false buildConfigField "boolean", "MOCK_BUILD", "true" } }
  • 20. Hardware setup – Testing @LargeTest @RunWith(AndroidJUnit4.class) public class TemperatureActivityTest { @Rule public ActivityTestRule<TemperatureActivity> mActivityTestRule = new ActivityTestRule<>(TemperatureActivity.class); @Test public void temperatureActivityTest() { // Click button to read temperature ViewInteraction button = onView(allOf(withId(R.id.button), withText("Read"), childAtPosition(childAtPosition(withId(android.R.id.content), 0), 0), isDisplayed())); button.perform(click()); // Check temperature was read from port ViewInteraction textView2 = onView(allOf(withId(R.id.textTemperature), childAtPosition(childAtPosition(withId(android.R.id.content), 0), 1), isDisplayed())); textView2.check(matches(withText("23.3"))); } }
  • 21. Hardware setup - Testing
  • 22. What’s next? > Gluing it all together > More complex sensors > Google Nearby API to get alarms / reminders on my phone
  • 23. /* THANK YOU*/ Riaan Cornelius http://riaancornelius.com/ riaan.cornelius@entelect.co.za @riaancornelius http://www.devconf.co.za/