Get python program that reads serial port working, see attached program (SerialRead.py)
Install MySQL server on Pi. You will be asked for a root password as part of the install, please user CoderDojo as password
sudo apt-get install mysql-server
Install MySQL library for Python
sudo apt-get install python-mysqldb
Log into MySQL and create table
mysql -u root –p
CREATE TABLE IF NOT EXISTS RndNums (Id INT PRIMARY KEY AUTO_IMCREMENT, RndNum VARCHAR(2)
Create user (testuser) and set password (test623)
CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'test623';
Grant privileges to testuser on all tables in testdb database
GRANT ALL ON testdb.* TO 'testuser'@'localhost';
Query new table
SELECT * FROM RndNums;
database functionality to write values from Serial port to database table.
functionality to write to serial port to turn led on Arduino on/off. If value is greater than 50 and turn led off if value is less than 50.
After the program has run, use a terminal window to start MySQL and query table to check that values have been inserted. See steps 4 & 7 above
sudo apt-get install python-serial
The following link provides a good tutorial on Python, which you may wish to look at before next week's session.
To use the following commands, open terminal window from desktop
apt-get install [package name]
apt-get remove [package name]
apt-cache search [game]
Produced by Raspberry PI foundation
Released in Feb 2012
System on a Chip (SOC) – CPU & GPU + RAM on single chip – unlike PC architecture.
Model A – Single USB, No network port
Model B 2 USB port, network port
512MB RAM on newer models
Runs Linux Operating System
Operating System is stored on SD card
Raspberry PI does not come with monitor, keyboard, mouse, power supply, Operating System, hard disk