From charlesreid1

 
(17 intermediate revisions by the same user not shown)
Line 5: Line 5:
=Installing=
=Installing=


The page containing instructions for installing an operating system on the Raspberry Pi is over at [[RaspberryPi/Installing]]
Instructions for installing an operating system on the Raspberry Pi: [[RaspberryPi/Installing]]




==After Installing: Interfacing with Headless Pi==


=Interfacing with Headless Pi=
Instructions for interfacing with headless Raspberry Pis, including how to change their boot sequence to find them on a network: [[RaspberryPi/Headless]]


If you are running a headless Raspberry Pi, you can follow these instructions for modifying the Raspberry Pi boot sequence so that you can find your Pi on a network: [[RaspberryPi/Headless]]


==After Installing: First Steps with Pi==
You can find a guide to your first steps with Raspberry Pi, mainly covering the setup process for Raspbian Linux: [[RaspberryPi/First Steps]]
=Raspberry Pi Projects=
==Hardware Focus==
Most recent projects listed first.
===Making an Internet of Things Morse Code Keyer with Raspberry Pi===
Combining the morse code example below with [[Flask]], a lightweight web server for Python, allows us to create an API for remotely controlling the Raspberry Pi. We can then use the Raspberry Pi to send morse code with the LED.
Here are the details: [[RaspberryPi/IoT Morse Code Keyer]]
===Morse Code on Raspberry Pi===
This page has more details on a quick-and-easy way to get a Morse code library I wrote in Python up and running on the Raspberry Pi: [[RaspberryPi/Morse Code]]
===Raspberry Pi Timelapse Photo===
You can find a short guide to how I built a Raspberry Pi time lapse photo camera here:
[[RaspberryPi/Timelapse]]
===Hello World LED Circuit with GPIO===
This project controls a simple LED circuit with the Raspberry Pi's onboard GPIO cable: [[Hello World Raspberry Pi]]
This project uses a python code to send high/low voltage signals to pins on the GPIO, and make an LED on a breadboard blink.
==Software Focus==
===Run Web Server on Pi===
You can find a guide to running a lightweight web server with Flask or something similar:
[[RaspberryPi/Web Server]]
===Kali Linux on Raspberry Pi===
Getting deeper into the world of networking and using the Pi for security and networking applications:
[[Kali Raspberry Pi]]
===Tor Proxy with Pi===
More info here: [https://learn.adafruit.com/onion-pi]


=First Steps with Pi=


You can find a guide to your first steps with Raspberry Pi, mainly covering the setup process for Raspbian Linux: [[RaspberryPi/First Steps]]
==Wifi Access Point==


=Run Web Server on Pi=
===Installing Requisite Software===


You can find a guide to running a lightweight web server with Flask or something similar over at [[RaspberryPi/Web Server]]
Basically, you will be setting up your Pi as a host access point, which requires some software. Specifically, here is the software required:


=Raspberry Pi Projects=
<pre>
$ sudo apt-get install hostapd isc-dhcp-server
</pre>


==Raspberry Pi Timelapse Photo==
===Set Up DHCP Server===


===Software===
Next, set up the DHCP server by editing <code>/etc/dhcp/dhcp.conf</code>


Since I hadn't connected my Pi to the net in a while, the first thing I did was to update the package manager:
Remove the following two lines by commenting them out:


<pre>
<pre>
sudo apt-get update
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
</pre>
</pre>


Next, I upgraded the operating system:
Next, add the word "authoritative;" to the section where it gives you information. You should see this in your file:


<pre>
<pre>
sudo apt-get dist-upgrade
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
</pre>
</pre>


With all of the updating and upgrading out of the way, I moved on to the actual Raspberry Pi camera itself. There is a Python module to control the Pi camera, available through aptitude:
Finally, add the following lines to set up the IP address assignment/configuration:


<pre>
<pre>
sudo apt-get install python-picamera python-picamera-docs
subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.10 192.168.42.50;
option broadcast-address 192.168.42.255;
option routers 192.168.42.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
</pre>
</pre>


However, I was still not able to use my camera, because I had to run the Raspberry Pi configuration program. To run it:
===Set Up DHCP Interfaces===
 
Next, edit the file <code>/etc/default/isc-dhcp-server</code> and update the <code>INTERFACES</code> section to read:


<pre>
<pre>
sudo raspi-config
INTERFACES="wlan0"
</pre>
</pre>


You enable the Raspberry Pi camera in the configuration menu.
Now disable the wlan0 interface:


===Setup===
<pre>
sudo ifdown wlan0
</pre>


The setup I had used one of [http://www.adafruit.com/products/1367 these] as the camera. This is a whopping 5 MP, which is as good as a point-and-shoot, except it's extremely tiny. I was able to get it hooked up to my Raspberry Pi and working just fine with the above steps.
Now change the wlan0 network interface so that it will use manually-assigned IP address information, instead of trying to set everything automatically. Edit <code>/etc/network/interfaces</code> and add/change the lines:
 
<pre>
# auto wlan0
</pre>


You can use Python code to trigger the camera to take a picture, and you can specify a filename to save to. Here's a quick script I hacked together to take a picture every 2 seconds, and save it to sequentially-numbered files (0001.jpg, 0002.jpg, etc.):
<pre>
allow-hotplug wlan0


<source lang="python">
iface wlan0 inet static
# pic.py
    address 192.168.42.1
    netmask 255.255.255.0
</pre>


import picamera
Finally, edit <code>/etc/hostapd/hostapd.conf</code> to set up the wireless network:
import time


camera = picamera.PiCamera()
<pre>
interface=wlan0
driver=rtl871xdrv
ssid=Pi_AP
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
</pre>


i = 0
Note that the <code>driver=rtl871xdrv</code> line may need to change.
while True:


    filename = "%04d.jpg"%(i)
===More Info===


    camera.capture(filename)
More info here: [https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point]
    print "Saving photo to %s"%(filename)


    i += 1
=Powering the Pi via UART/Serial=
    time.sleep(2)


</source>
UART = Universal Asynchronous Receive/Transmit


To run this, I use screen. I log in remotely, then run the <code>screen</code> command. In that screen I run <code>python pic.py</code>. It will print out as it progresses. Running it with screen allows you to disconnect and leave the Pi unattended.
While you can normally interface with and power the Pi by plugging it into a computer or a wall wart via the mini USB port, you can also power the Pi via the pins on the board, and communicate with the Pi via a serial connection. This uses the 5V, Ground, TX, and RX pins that are on the right side (the 5V side) of the pins on the Pi board.


By plugging these into a USB serial adapter, which is plugged into a computer, the connection can be used to provide power and a connection to the Pi.


More details: http://villagescience.org/running-raspberry-pi-usb-serial-ttl-adapter/


==Hello World LED Circuit with GPIO==
=Notes by Date=


This project controls a simple LED circuit with the Raspberry Pi's onboard GPIO cable. A python code is used to send high/low voltage signals to pins on the GPIO, and make an LED on a breadboard blink.
[[Raspberry Pi 2015-07-29]] - basic hello world


[[Hello_World_Arduino_Pi]]
[[Raspberry Pi 2015-07-30]] - basic hello world writeup


[[Raspberry Pi 2015-07-31]] - morse code writeup, Flask Web API to control hardware


==Kali Linux on Raspberry Pi==
[[August 2015]] - notes from august 2015


Getting deeper into the world of networking and using the Pi to analyze networks: [[Kali Pi]]
[[August 2016]] - notes from august 2016


=Resources=
=Resources=
Line 100: Line 185:
* http://raspberry.io/wiki/how-to-get-python-on-your-raspberrypi/
* http://raspberry.io/wiki/how-to-get-python-on-your-raspberrypi/


{{PiFlag}}


[[Category:Raspberry Pi]]
[[Category:Raspberry Pi]]

Latest revision as of 02:30, 12 August 2017

A guide to hacking on the Raspberry Pi, a microcomputer that runs a full stack Linux OS, all on a mobile processor:

RaspberryPi PluggedInRPi.jpg

Installing

Instructions for installing an operating system on the Raspberry Pi: RaspberryPi/Installing


After Installing: Interfacing with Headless Pi

Instructions for interfacing with headless Raspberry Pis, including how to change their boot sequence to find them on a network: RaspberryPi/Headless


After Installing: First Steps with Pi

You can find a guide to your first steps with Raspberry Pi, mainly covering the setup process for Raspbian Linux: RaspberryPi/First Steps

Raspberry Pi Projects

Hardware Focus

Most recent projects listed first.

Making an Internet of Things Morse Code Keyer with Raspberry Pi

Combining the morse code example below with Flask, a lightweight web server for Python, allows us to create an API for remotely controlling the Raspberry Pi. We can then use the Raspberry Pi to send morse code with the LED.

Here are the details: RaspberryPi/IoT Morse Code Keyer

Morse Code on Raspberry Pi

This page has more details on a quick-and-easy way to get a Morse code library I wrote in Python up and running on the Raspberry Pi: RaspberryPi/Morse Code

Raspberry Pi Timelapse Photo

You can find a short guide to how I built a Raspberry Pi time lapse photo camera here:

RaspberryPi/Timelapse

Hello World LED Circuit with GPIO

This project controls a simple LED circuit with the Raspberry Pi's onboard GPIO cable: Hello World Raspberry Pi

This project uses a python code to send high/low voltage signals to pins on the GPIO, and make an LED on a breadboard blink.

Software Focus

Run Web Server on Pi

You can find a guide to running a lightweight web server with Flask or something similar:

RaspberryPi/Web Server

Kali Linux on Raspberry Pi

Getting deeper into the world of networking and using the Pi for security and networking applications:

Kali Raspberry Pi

Tor Proxy with Pi

More info here: [1]


Wifi Access Point

Installing Requisite Software

Basically, you will be setting up your Pi as a host access point, which requires some software. Specifically, here is the software required:

$ sudo apt-get install hostapd isc-dhcp-server

Set Up DHCP Server

Next, set up the DHCP server by editing /etc/dhcp/dhcp.conf

Remove the following two lines by commenting them out:

option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;

Next, add the word "authoritative;" to the section where it gives you information. You should see this in your file:

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

Finally, add the following lines to set up the IP address assignment/configuration:

subnet 192.168.42.0 netmask 255.255.255.0 {
	range 192.168.42.10 192.168.42.50;
	option broadcast-address 192.168.42.255;
	option routers 192.168.42.1;
	default-lease-time 600;
	max-lease-time 7200;
	option domain-name "local";
	option domain-name-servers 8.8.8.8, 8.8.4.4;
}

Set Up DHCP Interfaces

Next, edit the file /etc/default/isc-dhcp-server and update the INTERFACES section to read:

INTERFACES="wlan0"

Now disable the wlan0 interface:

sudo ifdown wlan0

Now change the wlan0 network interface so that it will use manually-assigned IP address information, instead of trying to set everything automatically. Edit /etc/network/interfaces and add/change the lines:

# auto wlan0
allow-hotplug wlan0

iface wlan0 inet static
    address 192.168.42.1
    netmask 255.255.255.0

Finally, edit /etc/hostapd/hostapd.conf to set up the wireless network:

interface=wlan0
driver=rtl871xdrv
ssid=Pi_AP
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Raspberry
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Note that the driver=rtl871xdrv line may need to change.

More Info

More info here: [2]

Powering the Pi via UART/Serial

UART = Universal Asynchronous Receive/Transmit

While you can normally interface with and power the Pi by plugging it into a computer or a wall wart via the mini USB port, you can also power the Pi via the pins on the board, and communicate with the Pi via a serial connection. This uses the 5V, Ground, TX, and RX pins that are on the right side (the 5V side) of the pins on the Pi board.

By plugging these into a USB serial adapter, which is plugged into a computer, the connection can be used to provide power and a connection to the Pi.

More details: http://villagescience.org/running-raspberry-pi-usb-serial-ttl-adapter/

Notes by Date

Raspberry Pi 2015-07-29 - basic hello world

Raspberry Pi 2015-07-30 - basic hello world writeup

Raspberry Pi 2015-07-31 - morse code writeup, Flask Web API to control hardware

August 2015 - notes from august 2015

August 2016 - notes from august 2016

Resources