Pi Setup Nov 2016
Yet another setup for the Pi
This whole article is largely obsolete -- 2016 is a long time ago, there is a more recent one, look for it.
Contents
Base OS
https://www.raspberrypi.org/downloads/
- Raspbian
- RASPBIAN JESSIE WITH PIXEL
- Win32DiskImager utility
- put on 16 gig micro card
- boot
- Before installing new application or service in Raspbian, make sure to always type this into terminal: ( if this file is on your PI use cut and paste ) This takes awhile ( perhaps an hour? )
sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade
You many find the following of use as well Linux Commands On Pi
Change Password
- as shipped id is pi password is raspberry. default user is pi , and the password is raspberry
- Change your password. When logged in as the pi user, you can change your password with the passwd command. Enter passwd on the command line and press Enter . You'll be prompted to enter your current password to authenticate, and then asked for a new password.
passwd
Preferences
Use the menu to change to a us keyboard or whatever preference you may have.. timezone?
- WiFi Country code
- Timezone
- Keyboard had trouble getting to stick see Linux Commands On Pi which may have info on config file edit.
Set Up Remote Desktop
Base Install
- use this command to setup the pi => should work but did not see below
sudo apt-get install xrdp
but there seem to be problems on the pi 3 see
Summary ( and this worked for me )
remove the following packages : xrdp, vnc4server, tightvncserver ( may not be present, but no worry, just do it )
sudo apt-get remove xrdp vnc4server tightvncserver
install tightvncserver followed by xrdp
sudo apt-get install tightvncserver sudo apt-get install xrdp
Need the IP Address
on the pi issue the command
ifconfig
and read the tcpip address of the pi( inet addr ) which you can then use, or better use a fixed address
fixed ip address
sudo leafpad /etc/dhcpcd.conf
Scroll all the way to the bottom of the file and add one, or both of the following snippets. Depending on whether you want to set a static IP address for a wired connection or a wireless connection eth0 = wired, wlan0 = wireless. You’ll need to edit the numbers in the snippet so they match your network configuration.
- interface = This defines which network interface you are setting the configuration for.
- static ip_address = This is the IP address that you want to set your device to. (Make sure you leave the /24 at the end)
- static routers = This is the IP address of your gateway (probably the IP address or your router)
- static domain_name_servers = This is the IP address of your DNS (probably the IP address of your router). You can add multiple IP addresses here separated with a single space.
- my next Rasberry Pi 178/179
interface eth0 static ip_address=192.168.0.176/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1 interface wlan0 static ip_address=192.168.0.200/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1
Links
Wireless Links and WiFi
if you have the desktop avaliable see the icon for wireless, possibly bottom left?
ifconfig and ifconfig -a may give useful info
- https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md - includes info on encrypting password and other advanced info
- http://www.makeuseof.com/tag/setup-wi-fi-bluetooth-raspberry-pi-3/
- http://www.nowiressecurity.com/configure-8021x-authentication-linux
sudo iwlist wlan0 scan This will list all the networks in your vicinity along with some useful information for each network. To find your network name look for something that look like: ESSID:”Test Wifi Network”.
# You should already have your SSID name, but if not, use # sudo iwlist wlan0 scan # This will reveal the SSID in the line “ESSID”. Next, open wpa_supplicant.conf: # sudo leafpad /etc/wpa_supplicant/wpa_supplicant.conf # can have more than one connection apparently network={ ssid="Acme Corp" scan_ssid=1 psk=abc123 id_str="work" priority=5 network={ ssid="Linksys" scan_ssid=1 psk=abc123 id_str="home" priority=5
Misc
shortcuts
Spyder and More Python
>>> sudo apt-get install spyder
Python Autoexec
- http://www.instructables.com/id/Python-Autoexec-for-Your-Raspberry-Pi/
- http://www.raspberrypi-spy.co.uk/2015/02/how-to-autorun-a-python-script-on-raspberry-pi-boot/
sudo leafpad ~/.config/lxsession/LXDE/autostart
# =============== begin autoexec.py ============ # this is an example file, it shows how to open stuff, not # a good example of what to open, which is up to you. # this opens up so much stuff you may want to try it # with some lines commented out. # sudo leafpad ~/.config/lxsession/LXDE/autostart # sudo leafpad ~/autoexec.py # you can run it on the Pi as a normal idle or spyder program you do # not have to reboot each time import os from subprocess import Popen,PIPE # normally the output really has no place to go so nothing will be seen from the print statment print "starting autopython.py" # -------------- mount an nas drive ------------ # use os.system only if the command runs and exits othwise this program # will stop until command is done ( not my real password ) os.system( r'sudo mount -t cifs -o username="russ",password="all9s",workgroup="MSHOME",file_mode=0777,dir_mode=0777,nobrl //192.168.0.120/share/_Source/rPi /mnt/share1' ) # -------------- leafpad ------------ # this will run leafpad ( a nice little editor on the Pi ) with no file opended, the program does # not wait to see how leafpad runs but goes on to the rest of the program # not waiting is a general feature of Popen as used here #proc = Popen( [r"leafpad"] ) # -------------- leafpad ------------ # open a file, actually tis file in leafpad proc = Popen( [ "leafpad /home/pi/autopython.py"], shell=True ) # # -------------- starpusher ------------ # run the python game starpusher #proc = Popen( [r"python /home/pi/python_games/starpusher.py"], shell=True ) # -------------- idle ------------ # just open the idle ( a python environment #proc = Popen( [r"/usr/bin/idle"] ) # -------------- idle editing a file ------------ #proc = Popen( [r"/usr/bin/idle /home/pi/python_games/starpusher.py"], shell=True ) # -------------- idle not editing a file but running it ------------ # not a particularlly useful process proc = Popen( [r"/usr/bin/idle -r /home/pi/python_games/starpusher.py"], shell=True ) # works, but runs program print " autopython.py all done " # =================== eof ========
My Projects
This is the directory I use, can we do it from file manager? Yes so command below is optional.
sudo mkdir /home/pi/SpyderP
No module named pymysql
sudo pip install pymysql
ImportError: No module named pyperclip
sudo pip install pyperclip
The two above got the terminal running, even pyserial seems to have been included.
My Sql
which samba
did not show samba but
sudo apt-get install samba
showed it was there -- not this time it did a big install ?? did it remove and install, the mysteries continue
>>> create mount point
sudo mkdir /mnt/share1
this gave read access
sudo mount -t cifs -o guest //192.168.0.170/share /mnt/share1
read write with this
sudo mount -t cifs -o username="russ",password="passwordhere",workgroup="MSHOME",file_mode=0777,dir_mode=0777,nobrl //192.168.0.170/share/_Source/rPi /mnt/share1
Arduino Setup
- see the link below for more directions:
- http://tech.cyborg5.com/2013/05/30/irlib-tutorial-part-3d-installing-the-arduino-ide-on-a-raspberry-pi/
- use this for installation
sudo apt-get install arduino
Arduino
Use the menu based setup
where do the libr go
- needed to download the zips, decompress
- move, rename to remove ilegal char
- include sensor.h in main program
- install from zip did not work.
/usr/share/arduino/libraries get from on the pc at to do file management with sudo privilidge sudo pcmanfm
//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 white? -- supposed to be more accurate than 11 -- may be more sens - favor in purchase //#define DHTTYPE DHT21 // DHT 21 (AM2301) #define NO_DHT 1 // number of dht units -- do not lie messes up the timing #define DHTPIN_1 5 // unit 1 data pin what digital pin we're connected to on unit 1 pin numbering from top back away from you #define DHTPIN_2 5 // unit 2 data pain // 1: v+ power / 2: data 3: null/ 4: gnd // top view // /-------------/ // / o o o o / // / 1 2 3 4 / // / / // /-------------/ // data uses a pull up of about 5 K // LCD // old names #define LCD_RS 13 // register select, pin to digital pin 12 #define LCD_ENABLE 12 // pin to digital pin 11 #define LCD_D4 8 // pin to digital pin 5 #define LCD_D5 9 // pin to digital pin 4 #define LCD_D6 10 // pin to digital pin 3 #define LCD_D7 11 // pin to digital pin 2 // Connect pin 1 (on the left) of the sensor to +5V // NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 // to 3.3V instead of 5V! // Connect pin 2 of the sensor to whatever your DHTPIN is // Connect pin 4 (on the right) of the sensor to GROUND // Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor