Raspberry Pi

From Sketching with Hardware at LMU Wiki
Jump to navigation Jump to search

There are different version of the Raspberry Pi https://www.raspberrypi.org/, e.g.

Pi Tutorial Videos[edit]

List of Raspberry Pi Videos

Videos: Getting started[edit]


The Raspberry Pi is a Linux computer that has a multitude of connectors and in particular, it provides GPIO pins. The connector (HAT) provides an easy way to add your own sensors and actuators and there are many boars that can be connected.

Audio input and output are not very good, hence we recommend using a USB Sound Adapter (the 5€ versions work very well).

For programming, we will use python.

For controlling the Pins on the Raspberry Pi, you may want to look at the following library

Web server on the Raspberry Pi

Getting started Tasks[edit]

  • Connect the Pi to your local network and access it from another device via SSH.


  • If updating the Pi fails during its setup wizard (first start of the Pi), you might have to extend your file partition. The wizard interrupts with a "not enough space" error. You can find this option via "sudo raspi-config", select advanced options and expand the filesystem. After a reboot, you should have access to the whole SD card (you can check disk space with "df -h"). Make sure to finish the update with "sudo apt-get update && sudo apt-get upgrade".


Pinout of Pi Zero[edit]

physical connections
JL: https://peppe8o.com/raspberry-pi-zero-pinout/
CR: https://de.pinout.xyz/pinout/io_pi_zero
HW: https://www.argon40.com/learn/index.php/2020/03/06/a-comprehensive-guide-on-raspberry-pi-3-and-raspberry-pi-zero-and-zero-w-gpio-pinout/
JW: https://www.raspberrypi.org/documentation/usage/gpio/

SF: With the gpiozero library you will by default want to reference the pin number as in GPIOx where x is the pin you define in software. Example: LED(5) in software; connect to GPIO5 on the Pi Zero header. (see also: https://gpiozero.readthedocs.io/en/stable/recipes.html#pin-numbering)

Setting up the OS and Python[edit]

NOOBS configure
JL: https://www.tutorialspoint.com/python/python_environment.htm
CR: https://learn.adafruit.com/setting-up-a-raspberry-pi-with-noobs/download-noobs
HW: https://www.raspberrypi.org/help/noobs-setup./
JW: https://www.raspberrypi.org/documentation/installation/noobs.md
SG: https://medium.com/@nikosmouroutis/how-to-use-atom-with-your-raspberry-pi-through-sftp-382c43176a9e

SF: The simple three-step wizard we talked about: https://www.raspberrypi.org/software/

Access to GPIO[edit]

JL: http://codefoster.com/pi-basicgpio/
CR: https://fedoramagazine.org/raspberry-pi-zero-gpio-fedora/
HW: https://webnist.de/raspberry-pi-zero-gpio-pins-ueber-den-desktop-steuern/
SG: https://github.com/fivdi/onoff

SF: With the gpiozero library you will by default want to reference the pin number as in GPIOx where x is the pin you define in software. Example: LED(5) in software; connect to GPIO5 on the Pi Zero header. (see also: https://gpiozero.readthedocs.io/en/stable/recipes.html#pin-numbering)

Blinking an LED[edit]

JL: https://raspberrypihq.com/making-a-led-blink-using-the-raspberry-pi-and-python/
CR: https://fedoramagazine.org/raspberry-pi-zero-gpio-fedora/
HW: https://webnist.de/raspberry-pi-zero-gpio-pins-ueber-den-desktop-steuern/
JW: http://www.heidislab.com/tutorials/getting-started-with-raspberry-pi-led-blinking-on-raspberry-pi-zero

Reading a Pin[edit]

JL: http://raspberry.io/projects/view/reading-and-writing-from-gpio-ports-from-python/
CR: https://learn.sparkfun.com/tutorials/raspberry-gpio/all
HW: https://mjrobot.org/rpi-gpiozero/
SG: https://tutorials-raspberrypi.de/raspberry-pi-gpio-erklaerung-beginner-programmierung-lernen/

SF: What state does your input pin have by default? With gpiozero, you can configure the pin to be pulled up (pull_up=True) or pulled low (pull_up=False). If you pull up, you can only change the state by connecting the pin physically to GND. If pulled low, you can only change the input state by connecting it to 3.3V. (see also: https://gpiozero.readthedocs.io/en/stable/api_input.html). By default, the pin is pulled up. If you always define the state explicitly in your code, you might make it easier for yourself to debug the code. Example: Button(15, pull_up=True)

Runing a Webserver that access GPIO[edit]

JL: https://towardsdatascience.com/python-webserver-with-flask-and-raspberry-pi-398423cc6f5d
CR: https://www.e-tinkers.com/2018/04/how-to-control-raspberry-pi-gpio-via-http-web-server/
HW: https://hackaday.io/project/173322-controlling-gpio-outputs-using-a-web-interface-wit
JW: https://www.youtube.com/watch?v=c6FOpPXbLjs
SG: https://randomnerdtutorials.com/raspberry-pi-web-server-using-flask-to-control-gpios/

Restful API[edit]

JL: https://sites.google.com/site/cartwrightraspberrypiprojects/home/other-projects/rest-api
CR: https://docs.dataplicity.com/docs/control-gpios-using-rest-api
HW: https://www.youtube.com/watch?v=JZfevVG-VuA&list=PLLIDdNg0t5ceg3mI3vn0YJocJ4ndMtM98&index=4&t=0s
SG: https://tutorials-raspberrypi.de/raspberry-pi-nodejs-webserver-installieren-gpios-steuern/

Description of the components[edit]

JL: https://www.adafruit.com/product/3411
CR: https://computer.howstuffworks.com/raspberry-pi2.htm
HW: https://learn.adafruit.com/introducing-the-raspberry-pi-zero
JW: https://www.youtube.com/watch?v=WJdQ4rknBX0

Project Ideas[edit]







A small portable gadget. Which can record sensor data and give feedback to a user. Mind satisfaction for your offices days.
It’s hard to do small exercises, often we find excuses to not do it. Concentrated breathing can help your brain to relax, or focusing on small things can reduce stress. Using those informations to create short (~ 5min) exercises.


Home Office Buddy:
A speaker communicating in a pleasant way with the target person in order to minimize a possible social isolation and encourage the keeping of important routines & daily structures in order to maintain a certain productivity during a working day.
Example: suggest unplanned short breaks if the target person is showing a lack of concentration measured by a certain level of body movement.


Problem: too much sitting while working in the office
Idea: adjustable desk
Sensors: on the chair, to check, if the user is sitting and how long
Notification: User gets a message after a certain time, that the desk will rise for min. 30 minutes. After that time the desk can be lowerd again, if wished. The Sensor will messures again.
Gamification: a little "stand-up-figure" will be on the desk and will stand up, if the desk is rised. Will be collapse, if the desk is lowered.


Problem: Tension due to prolonged sitting and incorrect sitting positions (e.g. crooked shoulders)
Sensors: Kinect for analysis of posture, sensors that measure the tension in the neck
The longer one maintains a bad sitting position, the older/bent an avatar becomes on the screen. Through movement the avatar becomes younger/upright again.


WALL-E: your digital stress cleaner

  • The buggy has two “hands” and one trash can
  • Users’ stress detection: EDA/HRV
  • If stressful: The buggy will
    • search for the smartphone (RFID or GPS)
    • steal the smartphone
    • drop it into the trash can
  • If user calms down: be allowed to use smartphone


Problem: ① Uncomfortable working environment in aspects of lighting and air quality; ② Avoidable disturbance by colleges, etc.; ③ Remaining stationary for too long

Solution: ① Automatic adjustable light, automatic jalousie roller, automatic humidifier, LED as indicator next to windows; ② Display as door sign; ③ Speaker with a switch as indicator

Sensor: Temperature and humidity sensor Bme280, light sensor Tsl2561, CO2 sensor, motion sensor


Problem: Pain in the hand and wrist due to consistent movement or incorrect hand/arm position
Sensors: e.g. Leap Motion for motion and posture detection, keyboard/mouse to track activity (?)
Vibration of the mouse/keyboard if the same position was kept for too long or no pause was made. A visualization of an inflammation (red pulsating circles) is displayed, which gets worse/better depending on user behavior. This warns the user when his hand position is worsening. The user may choose to be prevented from continuing to work or not.