際際滷

際際滷Share a Scribd company logo
Coffee & Pi
Getting Started with Python
Questions
 Has anyone never seen or used a Raspberry Pi?
 Does anyone work professionally develop for Pi
or embedded systems/IoT?
 Windows or OS X?
 Who is from Philadelphia?
 Who is from the suburbs/outside the city/NJ?
Meetup Rules
 This is a beginner friendly meetup, focus on Pi, but
open to including other platforms and hardware
 There are no stupid questions.
 Open discussion is encouraged, keep it friendly!
 If you have equipment you would like to talk about or
test together, see me after the presentation!
 Problems become opportunities when the right people
join together! Be the bridge!
Coffee & Pi - Getting Started with Python
About Brad
 17+ years in IT, tech support, Linux administration
 Currently Senior DevOps Engineer for Health Union
 Mostly self-taught, with help from mentors and
Philly tech communities. Love just building stuff!
 Not great at coding, really enjoy servers and apps!
 Coffee & Pi is meant to help people at all ages and
skill levels to learn more about technology
What I did on my summer
vacation
 May - Participated in the 2nd Philly Art Museum Hackathon
 Was a finalist again, 2nd year in a row, didnt win :(
 June - Started a new job at Health Union :)
 June-August - Tried to build an iPhone travel app
 Failed :( (Did learn a lot about React Native and Swift!)
 August - Registered Coffee & Pi with the Raspberry Pi Foundation
 They have STICKERS!!! And I have news :)
 Got some great ideas and materials for future meetups!
 Built a Raspberry Pi photo booth and it works! :)
Upcoming jams in the US
Upcoming Coffee & Pi
 October 16 - Everything RetroPie!
 Install and configure RetroPie
 Explore and maybe demo some alternatives
 November - Looking for topic ideas, open to suggestions
 Will be more consistent with monthly meetups!
 March 2018 - Raspberry Pi Big Birthday Weekend
 Coffee & Pi is joining several Philly meetup groups and partners
for one big event!
 Introducing Philly & Pi
Philly & Pi
 Organizing to bring Philly meetups and groups together for demos and
talks to inspire people of all levels and ages to learn with Raspberry Pi
 Already confirmed meetup groups and partners
 Coffee & Pi Meetup
 Philly GraphDB MeetUp
 Philly IoT MeetUp
 DataPhilly Meetup
 Raspberry Pi
 Neo4j
Help Wanted!
 Philly & PI - More details to come! Will be looking
for other groups and partners to join!
 Raspberry Pi is in talks about streaming feeds
during the weekend too! Anyone have any
equipment or connections that can help?
 Will need volunteers if anyone is interested, will
put you first in line for swag and includes a free
Philly & Pi t-shirt! Let Brad know if you are!
Lets get to the builds!
Download Raspbian
with Desktop
 https://www.raspberrypi.org/downloads/raspbian/
 Raspbian with Desktop 1.63 GB, Lite is 364 MB
Installing Raspbian
using OS X
Etcher on mac to flash microSD card
 Download and Install Etcher - https://etcher.io
 Download OS image, Insert SD memory card, Flash!
Etcher on mac to flash microSD card
 Wait for the files to copy
Etcher on mac to flash microSD card
 Wait for the Validating of the image
Etcher on mac to flash microSD card
 When its finished, you can safely remove
memory card, and insert into Raspberry Pi and
boot!
Installing Raspbian
using Windows
Etcher on Windows 7+ to microSD card
 Download and Install Etcher - https://etcher.io
 Download OS image, Insert SD memory card, Flash!
Etcher on Windows 7+ to microSD card
 Wait for the files to copy
Etcher on Windows 7+ to microSD card
 Wait for the Validating of the image
Etcher on Windows 7+ to microSD card
 I actually saw the Unmounting step
Etcher on Windows 7+ to microSD card
 When its finished, you can safely remove
memory card, and insert into Raspberry Pi and
boot!
Using Raspbian
Desktop
Enable Wifi
 Click the disconnected Wifi
logo in toolbar (red arrows)
 Select the target network
 Enter network password/key
 Verify icon goes to blue wifi
Run Updates
 Open Terminal
 Run the following commands:
 sudo apt-get update
 sudo apt-get upgrade
Find the IP address
 Open Terminal
 Run the following command:
 ifconfig
 Check output for wlan0 for wifi
 Run exit to close terminal
Open Raspberry Pi Conf
 Click the drop down menu
 Click on Preferences
 Click on Raspberry Pi
Configuration
Enable VNC Server
 Click on Interfaces tab in
Raspberry Pi Configuration
 Click Enabled next to VNC
option
 Click on OK to save and
enable VNC server
Configure VNC Server
 After enabling, will have VNC
icon in the toolbar
 Clicking on the icon opens the
VNC Server config settings
 Also displays the wifi IP
address
 Authentication default is local
user pi with password
raspberry
Install VNC Connect
 Visit RealVNC website
to download VNC
Connect client
 https://www.realvnc.co
m/en/connect/downloa
d/vnc/
 Clients for Windows,
Mac, Linux, Raspberry
Pi, Solaris, HP-UX, AIX
Connect with VNC
You are now ready to code!
PiStop Worksheet
Install the PiStop on the GPIO before
powering on the Raspberry Pi
Open Thonny
 Worksheet says to use Python 3 IDE, but use
Thonny instead! Its now the default app for .py
 Click Menu - Programming - Thonny Python IDE
Using Thonny
Open PiStop Worksheet
Script in Thonny
 Code is online at
https://github.com/CoffeeAndPi/PiStopWorksheet
 Make changes, press Run Current Script button
(looks like a play button)
 To stop, click Interrupt/Reset button
(looks like a stop button)
Thats PiStop!
 Can use worksheet to get started.
 Expand on the ideas of challenging people by
different sequences and creating code to meet
those challenges.
 I didnt feel this was a enough for a meetup,
wanted to do something actually useful and
interesting
TouchSelfie Photo
Booth
TouchSelfie Photo
Booth DEMO!
Based on TouchSelfie Photo
Booth
https://makezine.com/projects/raspberry-pi-photo-booth/
The Coffee & Pi Way
 Need to install updates and python dependencies
 Using the latest Raspbian (Stretch) Sept 7, 2017
 May be different than original blog, but tested!
 Enable and add the camera and touch screen
 Setup Google Photos API integration
 Git clone repo, update settings, and run!
Required Components
 Raspberry Pi 3 + Raspbian Desktop OS
 Raspberry Pi Camera V2
 Raspberry Pi 7 Touchscreen Display
 USB battery pack (cordless) or USB cord
 Case or 3D printed camera mount
 Google Account with Photos API enabled
Install Touch Screen
 Raspberry Pi 3 mounts onto the back of the
touch screen with 4 screws
 Run red and black cables from Pi to touch screen
(other 3 are for Microsoft IoT and adv dev)
7 Pi Touch Screen
Add ribbon cable
silver side up
Add Raspberry Pi 3
screw into 4 posts on touch screen
Loop the ribbon cable to the Pi 3
Add red and black jumper cables
from Pi to touch screen
Install the Pi Camera v2
Make sure the blue side faces the network port!
Enable the camera via
Raspberry Pi Configuration
Enabling the camera
will trigger a reboot
By default, the touch screen display
is upside-down!
Rotate touch screen
180 degrees
 Open terminal
 sudo vi /boot/config.txt (or use fav text editor)
 Add lcd_rotate=2 to the bottom of the file
 Save and reboot!
Test the Camera
 Open Terminal
 cd Desktop
 raspistill -o cam.jpg
 Should take picture and save to Desktop as cam.jpg
 More raspistill options
https://www.raspberrypi.org/documentation/usage/ca
mera/raspicam/raspistill.md
Setup Pi and Dependencies
 Open Terminal
 Install Updates
sudo apt-get update && sudo apt-get upgrade
 Install Python Dependencies
sudo apt-get install python-imaging python-gdata
python-pil.imagetk
 Install Google API for Python
sudo pip install --upgrade google-api-python-client
Clone the repo to Pi
 In Terminal
 mkdir git
 cd git
 git clone
https://github.com/CoffeeAndPi/TouchSelfie
Create Google Photos Album
 https://photos.google.com/albums
 Create an upload album, save one photo into it
Enable 2-Step
Verification
 https://myaccount.google.com/security
 Follow wizard to enable 2-step verification
Turn on 2-Step
Verification
 Requires verifying with a cell or phone number
Create an App Password
 Will only display if 2-Step verification is enabled!
Generate App Password
 Choose a name for the app and Google will
generate an app password in a yellow box.
Save this!
Create API Keys
 https://console.developers.google.com/apis/librar
y
 Click on Select a Project -> Click on + to create
project
Create New Project
 Fill in Project name, can be anything
 Click Create when ready
Create Credentials
 Select the project you just created
 Click on Credentials on the left menu
Create Credentials
 Click on OAuth consent screen tab
 Enter a product name show to users
Create Credentials
 Click on Credentials again
 Click on Create credentials - OAuth client ID
Create Credentials
 Select Other for Application Type
 Set Name as Installed, then click Create
Create Credentials
 Click on OK to dismiss the client IDs
 Click on the Installed OAuth Client ID
Download Credentials JSON
 Click on Download JSON and save to
Raspberry Pi
Rename and Move JSON
 Rename the JSON file to OpenSelfie.json
 Move to /home/pi/git/TouchSelfie/scripts
Run the App
 Add Desktop/PhotoBooth.sh to the desktop
 Make it executable!
 Double click to start the app!
 Its a Raspberry Pi photo booth!!!
Coffee & Pi - Getting Started with Python
Thank you!
 Anything is possible! Keep experimenting!!!
 Connect with other local and online communities
for more help and support!
 You have my permission to fail! Keep trying!
 Please leave ratings and feedback on
meetup.com, it helps others to find and know
how Coffee & Pi goes!
Philly Tech
Communities
 Philly Python Users Group (PhillyPUG)
 https://www.meetup.com/preview/phillypug
 Philly IoT Meetup
 https://www.meetup.com/preview/Philadelphia-
Internet-of-Things-Meetup
 Hardware - NextFab, The Hacktory
 Youth - TechGirlz, Hopeworks, Coded by: Kids
Raspberry Pi Resources
 Use the #CoffeeAndPi to show off your projects!
 We are on PhillyDev.org Slack #RaspberryPi
 You can use the Coffee and Pi meetup tools,
email group, online discussion board
 Let me know if theres anything I can do to help!
Thank you!
Questions?
If you have equipment to test, come see me!

More Related Content

