Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi...

35
Seite 1 Raspberry Pi in Higher Education Alexander Elsas Goethe University Frankfurt, Germany [email protected] The Raspberry Pi Big Birthday Weekend, Cambridge

Transcript of Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi...

Page 1: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 1

Raspberry Pi in Higher Education

Alexander ElsasGoethe University Frankfurt, Germany

[email protected]

The Raspberry Pi Big Birthday Weekend, Cambridge

Page 2: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 2

Alexander Elsas

Assistant Professor

Economics, Management & Information Systems

Database developer with APEX

Information Systems for Business Students

Management for Computer Science Students

Raspberry Pi since February 2012

Page 3: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 3

Page 4: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 4

To Carry Coals to Newcastle

● Price tag● Performance● Flexibility● GPIO● Wolfram● ...

Page 5: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 5

Experiences so far

Introduced the Raspberry Pi in every introductory course for business students since winter semester 2012:

● Always an overwhelming positive reaction,● lots of questions far beyond the syllabus,● biggest motivation the multimedia center.

Based on these positive reactions the “Two Simple Projects“ have been created.

Page 6: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 6

Two Simple Projects

PiMMS: Pi-based Multimedia System

FRAdir: Operating directions of Frankfurt Airport

Objective:

Get business students an intro into computer science (information systems) and provide them a feeling of success to boost their motivation.

Page 7: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 7

PiMMS

Turn-key digital signage system:

Power-on on premise

No network connectivity needed

No manual configuration necessary

Boots into slideshow No coding, just configuration of existing programs

Fast results, product can be used in a real-life scenario

Possible extension: integrate network connectivity

Page 8: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 8

FRAdir

FRAport publishes the actual direction of operation of Frankfurt Airport (FRA) on their website (07 East / 25 West)

Objective: Gather data from the website, store it in a database for later analysis

Programming exercise in Python in a nutshell

Possible extension: 7-segment LED display

Page 9: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 9

Show-and-Tell

Both projects can be seen tomorrow.

Page 10: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 10

Computer Science Students

