Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building interactive wall décor from junk phones

Building interactive wall décor from junk phones

Why throw away your old phones when you can create a digital work of art? With just some basic arts and crafts skills, you can build a collage of phones with wires intertwining and running across your wall like a circuit board. It can display photo galleries, shopping lists, music visualizations, and make a wicked Zoom background.

In this talk, you'll learn how Node.js and a Raspberry Pi can manage multiple Android devices over USB. We'll explore how to build visualizations using browser APIs, and how to integrate with the wider Internet of Things. Let's give your old mobile phones a new life.

Tiger Oakes

May 28, 2022
Tweet

More Decks by Tiger Oakes

Other Decks in Programming

Transcript

  1. Hi! I’m Tiger. Software Engineer working on Microsoft Loop. •

    Worked on Edge, Chrome, and Firefox. • From Hawai’i, now based in Seattle. • Likes computers 2
  2. 5

  3. 7

  4. 9

  5. 10

  6. 12 Cells ADB WebSockets Remote HTTP POST Server On /

    Off Smart home Home Assistant Architecture
  7. Shopping list Base wood panel 1. Plywood panel 2. Sandpaper

    3. White acrylic paint 4. Paint brush 5. Wood screws or command strips for mounting to wall
  8. Shopping list Base wood panel 1. Plywood panel 2. Sandpaper

    3. White acrylic paint 4. Paint brush 5. Wood screws or command strips for mounting to wall
  9. Shopping list Mounts, connectors 6. Old cell phones and tablets

    running Android 7. Raspberry Pi or another computer for the server 8. USB cables 9. USB hub 10.Velcro strips 11.Wire clips
  10. Shopping list Mounts, connectors 6. Old cell phones and tablets

    running Android 7. Raspberry Pi or another computer for the server 8. USB cables 9. USB hub 10.Velcro strips 11.Wire clips
  11. Shopping list Mounts, connectors 6. Old cell phones and tablets

    running Android 7. Raspberry Pi or another computer for the server 8. USB cables 9. USB hub 10.Velcro strips 11.Wire clips
  12. Shopping list = €74.70 Base wood panel 1. Plywood panel

    2. Sandpaper 3. White acrylic paint 4. Paint brush 5. Wood screws or command strips for mounting to wall Mounts, connectors €26.60 6. Old cell phones and tablets running Android 7. Raspberry Pi or another computer for the server 8. Velcro strips 9. USB cables 10.Wire clips 11.USB hub €48.10
  13. 20 Cells ADB WebSockets Remote HTTP POST On / Off

    Smart home Home Assistant Architecture Server
  14. 02 Talk to your phone over USB. Using Android command

    line tools to control your USB cables 21
  15. # List connected devices > adb devices List of devices

    attached 1e778e25 device emulator-5554 device 24
  16. # Open a Unix shell on the Android device >

    adb –s <serial> shell 25
  17. # Command to install an app > adb –s ABC12345

    install ./app_name.apk # Command to simulate pressing power button > adb –s ABC12345 shell input keyevent 26 # Command to open website on phone > adb –s ABC12345 shell am start –a android.intent.action.VIEW –d https://example.com 26
  18. > adb devices * daemon not running; starting now at

    tcp:5037 * daemon started successfully List of devices attached ID1234 device device IDabcd device This phone has no ID! Making up a serial code and updating the phone 28
  19. # List connected devices with long output > adb devices

    -l List of devices attached ID1234 device usb:11 transport_id:1 device usb:22 transport_id:2 IDabcd device usb:33 transport_id:3 # Use USB port ID > adb –s usb:11 shell input keyevent 26 # Use transport ID > adb –t 3 shell input keyevent 26 29
  20. This phone has no Wi-Fi! Using the USB cable like

    an Ethernet cable with reverse port forwarding 31
  21. # Send TCP requests over a port to the server

    via USB, not WiFi > adb –s ABC12345 reverse tcp:<device-port> tcp:<system-port> # Reverse forward TCP request on port 3000 to server port 3000 > adb –s ABC12345 reverse tcp:3000 tcp:3000 32
  22. 35 Cells ADB WebSockets Remote HTTP POST On / Off

    Smart home Home Assistant Architecture Server
  23. 37

  24. https://npm.im/appium-adb import { ADB } from 'appium-adb'; const adb =

    await ADB.createADB(); const devices = await adb.getConnectedDevices(); 39
  25. https://npm.im/appium-adb Command line # List connected devices > adb devices

    List of devices attached 2315332 device 1ee21d device E2dbeeDR device JavaScript import { ADB } from 'appium-adb'; const adb = await ADB.createADB(); const devices = await adb.getConnectedDevices(); console.log(devices); // [{ udid: '2315332' }, // { udid: '1ee21d' }, // { udid: 'E2dbeeDR' }] 40
  26. Control devices with Node async function helloWorld() { const devices

    = await getConnectedDevices(); await Promise.all(devices.map(async (device) => { const KEYCODE_POWER = 26; await device.keyevent(KEYCODE_POWER); await device.startUri('https://example.com'); }); }); 41
  27. Server Communication protocol speed 44 Client ADB Establish connection and

    turn on phones WebSockets Send display data quickly
  28. Represent state with websites If you are presenting a website,

    an internet product or an app, you can place a screenshot of it here. 45 https://example.com
  29. Latest Software for 1st Gen Kindle Fire Released 2013. Android

    4.4 Firefox Nightly 102 Released yesterday. 46
  30. 50

  31. 51

  32. 52

  33. Distribute lines of text async function showText(text) { const lines

    = text.split('\n'); // Roughly sort based on ascending x and y position const scorePosition = (pos) => (pos.x * 100) + (pos.y * 500); const devices = (await getConnectedDevices()) .sort((a, b) => scorePosition(a) – scorePosition(b)); for (let i = 0; i < Math.min(lines.length, devices.length); i++) { await devices[i].sendUrl(`/page/text?text=${lines[i]}`); } } 53
  34. 54 Cells ADB WebSockets Remote HTTP POST On / Off

    Smart home Home Assistant Architecture Server
  35. import express from 'express'; const app = express(); app.post('/api/power', async

    function (req, res) { const devices = await getConnectedDevices(); await Promise.all(devices.map(async (device) => { const KEYCODE_POWER = 26; await device.keyevent(KEYCODE_POWER); }); res.send('Toggled power'); }); 56
  36. Other services 59 Cell ADB WebSockets Services HTTP POST Server

    & Webhooks Webhook call fired by service
  37. 64 Cells ADB WebSockets Remote HTTP POST Server On /

    Off Smart home Home Assistant Architecture