drive into IoT – Evolution of Brillo Evolution of Brillo • Based on Android (duh!) Based on Android (duh!) • Targets SoM and has support for the RasPi 3 as well Targets SoM and has support for the RasPi 3 as well
• MicroControllers MicroControllers – Arduino, ESP 8266, ESP 32, Micro Bit, Calliope Arduino, ESP 8266, ESP 32, Micro Bit, Calliope – Runs only one program Runs only one program • General Purpose Boards General Purpose Boards – Include OS (usually Linux or Linux based) Include OS (usually Linux or Linux based) – Thus can run multiple programms concurrently Thus can run multiple programms concurrently • Most IoT systems use SoCs or SoMs Most IoT systems use SoCs or SoMs
• SoM vs. Development Boards SoM vs. Development Boards • Development Boards are Development Boards are – For development and prototyping For development and prototyping • SoMs are SoMs are – System on Module System on Module – Provide CPU, Memory, Interfaces, Timers, Voltage Regulators and Provide CPU, Memory, Interfaces, Timers, Voltage Regulators and Connectivity Connectivity – Need to be connected to the final production circuit board Need to be connected to the final production circuit board
model • Support lib for hardware related stuf Support lib for hardware related stuf • Supports plenty of services Supports plenty of services – Subset of Firebase Subset of Firebase – Subset Google Play Services Subset Google Play Services – Subset of Android Subset of Android
for – Notifications Notifications – typical ContentProviders like Calendar or Contacts typical ContentProviders like Calendar or Contacts • Screens are optional Screens are optional – And quite frankly not the most important feature for IoT And quite frankly not the most important feature for IoT – Instead use voice, game controllers, simple buttons and sensors Instead use voice, game controllers, simple buttons and sensors
Permissions are always granted, but must be declared Permissions are always granted, but must be declared • All code can throw IOExceptions All code can throw IOExceptions – my sample code blissfully ignores this :-) my sample code blissfully ignores this :-)
Special support lib – Peripheral I/O API Peripheral I/O API – User Driver API User Driver API • But first But first – AndroidManifest.xml AndroidManifest.xml – build.gradle build.gradle
connection • Very old protocol Very old protocol • RS-232, USB and the like are based on it RS-232, USB and the like are based on it • Only a few devices need it Only a few devices need it • BUT: Can be used to read state of devices (Raspi) BUT: Can be used to read state of devices (Raspi)
bus Connect up to 128 devices per I²C bus – Actually 117 since some addresses are reserved Actually 117 since some addresses are reserved • Address is set by vendor Address is set by vendor – Sometimes adjustments via add-on pins are possible Sometimes adjustments via add-on pins are possible • Single data line, thus half-duplex transmissions Single data line, thus half-duplex transmissions • Can be based on registers or based on raw transfers Can be based on registers or based on raw transfers
val manager = PeripheralManagerService() manager = PeripheralManagerService() i2cDevice i2cDevice = manager.openI2cDevice( = manager.openI2cDevice("i2c_name" "i2c_name", , 0x40 0x40) ) } } // Modify the contents of a single register // Modify the contents of a single register fun fun setRegisterFlag setRegisterFlag(device: I2cDevice (device: I2cDevice, , address: Int) { address: Int) { // Read one register from slave // Read one register from slave var var value = device.readRegByte(address) value = device.readRegByte(address) // Set bit 6 // Set bit 6 value = value value = value or or 0x40 0x40 // Write the updated value back to slave // Write the updated value back to slave device.writeRegByte(address device.writeRegByte(address, , value) value) } }
typically High performance protocol (up to 1GHz, though typically slower) slower) • Uses clock signal for transmission Uses clock signal for transmission • Limited number of devices because of Chip Select pins Limited number of devices because of Chip Select pins
fun fun sendCommand sendCommand(device: SpiDevice (device: SpiDevice, , buffer: ByteArray) { buffer: ByteArray) { // Shift data out to slave // Shift data out to slave device.write(buffer device.write(buffer, , buffer. buffer.size size) ) // Read the response // Read the response val val response = ByteArray( response = ByteArray(32 32) ) device.read(response device.read(response, , response. response.size size) ) } }
separation within teams • Useful if your device allows third party apps to run Useful if your device allows third party apps to run • Driver developer cares about nitty-gritty low-level details Driver developer cares about nitty-gritty low-level details • „ „Normal“ Android developer uses stuf as per usual Normal“ Android developer uses stuf as per usual
presses Touch events and button presses • Sensors Sensors – Accelerometer, light, proximity… Accelerometer, light, proximity… • GPS GPS – Maps NMEA strings of sensors to Location objects Maps NMEA strings of sensors to Location objects • Audio Audio – For playing as well as for recording audio For playing as well as for recording audio
know Android Loads of devs know Android • Also Java / JVM based Also Java / JVM based – Simplifies IoT dev for newcomers, even if unfamiliar with Android Simplifies IoT dev for newcomers, even if unfamiliar with Android – Java was IMHO one important aspect of Android‘s success Java was IMHO one important aspect of Android‘s success • Huge ecosystem around Android (libraries, Android Studio...) Huge ecosystem around Android (libraries, Android Studio...) • Firebase integration Firebase integration
Android security architecture Android security architecture – OTA updates by Google even for vendor abandonded devices OTA updates by Google even for vendor abandonded devices • Though the lifespan of this guarantee is not yet defined Though the lifespan of this guarantee is not yet defined
based – Small module containing CPU, memory, storage and networking Small module containing CPU, memory, storage and networking • Portability across supported SoM architectures Portability across supported SoM architectures – (still: keep your code independent of specifics!) (still: keep your code independent of specifics!)
humidity and other sensors…) Agriculture (precision farming, humidity and other sensors…) • Sensors and monitoring for wind and solar energy plants Sensors and monitoring for wind and solar energy plants • Financial industries (ATMs, payment and information terminals) Financial industries (ATMs, payment and information terminals) • Logistics / warehouse robotics Logistics / warehouse robotics • Public transport (information systems and NFC-based Public transport (information systems and NFC-based monitoring/ticketing) monitoring/ticketing) • Sensors in production on ships or vehicles of all sorts Sensors in production on ships or vehicles of all sorts – Unless real time requirements are a must [airplanes, trains, safety systems] Unless real time requirements are a must [airplanes, trains, safety systems] • IoT Edge devices (hubs or bridges) IoT Edge devices (hubs or bridges)
Android Things • Anything where energy efficiency is a must Anything where energy efficiency is a must • Very ressource sensitive projects Very ressource sensitive projects – CPU, memory and storage requirements of Android Things CPU, memory and storage requirements of Android Things • Real Time Requirements Real Time Requirements • Anything that must run on unsupported architectures Anything that must run on unsupported architectures
point is an Activity As usual: Starting point is an Activity • From here on it depends From here on it depends – With touchscreen With touchscreen • Nothing changed Nothing changed – Without Without • You only need onCreate() and onDestroy() You only need onCreate() and onDestroy()
Data“ Designing Connected Products, O‘Reilly, 2015 Designing Connected Products, O‘Reilly, 2015 • That‘s where the Internet part of IoT comes into play That‘s where the Internet part of IoT comes into play – IoT provides data IoT provides data – IoT reacts to data IoT reacts to data