● Course “Introduction into ERP“● Very SAP-oriented● Students “hate“ SAP● Open Source ERP with Raspberry Pi● Installation and configuration of OpenERP (now Odoo:

http://en.wikipedia.org/wiki/Odoo) ● Comparison of performance, GUI, etc

Page 11: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 11

Further projects in the pipeline

● SQL-Box:

Raspberry Pi as database server, equipped with MySQL or SQLite as SQL learning tool

● Pi-Lab:

Establish an infrastructure on campus to support more advanced projects

● Ideas from the audience ...

Page 12: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 12

Best Programming Language?

● Learning to programme is independent from a specific language.

● A problem must be analyzed, divided in sub-problems, etc …

● At the end of the day the remaining problems are on the level of individual statements of the chosen programming language.

Programming is a process, not a language!

Page 13: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 13

Something completely different

Raspberry Pi and its success, ecosystem, created jobs and businesses as object of economic analysis.

Page 14: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 14

Contact

Alexander Elsas

Goethe-Universität Frankfurt

Theodor-W.-Adorno-Platz 3

D-60323 Frankfurt

Telephone: +49 69-798 33636

Fax: +49 69-798 33639

Email: [email protected]

Internet: databaselab.de

Page 15: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 1

PiMMS & FRAdir – Two Simple Projects

Alexander ElsasGoethe University Frankfurt, Germany

[email protected]

The Raspberry Pi Big Birthday Weekend, Cambridge

Page 16: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 2

Two Simple Projects

PiMMS: Pi-based Multimedia System

FRAdir: Operating directions of Frankfurt Airport

Objective:

Get business students an intro into computer science (information systems) and provide them a feeling of success to boost their motivation.

Page 17: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 3

PiMMS

Turn-key digital signage system:

Power-on on premise

No network connectivity needed

No manual configuration necessary

Boots into slideshow No coding, just configuration of existing programs

Fast results, product can be used in a real-life scenario

Possible extension: integrate network connectivity on premise

Page 18: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 4

Page 19: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 5

Page 20: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 6

Page 21: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 7

Components

Monitor feh as slideshow application

starts automatically after booting into LXDE xscreensaver to disable screensaver of LXDE

sudo apt-get install feh xscreensaver

Page 22: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 8

Technical Details

feh -pzrFYD10 slideshows in slideshow, make slideshow executable(http://man.finalrewind.org/1/feh/ for options of feh)

Autostart in LXDE:Add @/home/pi/slideshow to /etc/xdg/lxsession/LXDE-pi/autostart

Page 23: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 9

Looking for ...

Replacement for feh which can also show video (like Irfanview)

Page 24: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 10

FRAdir

FRAport publishes the actual direction of operation of Frankfurt Airport (FRA) on their website (07 East / 25 West)

Objective: Gather data from the website, store it in a database for later analysis

Programming exercise in Python in a nutshell

Possible extension: 7-segment LED display

Page 25: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 11

Data source: http://apps.fraport.de/betriebsrichtung/betriebsrichtung.html

Page 26: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 12

Source Code: betriebsrichtung.py

#!/usr/bin/python

import urllib, time, sqlite3, smtplib

from email.message import Message

#URl einlesen

sock = urllib.urlopen("http://apps.fraport.de/betriebsrichtung/betriebsrichtung.html")

htmlSource = sock.read()

sock.close()

beg = htmlSource.find("Betriebsrichtung")

betriebsrichtung = htmlSource[beg+60]

if (betriebsrichtung == "0"):

betriebsrichtung = "Ost 07"

else:

betriebsrichtung = "West 25"

Page 27: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 13

seit = htmlSource.find("seit")

datum = htmlSource[seit+5:seit+15]

zeit = htmlSource[seit+17:seit+25]

sep = ";"

ausgabe = betriebsrichtung+ sep+ datum+" "+ zeit+ sep+ time.strftime("%c")

print ausgabe

Page 28: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 14

f = open('status.br', 'r')

last = f.readline()

f.close()

#print last

msg = Message()

msg.set_payload(ausgabe)

msg["Subject"] = "Betriebsrichtung: "+betriebsrichtung

msg["From"] = "[email protected]"

msg["To"] = "[email protected]"

Page 29: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 15

if (last[0] <> betriebsrichtung[0]):

#print "Wechsel!!!"

f = open('status.br', 'w')

f.write(betriebsrichtung)

f.close

# csv fortschreiben

f = open('br.csv', 'a')

f.write(ausgabe+'\n')

f.close

# html datei updaten

sep = "<br>"

ausgabe = "<div style>"+betriebsrichtung+ sep+ "Seit: " +datum+" "+ zeit+ sep+"Update: "+ time.strftime("%c")+"</div>"

f = open('/var/www/br.html', 'w')

f.write(ausgabe)

f.close

Page 30: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 16

# datenbank

#if (True):

db = sqlite3.connect('br.db')

cursor = db.cursor()

cursor.execute('''INSERT INTO br(id, richtung, zeit, bemerkung)VALUES(NULL,?,?,?)''', (betriebsrichtung, zeit+";"+datum, ' '))

db.commit()

db.close()

Page 31: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 17

# email

#if (True):

smtpobj = smtplib.SMTP("smtp.gmail.com", 587)

smtpobj.ehlo()

smtpobj.starttls()

smtpobj.ehlo()

smtpobj.login('[email protected]', 'mysecretpassword')

smtpobj.sendmail('[email protected]', '[email protected]', msg.as_string())

smtpobj.quit

Page 32: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 18

Email on midday: statusbr.py

#!/usr/bin/python

import smtplib

from email.message import Message

f = open('status.br', 'r')

last = f.readline()

f.close()

msg = Message()

msg.set_payload(last)

msg["Subject"] = "Betriebsrichtung: "+last

msg["From"] = "[email protected]"

msg["To"] = "[email protected]"

smtpobj = smtplib.SMTP("smtp.gmail.com", 587)

smtpobj.ehlo()

smtpobj.starttls()

smtpobj.ehlo()

smtpobj.login('[email protected]', 'mysecretpassword')

smtpobj.sendmail('[email protected]', '[email protected]', msg.as_string())

smtpobj.quit

Page 33: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 19

Crontab

betriebsrichtung.py is started hourly

statusbr.py always on midday

Page 34: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 20

Page 35: Raspberry Pi in Higher Education - Databaselabdatabaselab.org/files/cambridge.pdf · Raspberry Pi in Higher Education ... product can be used in a real-life ... Installation and configuration

Seite 21

Contact

Alexander Elsas

Goethe-Universität Frankfurt

Theodor-W.-Adorno-Platz 3

D-60323 Frankfurt

Telephone: +49 69-798 33636

Fax: +49 69-798 33639

Email: [email protected]

Internet: databaselab.de