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

IoT Devices: Raspberry Pi

IoT Devices: Raspberry Pi

stwn

May 20, 2021
Tweet

More Decks by stwn

Other Decks in How-to & DIY

Transcript

  1. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 1 Iwan

    Setiawan <stwn at unsoed.ac.id> IoT Devices: Raspberry Pi
  2. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 2 Iwan

    Setiawan <stwn at unsoed.ac.id> Internet of Things (IoT) • Everyday objects connected to the (inter)network – “Your coffee maker has an IP address” – “You could ping your refrigerator” – “Your bike could talk to your air conditioner” • Many applications – Smart Home – Smart City – Smart anything? +Exchanging data! Device S Device S Device S Device S Global TCP/IP
  3. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 3 Iwan

    Setiawan <stwn at unsoed.ac.id> Internet of Things (IoT) • Everyday objects connected to the (inter)network – “Your coffee maker has an IP address” – “You could ping your refrigerator” – “Your bike could talk to your air conditioner” • Many applications – Smart Home – Smart City – Smart anything? Device S Device S Device S Device S Gateway +Exchanging data! Global TCP/IP
  4. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 4 Iwan

    Setiawan <stwn at unsoed.ac.id> Internet of Things (IoT) • Everyday objects connected to the (inter)network – “Your coffee maker has an IP address” – “You could ping your refrigerator” – “Your bike could talk to your air conditioner” • Many applications – Smart Home – Smart City – Smart anything? Device S Device S Device S Device S Gateway Network +Exchanging data! Global TCP/IP
  5. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 5 Iwan

    Setiawan <stwn at unsoed.ac.id> Internet of Things (IoT) • Everyday objects connected to the (inter)network – “Your coffee maker has an IP address” – “You could ping your refrigerator” – “Your bike could talk to your air conditioner” • Many applications – Smart Home – Smart City – Smart anything? Physical Device S Device S Device S Device S Gateway Network Data Link Physical Data Link Physical Data Link Physical Data Link Data Link Physical Data Link Physical Network +Exchanging data! Global TCP/IP
  6. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 6 Iwan

    Setiawan <stwn at unsoed.ac.id> Internet of Things (IoT) • Everyday objects connected to the (inter)network – “Your coffee maker has an IP address” – “You could ping your refrigerator” – “Your bike could talk to your air conditioner” • Many applications – Smart Home – Smart City – Smart anything? Physical Device S Device S Device S Device S Gateway Internet Data Link Physical Data Link Physical Network Network Data Link Network Physical Data Link Network Physical Data Link Network Physical Data Link Network +Exchanging data! Global TCP/IP
  7. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 7 Iwan

    Setiawan <stwn at unsoed.ac.id> Internet of Things (IoT) • Everyday objects connected to the (inter)network – “Your coffee maker has an IP address” – “You could ping your refrigerator” – “Your bike could talk to your air conditioner” • Many applications – Smart Home – Smart City – Smart anything? Physical Device S Device S Device S Device S Gateway Internet Data Link Physical Data Link Physical Network Network Data Link Network Physical Data Link Network Physical Data Link Network Physical Data Link Network +Exchanging data! Global TCP/IP Cloud Infra Cloud Infra
  8. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 8 Iwan

    Setiawan <stwn at unsoed.ac.id> Objectives • Get to know Raspberry Pi • Learning how to set up Raspberry Pi • Learning how to use Raspberry Pi OS – Graphical user interface (GUI) – Text user interface (TUI)
  9. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 9 Iwan

    Setiawan <stwn at unsoed.ac.id> Agenda • Raspberry Pi: Hardware and software • Installing and configuring Raspberry Pi OS • Using Raspberry Pi OS via GUI and TUI – Accessing the Raspberry Pi remotely – Command line interface (CLI)
  10. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 10 Iwan

    Setiawan <stwn at unsoed.ac.id> Raspberry Pi: Hardware • A single-board computer or “mini computer” • Low-cost computer, designed to be tinkered • Small size with “unlimited uses” – Phy. computing: coding+interacting with real world – Add-ons in the forms of expansion board or HATs +low-power * https://projects.raspberrypi.org/en/ e.g. Sense HAT Hardware Attached on Top
  11. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 11 Iwan

    Setiawan <stwn at unsoed.ac.id> Raspberry Pi: Hardware Raspberry Pi Foundation, OGL v3.0 Sense HAT* * https://raspberrypi.org/products/sense-hat/ astro-pi.org
  12. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 12 Iwan

    Setiawan <stwn at unsoed.ac.id> A: USB-C Power B: Display C: Connectivity D: HDMI-0 E: HDMI-1 F : System-on-chip G: GPIO H: RAM I : Camera J : Audio K: PoE L : USB 2.0 M: USB 3.0 N: Ethernet Monitor Electronic components Touchscreen CPU+GPU WiFi+Bluetooth Gareth Halfacree, CC By-NC-SA 4.0
  13. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 13 Iwan

    Setiawan <stwn at unsoed.ac.id> A: USB-C Power B: Display C: Connectivity D: HDMI-0 E: HDMI-1 F : System-on-chip G: GPIO H: RAM I : Camera J : Audio K: PoE L : USB 2.0 M: USB 3.0 N: Ethernet Monitor Electronic components Touchscreen CPU+GPU WiFi+Bluetooth MicroSD card Gareth Halfacree, CC By-NC-SA 4.0
  14. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 14 Iwan

    Setiawan <stwn at unsoed.ac.id> Raspberry Pi: Software • Raspberry Pi OS, an official supported OS – Lite, base system and tools – Desktop, includes desktop env. and basic applications – Desktop and recommended software, or “full” release • Set of applications preinstalled, depends on the release • Development environment – Python 3 – Mu editor formerly, Raspbian
  15. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 15 Iwan

    Setiawan <stwn at unsoed.ac.id> Software Download • Raspberry Pi OS “full” • Raspberry Pi Imager • SSH/PuTTY and VNC Viewer * Raspberry Pi OS and Imager: https://raspberrypi.org/software/ * PuTTY: https://putty.org/ * VNC Viewer: https://realvnc.com/en/connect/download/viewer/ * Local mirror site: http://dl.kuliax.net/acnt/iot/
  16. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 16 Iwan

    Setiawan <stwn at unsoed.ac.id> Preparing MicroSD • Plug MicroSD card into the reader • Plug the reader into your computer
  17. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 17 Iwan

    Setiawan <stwn at unsoed.ac.id> Installing Raspberry Pi OS • Run Raspberry Pi Imager • Choose OS-Use custom, select the image • Choose Storage, and click WRITE – Select the correct drive, be careful – While the Imager writes, prepare the Raspberry Pi – Takes ~12 minutes with USB3 connection
  18. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 18 Iwan

    Setiawan <stwn at unsoed.ac.id> Enabling “Headless Mode” • Reason: There is no monitor available • Steps needed to run on your computer – Open boot partition on the MicroSD card – Create a file named “ssh” – Configure static IP address by editing dhcpcd.conf in rootfs partition inside “etc” directory. Add these lines in the file interface eth0 static ip_address=192.168.X.1/24
  19. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 19 Iwan

    Setiawan <stwn at unsoed.ac.id> Preparing Raspberry Pi • Unplug MicroSD card from the reader • Plug MicroSD card into the Raspberry Pi • Plug in all the needed things – If you have a monitor, MicroHDMI-to-VGA converter to Raspberry Pi, also the VGA cable to the other end, and wireless keyboard+mouse dongle – USB type-C power supply
  20. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 20 Iwan

    Setiawan <stwn at unsoed.ac.id> Booting up the Raspberry Pi • When the power supply is plugged in, the Raspberry Pi will turn on and boot • If the booting succeeds – Headless: Raspberry Pi will wait for SSH access – With monitor: a desktop will be shown including a welcoming dialog
  21. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 21 Iwan

    Setiawan <stwn at unsoed.ac.id> Connecting to the Raspberry Pi • Configure Ethernet interface on your computer by adding an IP address with the same network as your Raspberry Pi – IP address: 192.168.X.2/24 – Depends on OS on your computer – Check if the Raspberry Pi’s IP address is reachable via ping command: ping 192.168.X.1, or ping raspberry.local • Connect to the Raspberry Pi using SSH, or PuTTY – Linux or MAC: ssh [email protected] – Windows 10: run PowerShell application first
  22. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 22 Iwan

    Setiawan <stwn at unsoed.ac.id> Configuring VNC Server • Edit rc.local file $ sudo nano /etc/rc.local sudo -u pi vncserver -randr=[resolution] • Save the file • Reboot your Raspberry Pi
  23. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 23 Iwan

    Setiawan <stwn at unsoed.ac.id> Remote Access Using VNC • Run VNC Viewer and use the IP address of the Raspberry Pi to connect into • If succeeded, the desktop will be shown
  24. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 24 Iwan

    Setiawan <stwn at unsoed.ac.id> First Configuration (1) • Locale – Country, Language, and Timezone – Check “Use English language” and “Use US keyboard” • Change Password – Default username and password: pi/raspberry – Change the password to “@cnt-X”, e.g. “@cnt-10” for ACNT-10 group • If you have a monitor and there is a black border when the desktop is shown up, please tick the checkbox in “Set Up Screen” dialog • Select WiFi Network and enter the password. Turn off Bluetooth
  25. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 25 Iwan

    Setiawan <stwn at unsoed.ac.id> First Configuration (2) • Update software, if necessary – Updating software packages on Raspberry Pi OS – Debian-based systems use Advanced Packaging Tool (APT) for package management • Check if the time is correct, related to Network Time Protocol (NTP) • Reboot
  26. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 26 Iwan

    Setiawan <stwn at unsoed.ac.id> Exploring Raspberry Pi OS • Desktop, taskbar, system tray • Default and pre-installed applications – File manager – Unix-like file system – Taking screenshot • CLI or shell – Consistent – Faster – Powerful, lots of options
  27. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 27 Iwan

    Setiawan <stwn at unsoed.ac.id> Practicing CLI • Open the terminal, Ctrl+Alt+T • Try to run applications via CLI • Common commands – df, ls, cd, cp, mv, rm, mkdir, pwd, man [cmd], clear (Ctrl+S), cal, date, pinout – ifconfig, ip addr, route -n, hostname -I Case-sensitive * https://raspberrypi.org/documentation/linux/usage/commands.md
  28. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 28 Iwan

    Setiawan <stwn at unsoed.ac.id> Command Line-Fu • Command history: up and down arrows • Command search: Ctrl+R, type the command • Tab completion: Tab and Tab-Tab • File editing: Vim, nano, etc. • System monitoring: top, ps
  29. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 29 Iwan

    Setiawan <stwn at unsoed.ac.id> Raspberry Pi Configuration • Disable autologin • Change hostname to “acnt-X” e.g. “acnt-10” • Security issues – Desktop, e.g. lock with “dm-tool lock” – Remove unused packages, install system updates – Network security
  30. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 30 Iwan

    Setiawan <stwn at unsoed.ac.id> IoT Assignment 1 1. Find the Raspberry Pi 4 Model B specifications – System-on-chip – Instruction set – CPU and GPU 2. Visit these websites and report your findings – pinout.xyz – resistorcolorcodecalc.com – gpiozero.readthedocs.io
  31. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 31 Iwan

    Setiawan <stwn at unsoed.ac.id> IoT Assignment 1 3. Observing a pair of traffic lights, physically or virtually – Time needed: 5~10 minutes – Take a picture – Draw the pair of traffic lights either by hand or using computer – Put some notes, e.g. time between red to green, and vice versa +situation Upload your experiment results and assignment 1 to Moodle • Using one PDF file • One group, one document • If you have a demo video (3~5 mins), please attach the URL in the document 05/25 9pm Screenshots, figures, descriptions, notes, video, etc.
  32. Advanced Computer Networks Tutorials, Spring 2021, CSIE NTUST 32 Iwan

    Setiawan <stwn at unsoed.ac.id> Resources • Raspberry Pi Foundation, “Getting started with your Raspberry Pi,” 2021. [Online]. Available: https://futurelearn.com/courses/getting-started- with-your-raspberry-pi