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.

= Base OS =

https://www.raspberrypi.org/downloads/


 * Raspbian
 * RASPBIAN JESSIE WITH PIXEL
 * Win32DiskImager utility
 * put on 16 gig micro card
 * boot

sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade
 * 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? )

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
sudo apt-get install xrdp
 * 1) use this command to setup the pi => should work but did not see below

but there seem to be problems on the pi 3 see Summary ( and this worked for me )
 * connect problems

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

 * https://askubuntu.com/questions/133343/how-do-i-set-up-xrdp-session-that-reuses-an-existing-session

= 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


 * http://raspberrypihq.com/how-to-connect-your-raspberry-pi-to-wifi/


 * https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md  - includes info on encrypting password and other advanced info


 * https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=138137


 * 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”.


 * 1) You should already have your SSID name, but if not, use


 * 1) sudo iwlist wlan0 scan
 * 2) This will reveal the SSID in the line “ESSID”. Next, open wpa_supplicant.conf:


 * 1) sudo leafpad /etc/wpa_supplicant/wpa_supplicant.conf


 * 1) 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

 * http://www.raspberry-projects.com/pi/pi-operating-systems/raspbian/gui/desktop-shortcuts

= Spyder and More Python = >>> sudo apt-get install spyder

Python Autoexec
sudo leafpad ~/.config/lxsession/LXDE/autostart
 * 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/


 * 1) =============== begin autoexec.py ============
 * 2) this is an example file, it shows how to open stuff, not
 * 3) a good example of what to open, which is up to you.
 * 4) this opens up so much stuff you may want to try it
 * 5) with some lines commented out.
 * 6) sudo leafpad ~/.config/lxsession/LXDE/autostart
 * 7) sudo leafpad ~/autoexec.py
 * 8) you can run it on the Pi as a normal idle or spyder program you do
 * 9) not have to reboot each time

import os from subprocess import Popen,PIPE

print "starting autopython.py"
 * 1) normally the output really has no place to go so nothing will be seen from the print statment


 * 1) -- mount an nas drive
 * 2) use os.system only if the command runs and exits othwise this program
 * 3) 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' )


 * 1) -- leafpad
 * 2) this will run leafpad ( a nice little editor on the Pi ) with no file opended, the program does
 * 3) not wait to see how leafpad runs but goes on to the rest of the program
 * 4) not waiting is a general feature of Popen as used here


 * 1) proc = Popen( [r"leafpad"] )


 * 1) -- leafpad
 * 2) open a file, actually tis file in leafpad

proc = Popen( [ "leafpad /home/pi/autopython.py"], shell=True ) #


 * 1) -- starpusher
 * 2) run the python game starpusher


 * 1) proc = Popen( [r"python /home/pi/python_games/starpusher.py"], shell=True )


 * 1) -- idle
 * 2) just open the idle ( a python environment


 * 1) proc = Popen( [r"/usr/bin/idle"] )


 * 1) -- idle editing a file


 * 1) proc = Popen( [r"/usr/bin/idle /home/pi/python_games/starpusher.py"], shell=True )


 * 1) -- idle not editing a file but running it
 * 2) 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 "


 * 1) =================== 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 =

Pi MySql

= Share Net Drive =

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 =
 * 1) see the link below for more directions:
 * 2) http://tech.cyborg5.com/2013/05/30/irlib-tutorial-part-3d-installing-the-arduino-ide-on-a-raspberry-pi/


 * 1) 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)


 * 1) define NO_DHT  1     // number of dht units -- do not lie messes up the timing


 * 1) 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
 * 2) 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
 * 1) define LCD_RS        13     // register select, pin to digital pin 12
 * 2) define LCD_ENABLE    12     // pin to digital pin 11
 * 3) define LCD_D4        8      // pin to digital pin 5
 * 4) define LCD_D5        9      // pin to digital pin 4
 * 5) define LCD_D6        10     // pin to digital pin 3
 * 6) 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

= Old =


 * PiSetup

= Terminal and GreenHouse now Work =

= Clone =

PiClone

= SSH from Windows =

Raspberry Pi SSH