Event

0.Introduction – Announcement and overview of SwiftHome

0.Introduction – Announcement and overview of SwiftHome

This article is based on the session presented at iOSDC2022, Make your home more convenient and safe with Swift! This is an article that summarizes the introduction to Part 0 of the announcement.

What is this announcement about?

This announcement is about implementing Swift on the Raspberry Pi and Heroku.
Specifically,

  1. Enhance existing smart home functions
  2. Monitor the status of your home
  3. Connect iPhone and Raspberry Pi via Heroku

Something like that!


I named this project SwiftHome this time!

Glossary
What is a smart home?
  • Enable control of home appliances via the network
  • For example, turn on the lights in the living room from Google Home!
  • “OK, Google, turn on the living room lights!”
What is a Raspberry Pi?
  • Official name for Raspberry Pi
  • Small single board computer
  • SD card with OS
What is Heroku?
  • Service that provides the necessary platform to run applications (PaaS)
  • Convenient and easy-to-use rental server An image like this
  • This time, it will be used to deploy a server implemented with Vapor (one of the ServerSideSwift frameworks)

In short, smart home is good! ! This is the announcement! ! !

What to say/don’t say in this presentation

○Speaking

  • Implementation of Swift and Vapor on Raspberry Pi and Heroku
  • Among the functions to be realized, core implementation procedures and details (details are described in the blog)
  • Failures in implementation and personal trial and error methods

×Don’t talk

  • How to set up a Raspberry Pi
  • Details and principles of technical elements mainly around the hardware

Notes on presentation content

  1. The presenter is not well versed in hardware technology
    • The information presented may be inaccurate or lacking
  2. The code and repository that we are implementing this time are developed by an individual, so there are many places where architecture and security have not been properly considered
  3. Presentation time and slides due to space constraints, I can’t publish/write all the code and information, so please check the blog post (described later) for details

Implemented this time

I tried to put together what I implemented in SwiftHome this time in a certain OS style!
I will introduce the contents described here in this announcement and blog in order!


Configure SwiftHome

Three applications will appear in SwiftHome implemented this time.

  1. SwiftHomeApp (Mobile app implemented on iPhone)
    1. Send location information and elevation data to Heroku to determine if the user is at home
    2. Suica Scan ID and send to Heroku
  2. SwiftHomeServer(Server application implemented with Vapor running on Heroku)
    1. Implement API/WebSocket and send data
    2. Storing data in Postgres
  3. SwiftHomeApp(running on Raspberry Pi Swift Package)
    1. Using Raspberry Pi GPIO to operate LEDs, read sensor data
    2. Swift/Vapor implementation
    3. To operate home appliances , API execution of SwitchBot
    4. Execution of Python/Bash code from Swift


In SwiftHome, SwiftHomeApp and SwiftHomePi exchange data via SwiftHomeServer.
For communication, we use RestAPI and WebSocket communication.
In consideration of security, direct API communication to the Raspberry Pi is not allowed!

Glossary
What are GPIOs?
  1. Abbreviation for ‘General Purpose Input/Output’, a general-purpose I/O port
  2. As shown below Each port has a different role, such as power supply, GND (negative), and I/O.
  3. You can connect LEDs, sensors, etc. to these pins and operate them by creating a circuit. Photos!)

Tester

When doing electronic work, it is convenient to have a tool called a tester like the one below!
You can check how much current and voltage is flowing, and you can use it to check if the LED or cord is broken!
Even if the code and circuit are well made, If the LED is broken or the code is disconnected, it will take a long time to identify the cause So I’m pretty happy to be able to reduce that risk! !

By the way, at the time of writing, it was about 1000 yen, which was surprisingly cheap, so I bought it!
The sense of security that can be used to check if it is broken was amazing! lol

Wrap up

This article summarizes the introductory content of the SwiftHome announcement.
The next article will be “1. Running Swift on a Raspberry Pi – Blinking an LED using GPIO“!

1. Run Swift on Raspberry Pi - Use GPIO to blink an LEDThis article is an article that summarizes the contents of part 1 of the announcement of "Make your home more convenient and safe with Swift", "Running Swift on a Raspberry Pi - Blinking LEDs using GPIO"!...
+1

COMMENT

Your email address will not be published. Required fields are marked *

CAPTCHA