Coffee & Pi - Getting Started with Python

  • 1. Coffee & Pi Getting Started with Python
  • 2. Questions Has anyone never seen or used a Raspberry Pi? Does anyone work professionally develop for Pi or embedded systems/IoT? Windows or OS X? Who is from Philadelphia? Who is from the suburbs/outside the city/NJ?
  • 3. Meetup Rules This is a beginner friendly meetup, focus on Pi, but open to including other platforms and hardware There are no stupid questions. Open discussion is encouraged, keep it friendly! If you have equipment you would like to talk about or test together, see me after the presentation! Problems become opportunities when the right people join together! Be the bridge!
  • 5. About Brad 17+ years in IT, tech support, Linux administration Currently Senior DevOps Engineer for Health Union Mostly self-taught, with help from mentors and Philly tech communities. Love just building stuff! Not great at coding, really enjoy servers and apps! Coffee & Pi is meant to help people at all ages and skill levels to learn more about technology
  • 6. What I did on my summer vacation May - Participated in the 2nd Philly Art Museum Hackathon Was a finalist again, 2nd year in a row, didnt win :( June - Started a new job at Health Union :) June-August - Tried to build an iPhone travel app Failed :( (Did learn a lot about React Native and Swift!) August - Registered Coffee & Pi with the Raspberry Pi Foundation They have STICKERS!!! And I have news :) Got some great ideas and materials for future meetups! Built a Raspberry Pi photo booth and it works! :)
  • 8. Upcoming Coffee & Pi October 16 - Everything RetroPie! Install and configure RetroPie Explore and maybe demo some alternatives November - Looking for topic ideas, open to suggestions Will be more consistent with monthly meetups! March 2018 - Raspberry Pi Big Birthday Weekend Coffee & Pi is joining several Philly meetup groups and partners for one big event! Introducing Philly & Pi
  • 9. Philly & Pi Organizing to bring Philly meetups and groups together for demos and talks to inspire people of all levels and ages to learn with Raspberry Pi Already confirmed meetup groups and partners Coffee & Pi Meetup Philly GraphDB MeetUp Philly IoT MeetUp DataPhilly Meetup Raspberry Pi Neo4j
  • 10. Help Wanted! Philly & PI - More details to come! Will be looking for other groups and partners to join! Raspberry Pi is in talks about streaming feeds during the weekend too! Anyone have any equipment or connections that can help? Will need volunteers if anyone is interested, will put you first in line for swag and includes a free Philly & Pi t-shirt! Let Brad know if you are!
  • 11. Lets get to the builds!
  • 12. Download Raspbian with Desktop https://www.raspberrypi.org/downloads/raspbian/ Raspbian with Desktop 1.63 GB, Lite is 364 MB
  • 14. Etcher on mac to flash microSD card Download and Install Etcher - https://etcher.io Download OS image, Insert SD memory card, Flash!
  • 15. Etcher on mac to flash microSD card Wait for the files to copy
  • 16. Etcher on mac to flash microSD card Wait for the Validating of the image
  • 17. Etcher on mac to flash microSD card When its finished, you can safely remove memory card, and insert into Raspberry Pi and boot!
  • 19. Etcher on Windows 7+ to microSD card Download and Install Etcher - https://etcher.io Download OS image, Insert SD memory card, Flash!
  • 20. Etcher on Windows 7+ to microSD card Wait for the files to copy
  • 21. Etcher on Windows 7+ to microSD card Wait for the Validating of the image
  • 22. Etcher on Windows 7+ to microSD card I actually saw the Unmounting step
  • 23. Etcher on Windows 7+ to microSD card When its finished, you can safely remove memory card, and insert into Raspberry Pi and boot!
  • 25. Enable Wifi Click the disconnected Wifi logo in toolbar (red arrows) Select the target network Enter network password/key Verify icon goes to blue wifi
  • 26. Run Updates Open Terminal Run the following commands: sudo apt-get update sudo apt-get upgrade
  • 27. Find the IP address Open Terminal Run the following command: ifconfig Check output for wlan0 for wifi Run exit to close terminal
  • 28. Open Raspberry Pi Conf Click the drop down menu Click on Preferences Click on Raspberry Pi Configuration
  • 29. Enable VNC Server Click on Interfaces tab in Raspberry Pi Configuration Click Enabled next to VNC option Click on OK to save and enable VNC server
  • 30. Configure VNC Server After enabling, will have VNC icon in the toolbar Clicking on the icon opens the VNC Server config settings Also displays the wifi IP address Authentication default is local user pi with password raspberry
  • 31. Install VNC Connect Visit RealVNC website to download VNC Connect client https://www.realvnc.co m/en/connect/downloa d/vnc/ Clients for Windows, Mac, Linux, Raspberry Pi, Solaris, HP-UX, AIX
  • 33. You are now ready to code!
  • 35. Install the PiStop on the GPIO before powering on the Raspberry Pi
  • 36. Open Thonny Worksheet says to use Python 3 IDE, but use Thonny instead! Its now the default app for .py Click Menu - Programming - Thonny Python IDE
  • 38. Open PiStop Worksheet Script in Thonny Code is online at https://github.com/CoffeeAndPi/PiStopWorksheet Make changes, press Run Current Script button (looks like a play button) To stop, click Interrupt/Reset button (looks like a stop button)
  • 39. Thats PiStop! Can use worksheet to get started. Expand on the ideas of challenging people by different sequences and creating code to meet those challenges. I didnt feel this was a enough for a meetup, wanted to do something actually useful and interesting
  • 42. Based on TouchSelfie Photo Booth https://makezine.com/projects/raspberry-pi-photo-booth/
  • 43. The Coffee & Pi Way Need to install updates and python dependencies Using the latest Raspbian (Stretch) Sept 7, 2017 May be different than original blog, but tested! Enable and add the camera and touch screen Setup Google Photos API integration Git clone repo, update settings, and run!
  • 44. Required Components Raspberry Pi 3 + Raspbian Desktop OS Raspberry Pi Camera V2 Raspberry Pi 7 Touchscreen Display USB battery pack (cordless) or USB cord Case or 3D printed camera mount Google Account with Photos API enabled
  • 45. Install Touch Screen Raspberry Pi 3 mounts onto the back of the touch screen with 4 screws Run red and black cables from Pi to touch screen (other 3 are for Microsoft IoT and adv dev)
  • 46. 7 Pi Touch Screen
  • 48. Add Raspberry Pi 3 screw into 4 posts on touch screen
  • 49. Loop the ribbon cable to the Pi 3
  • 50. Add red and black jumper cables from Pi to touch screen
  • 51. Install the Pi Camera v2 Make sure the blue side faces the network port!
  • 52. Enable the camera via Raspberry Pi Configuration
  • 53. Enabling the camera will trigger a reboot
  • 54. By default, the touch screen display is upside-down!
  • 55. Rotate touch screen 180 degrees Open terminal sudo vi /boot/config.txt (or use fav text editor) Add lcd_rotate=2 to the bottom of the file Save and reboot!
  • 56. Test the Camera Open Terminal cd Desktop raspistill -o cam.jpg Should take picture and save to Desktop as cam.jpg More raspistill options https://www.raspberrypi.org/documentation/usage/ca mera/raspicam/raspistill.md
  • 57. Setup Pi and Dependencies Open Terminal Install Updates sudo apt-get update && sudo apt-get upgrade Install Python Dependencies sudo apt-get install python-imaging python-gdata python-pil.imagetk Install Google API for Python sudo pip install --upgrade google-api-python-client
  • 58. Clone the repo to Pi In Terminal mkdir git cd git git clone https://github.com/CoffeeAndPi/TouchSelfie
  • 59. Create Google Photos Album https://photos.google.com/albums Create an upload album, save one photo into it
  • 60. Enable 2-Step Verification https://myaccount.google.com/security Follow wizard to enable 2-step verification
  • 61. Turn on 2-Step Verification Requires verifying with a cell or phone number
  • 62. Create an App Password Will only display if 2-Step verification is enabled!
  • 63. Generate App Password Choose a name for the app and Google will generate an app password in a yellow box. Save this!
  • 64. Create API Keys https://console.developers.google.com/apis/librar y Click on Select a Project -> Click on + to create project
  • 65. Create New Project Fill in Project name, can be anything Click Create when ready
  • 66. Create Credentials Select the project you just created Click on Credentials on the left menu
  • 67. Create Credentials Click on OAuth consent screen tab Enter a product name show to users
  • 68. Create Credentials Click on Credentials again Click on Create credentials - OAuth client ID
  • 69. Create Credentials Select Other for Application Type Set Name as Installed, then click Create
  • 70. Create Credentials Click on OK to dismiss the client IDs Click on the Installed OAuth Client ID
  • 71. Download Credentials JSON Click on Download JSON and save to Raspberry Pi
  • 72. Rename and Move JSON Rename the JSON file to OpenSelfie.json Move to /home/pi/git/TouchSelfie/scripts
  • 73. Run the App Add Desktop/PhotoBooth.sh to the desktop Make it executable! Double click to start the app! Its a Raspberry Pi photo booth!!!
  • 75. Thank you! Anything is possible! Keep experimenting!!! Connect with other local and online communities for more help and support! You have my permission to fail! Keep trying! Please leave ratings and feedback on meetup.com, it helps others to find and know how Coffee & Pi goes!
  • 76. Philly Tech Communities Philly Python Users Group (PhillyPUG) https://www.meetup.com/preview/phillypug Philly IoT Meetup https://www.meetup.com/preview/Philadelphia- Internet-of-Things-Meetup Hardware - NextFab, The Hacktory Youth - TechGirlz, Hopeworks, Coded by: Kids
  • 77. Raspberry Pi Resources Use the #CoffeeAndPi to show off your projects! We are on PhillyDev.org Slack #RaspberryPi You can use the Coffee and Pi meetup tools, email group, online discussion board Let me know if theres anything I can do to help!
  • 78. Thank you! Questions? If you have equipment to test, come see me!