3. Mr Sulu, our coordinates, please...
Physical
World
Cloud
4. At a glance
SAFETY &
SECURITY
SAFETY &
SECURITY
HOME
APPLIANCES
HOME
APPLIANCES
CONNECTED
CARS
CONNECTED
CARSSMART METERSSMART METERS
INDUSTRY 4.0INDUSTRY 4.0
SALES &
VENDING
SALES &
VENDING
PORTABILITYPORTABILITY
LARGE, VIBRANT,
PROFESSIONAL
COMMUNITY
LARGE, VIBRANT,
PROFESSIONAL
COMMUNITY
FULL-STACK
CLOUD
SERVICES
FULL-STACK
CLOUD
SERVICES
SECURITYSECURITY
ON DEVICE
INTELLIGENCE
ON DEVICE
INTELLIGENCE
MODERN
ARCHITECTURE
AND
LANGUAGES
MODERN
ARCHITECTURE
AND
LANGUAGES
5. Environment
●
Same architecture
●
Same IDE (Android Studio)
●
Same programming language(s)
●
Same framework
●
Same app (Activity) lifecycle
●
Same UI widgets (UI?)
●
Same application packaging
●
Same reliable security for apps and frmware
upgrade
●
Same passionate community
10. SOM: System On Module
A system on a module (SOM) is a board-level circuit that integrates
a system function in a single module.
A typical SOM consists of:
●
a microcontroller, microprocessor or digital signal processor
(DSP)
●
memory blocks including a selection of ROM, RAM, EEPROM
and/or fash memory
●
timing sources
●
industry standards interface such as USB, FireWire, Ethernet,
UART, SPI
●
peripherals including counter-timers, real-time timers and power-
on reset generators
●
analog interfaces including ADCs and DACs
●
voltage regulators and power management circuits
https://en.wikipedia.org/wiki/System_on_module
11. From prototype...
SYSTEM ON
MODULE (SOM) WITH
OS AND APPS
SYSTEM ON
MODULE (SOM) WITH
OS AND APPS
BASEBOARD
FOR
PROTOTYPING
BASEBOARD
FOR
PROTOTYPING
12. … to production
SYSTEM ON
MODULE (SOM) WITH
OS AND APPS
SYSTEM ON
MODULE (SOM) WITH
OS AND APPS
STACK OF
DEDICATED
BOARDS
STACK OF
DEDICATED
BOARDS
13. Setup the development environment
●
Android Studio 3.0
– Android 7.0 support for Developer Preview 4
– Android 8.0 support for Developer Preview 5
upwards
●
Google Account
– Access to Android Things Console
●
Hardware
– SOM
– Development Kit
– Sensor, actuators, interfaces
14. Boards
Intel Edison Intel Joule NXP Pico i.MX6UL Raspberry Pi3
PRICE $55 > $200 $70 $22
SDK
PRICE
$150 > $300 - $22
CPU Atom DC @500Mhz Atom QC @1.5GHz
NXP i.MX6Ultralite ARM
Cortex A7 @500MHz
Broadcom BCM2837
QC @1.2GHz Cortex
A53
RAM 1GB 3-4GB 512MB 1GB
STORA
GE
4GB 8-16GB 4GB microSD
DISPLA
Y
NO HDMI NO HDMI
CAMER
A
NO CSI-2 NO CSI-2
AUDIO USB 2.0 USB 2.0 3.5mm Analog USB 2.0 & 3.5mm Analog
NET WiFi n, BT 4.0 WiFi ac, BT 4.2 Ethernet, WiFi n, BT 4.1 GB Ethernet, WiFi n, BT 4.1
USB USB 2.0 OTG
2x USB 2.0 HOST +
USB 3.0 OTG
USB 2.0 HOST +
USB 2.0 OTG
4x USB 2.0 HOST
GPIO
2x UART, 2x I2C,SPI 2ch,
14 GPIO
4x UART, 5x I2C, 2x SPI, up
to 48 GPIO
8x UART, 4x I2C, 4x SPI, >
20 GPIO
2x UART, 2x I2C, 2x SPI, up
to 26 GPIO
15. Select a board
●
Intel Edison
– Damn small!
– No UI, no Ethernet
– ADB via USB
– Obsolete (will not receive upgrades), but easily
sold on eBay at afordable price
●
Raspberry Pi3
– Damn cheap!
– Ethernet + WiFi
– HDMI + Camera + lot of
– extension boards: AI+VR+IoT!
– Diferent confgs can be tested swapping the SD
16. Deployment and update
APP
by Developer
APP
by Developer
OS
by Google
OS
by Google
DEVELOPER
UPDATE
CONSOLE
DEVELOPER
UPDATE
CONSOLE
DeviceDevice
OTA
19. Android Things vs Android
●
No UI == some hacking
– ADB via USB is not available on any board: it
must be confgured over network
– Wireless Network must be confgured using
ADB. See previous item: loop!
– Bluetooth and other stuf must be managed
programatically
●
Power management must be implemented from
scratch
●
RTC could not be available: without time
synhcronization certifcate validation may fail
24. Warning
●
Moving from software to hardware playground
requires some skills and attention
●
Boards may accept 3.3v or 5v peripherals or both:
check voltage matching before connecting
devices otherwise you may damage the hardware
●
Flying cables, jumpers, breadboards and misc
tools may cause a short circuit in milliseconds
and fre your beloved workstation
●
Boards with eMMC may be “bricked” if bootloader
update fails. It is strongly recommended to move
early steps on a board with removable storage
(Raspberry Pi3)
25. General Purpose Input/Output (GPIO)
●
Digital I/O with two logical states (true/false)
mapped on two electrical states (high/low)
PeripheralManagerService pms = new PeripheralManagerService();
List<String> portList = pms.getGpioList();
mGpio = pms.openGpio(portList.get(0));
mGpio.setValue(true | false); // write
boolean state = mGpio.getValue(); // read
26. General Purpose Input/Output (GPIO)
GpioCallback mGpioCallback = new GpioCallback() {
@Override
public boolean onGpioEdge(Gpio gpio) {
mDevice.getValue(); // Read the active low pin state
return true; // Continue listening for more interrupts
}
@Override
public void onGpioError(Gpio gpio, int error) { }
};
// EDGE_BOTH |EDGE_NONE | EDGE_RISING | EDGE_FALLING
mGpio.setEdgeTriggerType(EDGE_BOTH);
mGpio.registerGpioCallback(mGpioCallback);
27. GPIO for analog input
●
Android Things API currently does not support
analog input (think about “analogRead()”
provided by Arduino)
●
An Analog To Digital Converter (ADC) must be
used to read voltage level
●
The 2-channel converter ADC0832 can be easily
used to solve this issue
Start communication
Analog input
Clock
Output
Channel
selection
29. Writing the ADC0832 driver [2]
// selecting channel 1
for (int i = 0; i < 3; i++) { // Input MUX address
if (i == 0 || i == 1 || ch == 1) { gpioD1.setValue(true); }
else { gpioD1.setValue(false); }
gpioCLK.setValue(true); //Clock signal
gpioCLK.setValue(false);
}
30. Writing the ADC0832 driver [2]
for (int i = 0; i < 8; i++) { // Read 8 bits from ADC
gpioCLK.setValue(true); //Clock signal
gpioCLK.setValue(false);
ad = ad << 1;
boolean value = gpioD0.getValue();
if (value) {
ad |= 0x01;
}
}
31. Writing a driver FAQ
●
Is this always so complicated?
– YES
●
Could it be simplifed?
– YES
●
How???
– Using a driver library :-)
●
Where?
– Android Things user-space drivers (by Google)
– Useful Packages and Modules (UPM) and MRAA
(by Intel)
32. Pulse Width Modulation (PWM)
●
Uses a square wave signal (with assigned
frequency and duty-cycle) to control devices such
as servo motors.
33. Pulse Width Modulation (PWM)
●
Values for this servo:
– 50HZ , 7.5% -> Neutral position(90°)
– 50HZ , 3.75% -> Min position (0°)
– 50HZ , 11.25% -> Max position (180°)
PeripheralManagerService pms = new PeripheralManagerService();
List<String> portList = pms.getPwmList(); //List of all PWM ports
Pwm mPwm = pms.openPwm(portList.get(0));
mPwm.setPwmFrequencyHz(50);
mPwm.setPwmDutyCycle(7.5);
mPwm.setEnabled(true); //start pulsing
37. Universal Asynchronous Receiver
Transmitter (UART)
●
Every time you see the TX-RX pair, there’s a UART
available!
●
The simplest serial port used for expansion boards
or even home appliances (often for logging)
●
Features: point to point, asynchronous (no clock),
full duplex
●
Peripheral specs: boudrate, parity bit, data size,
stop bit
●
Physical Interface: 3 basic wires TX, RX, GND + 2
optional wires: request to send (RTS) and clear to
send (CTS)
44. Serial Peripheral Interface (SPI)
●
Full duplex, synchronous, master-slave (HW)
●
Params: Frequency, BPW, MSB/LSB, CLOCK mode
●
Connection:
●
2 Bus lines
●
Master Out Slave In (MOSI)
●
Master In Slave Out (MISO)
●
Clock [CLK]
●
Slave selection pin [CS or SS]
●
Fastest serial connection available: best to
communicate with slave boards that have
full (and low level) control of all sensor and
actuators
50. 52
Conclusion
●
Android Things brings the power and richness of
Android Platform to the IoT World
●
Secure, portable, scalable, ready-for-the-cloud,
ready-for-independence :-)
●
Upcoming board with cellular network
connectivity and near-to-wearable devices will
open the doors to new classes of applications and
services
51. 53
Speaker
●
Co-founder GULCh (21 years ago…)
●
Manager @ Open Reply
●
Technical writer
●
Linux User since 1994
●
Android Developer since 2009
●
Billionaire (still to come)
●
Reference
– Twitter: @gerdavax
– http://www.gerdavax.it
– gerdavax presso la posta di Big G
52. 54
Copyright and disclaimer
●
This presentation has been written by Stefano
Sanna and Giovanni Di Gialluca. It has been
derived from “Android Things in action”,
presented at Droidcon 2017 in Turin.
●
This presentation is published under the Creative
Commons License “Attribution-NonCommercial-
ShareAlike 4.0 International”
●
All brands, trademarks and technologies
mentioned in this presentation are properties of
respective owners and they have been used just
for educational purpose.