1 of 49

Automating our home with Android Things

2 of 49

About me

@sergioch23

github.com/sergiocasero

sergio.casero23@gmail.com

@sergioch23

3 of 49

4 of 49

Madrid Android Developer Group

5 of 49

About Android Things

6 of 49

About Android Things

7 of 49

About Android Things

  • GPIO

  • PWM

  • Serial

8 of 49

About Android Things

9 of 49

About Android Things

10 of 49

Pinouts

11 of 49

Config

12 of 49

Hardware

13 of 49

Hardware

Lights

Rain

Thermostat

Fire detector

Alarm

14 of 49

Hardware

Lights

Relay

Triac

Link: https://goo.gl/opVD0s

Cost: 1€

Link: https://goo.gl/pD8seZ

Cost: 0,15€

15 of 49

Hardware

Rain

YL-83 / LM393

Link: https://goo.gl/Cd5THt

Cost: 0,52€

16 of 49

Hardware

Thermostat

DHT22

DS18B20

Link: https://goo.gl/smO2nE

Cost: 2,27€

Link: https://goo.gl/rhHIje

Cost: 0,524€

17 of 49

Hardware

Fire detector

MQ2

Link: https://goo.gl/8jSkCz

Cost: 0,88€

18 of 49

Hardware

HC-SR501

Alarm

Link: https://goo.gl/CBUHqQ

Cost: 0,75€

19 of 49

Hardware

HC-SR501

Alarm

Link: https://goo.gl/CBUHqQ

Cost: 0,75€

20 of 49

Hardware

21 of 49

Hardware

22 of 49

ESP8266

  • 802.11 b/g/n
  • Integrated low power 32-bit MCU
  • Integrated 10-bit ADC
  • Integrated TCP/IP protocol stack
  • Integrated TR switch, balun, LNA, power amplifier and matching network
  • Integrated PLL, regulators, and power management units
  • Supports antenna diversity
  • WiFi 2.4 GHz, support WPA/WPA2
  • Support STA/AP/STA+AP operation modes
  • Support Smart Link Function for both Android and iOS devices
  • SDIO 2.0, (H) SPI, UART, I2C, I2S, IR Remote Control, PWM, GPIO
  • STBC, 1x1 MIMO, 2x1 MIMO
  • A-MPDU & A-MSDU aggregation & 0.4s guard interval
  • Deep sleep power <10uA, Power down leakage current < 5uA
  • Wake up and transmit packets in < 2ms • Standby power consumption of < 1.0mW (DTIM3)
  • +20 dBm output power in 802.11b mode • Operating temperature range -40C ~ 125C
  • FCC, CE, TELEC, WiFi Alliance, and SRRC certified
  • Link: https://goo.gl/X5VmHw
  • Cost: 1,67€

23 of 49

ESP8266

24 of 49

ESP8266

25 of 49

Development

26 of 49

  1. “Authentication”

  • Detecting sensors

  • Using sensors

27 of 49

Authentication

28 of 49

Limitations

  1. No keyboard

2. No mouse

3. No touchscreen

4. No Auth API

29 of 49

The way

  1. Android Things device generates QR

  • Phone reads the QR Code

  • Phone matches with Firebase database

  • Put user information into the database

  • Android Things receives the data

User is paired with device ;)

30 of 49

  1. Generate unique id

31 of 49

2 & 3. Phone reads the QR

32 of 49

4. Put user info into the database

33 of 49

4. Android Things receives the data

34 of 49

Read unique ID, push info to firebase and read in the Android Things device

Generate unique ID and push it to Firebase

35 of 49

User is paired with device ;)

36 of 49

Detecting sensors

37 of 49

Considerations

  1. Wire and Wireless sensors

  • User could be out of network

  • The process should be easy and semi automatic

38 of 49

Wire sensors

39 of 49

Wireless sensors

  • Unique IP Address (192.168.1.XXX)

  • Android things device and sensors will be connected to the same network

  • Android Things device can use retrofit so...

40 of 49

Wireless sensors

Defining custom API

  • id: IP Address
  • label: User could change sensor label
  • Type: Important, we have TERMOSTAT, SWITCH, ALARM...
  • Value: The value (Example: In SWITCH can be 0, 1)

1 mandatory service: IP_ADDRESS/type

41 of 49

Wireless sensors

How to

192.168.1.100/type RETURN Sensor

192.168.1.101/type TIMEOUT

...

192.168.1.149/type RETURN Sensor

192.168.1.150/type TIMEOUT

42 of 49

Wireless sensors

How to

43 of 49

Wireless sensors

How to

44 of 49

Using sensors

45 of 49

Using sensors

How to

46 of 49

Using sensors

How to

47 of 49

48 of 49

Links

  • https://www.raspberrypi.org/

  • http://www.esp8266.com/

  • https://github.com/esp8266

  • https://www.arduino.cc/

  • https://android.jlelse.eu/getting-started-with-android-things-b73be3295b42?gi=8a1eac13f919

49 of 49

Thanks