Difference between revisions of "Raspberry Pi"
m (→Configuring dual wifi adapters) |
(wifi extender project) |
||
Line 25: | Line 25: | ||
} | } | ||
</source> | </source> | ||
− | *'''Note1:''' The ''wpa_supplicant.conf'' file will be copied into ''/etc'' which is where it can be created or modified after the system is up and running. | + | *'''Note1:''' The ''wpa_supplicant.conf'' file will be copied into ''/etc/wpa_supplicant'' which is where it can be created or modified after the system is up and running. |
*'''Note2:''' If you'd like the file to apply only to specific interfaces (in the case that you have more than one wifi adapter) you can name the file e.g. ''wpa_supplicant-wlan1.conf''. | *'''Note2:''' If you'd like the file to apply only to specific interfaces (in the case that you have more than one wifi adapter) you can name the file e.g. ''wpa_supplicant-wlan1.conf''. | ||
Line 49: | Line 49: | ||
If you want to give it a fixed IP, you can set this up using in your router's DHCP server using the Pi's MAC address. Once you have discovered the Pi's IP you can ''ssh'' into it with the default credentials of user name "pi" and password "raspberry". Then you can begin configuring it starting by removing the default password! One very useful thing you may like to do straight away is make your Pi into a wifi [[hotspot]] :-) | If you want to give it a fixed IP, you can set this up using in your router's DHCP server using the Pi's MAC address. Once you have discovered the Pi's IP you can ''ssh'' into it with the default credentials of user name "pi" and password "raspberry". Then you can begin configuring it starting by removing the default password! One very useful thing you may like to do straight away is make your Pi into a wifi [[hotspot]] :-) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== External drives == | == External drives == | ||
Line 83: | Line 59: | ||
}} | }} | ||
− | One way of making the system less reliant on the SD card is to have it used only for initial booting and then use the external drive for root | + | One way of making the system less reliant on the SD card is to have it used only for initial booting and then use the external drive for root partition. This is set in the ''/boot/cmdline.txt'' file, see [http://banoffeepiserver.com/setup-raspbian-on-a-sata-hard-disk.html this] for more detail. |
+ | |||
+ | == Making a wifi signal extender == | ||
+ | In a few AirBnB's we've stayed at recently we've found that the wifi signal is very weak in some parts of the house where we like to use the computers a lot. I decided to make a general purpose solution using a Pi with an extra wifi adapter added via USB. This extra wifi adpater could also be further extended using a 5m USB extension cable in the case of very extreme cases involving concrete walls etc. | ||
+ | |||
+ | It's easiest to get an official wifi module so that you now it's supported by the Pi out of the box, but in my case I already had a USB adapter that was based on the '''RTL8192EU''' and took a few hours to get installed. In the end I found [https://lb.raspberrypi.org/forums/viewtopic.php?t=103989&start=200#p1255100 these] instructions that use [http://fars-robotics.net/install-wifi this] script which worked flawlessly: | ||
+ | <source lang="bash"> | ||
+ | sudo wget http://fars-robotics.net/install-wifi -O /usr/bin/install-wifi | ||
+ | sudo chmod +x /usr/bin/install-wifi | ||
+ | sudo install-wifi | ||
+ | </source> | ||
+ | |||
+ | |||
+ | After running this, I could then see my two wifi adapters listed in ''ifconfig''. To see which one is which you can check the drivers that each one are using: | ||
+ | <source lang="bash"> | ||
+ | readlink /sys/class/net/{!wlan0!}/device/driver | ||
+ | readlink /sys/class/net/{!wlan1!}/device/driver | ||
+ | </source> | ||
+ | |||
+ | In my case I found that the original on-board one showing up as '''wlan1''', and the new one as '''wlan0'''. I figure that it would be best to use the new one as the one that connects wirelessly to the internet router, because it has an external antenna and so probably can reach the router from further away than the on-board one could. The connection details (the router SSID and password) are usually added to the ''/etc/wpa_supplicant/wpa_supplicant.conf'' file to have the wifi adapter automatically connect to the router on boot up. But if we do that then both of the wifi adapters will connect to the router, to have the details in the file only apply to a specific interface, the interface name can be included in the file name - in this case we call the file '''wpa_supplicant{!-wlan0!}.conf. | ||
+ | |||
+ | Now for the internal ''wlan1'' wifi, we want to configure that one as a hotspot. The easiest way to do this for Raspbian is using the ''create-ap'' utility which is covered in the [[hotspot]] page. Once you've gone through the installation of that, you can then configure it in ''/etc/create_ap.conf'', the minimal settings involve setting the interface names and specifying an SSID and password. | ||
+ | <source> | ||
+ | WIFI_IFACE={!wlan1!} | ||
+ | INTERNET_IFACE={!wlan0!} | ||
+ | SSID=PiFi_Extension | ||
+ | PASSPHRASE=MyPwd | ||
+ | </source> | ||
+ | |||
+ | Then I set the hotspot service to start on bootup and rebooted it to test everything was working :-) | ||
+ | <source> | ||
+ | systemctl enable create_ap | ||
+ | </source> | ||
== Pi based projects == | == Pi based projects == | ||
Line 93: | Line 101: | ||
*[https://www.youtube.com/watch?v=irWQYYEUBWk Kano OS] ''- Kids OS for Raspberry Pi'' | *[https://www.youtube.com/watch?v=irWQYYEUBWk Kano OS] ''- Kids OS for Raspberry Pi'' | ||
*[[Charge controller project]] | *[[Charge controller project]] | ||
+ | |||
+ | == Useful links == | ||
+ | *[http://elinux.org/User:Nad My page on eLinux.org] | ||
+ | *[http://learn.adafruit.com/downloads/pdf/reading-a-analog-in-and-controlling-audio-volume-with-the-raspberry-pi.pdf Analog Inputs for Raspberry Pi Using the MCP3008] | ||
+ | *[http://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c How to configure I<sup>2</sup>C] | ||
+ | *[http://www.raspberrypi.org/wp-content/uploads/2012/04/Raspberry-Pi-Schematics-R1.0.pdf RPi schematics] | ||
+ | *[http://elinux.org/RaspberryPiBoard RPi Hub] | ||
+ | *[http://elinux.org/RPi_Tutorials RPi Tutorials] | ||
+ | *[http://log.liminastudio.com/writing/tutorials/tutorial-how-to-use-your-raspberry-pi-like-an-arduino How to use your Raspberry Pi like an Arduino] | ||
+ | *[http://wiringpi.com Wiring Pi] | ||
+ | *[http://tutorial.cytron.com.my/2012/01/10/measuring-tilt-angle-with-gyro-and-accelerometer/ Measuring Tilt Angle with Gyro and Accelerometer] | ||
+ | *[http://elinux.org/RPI-Wireless-Hotspot How to set up a ad-hoc network with the Raspberry Pi] | ||
+ | *[https://medium.com/concerning-pharo/pharo-pi-9eef257b6a21#.ttz36xqz9 Pharo on the Pi] | ||
+ | *[https://www.youtube.com/watch?v=RoYZxaUZues Testing out e-paper options for the Pi] | ||
== Other options == | == Other options == | ||
Line 100: | Line 122: | ||
*[http://makezine.com/2015/11/28/chip-vs-pi-zero/ CHIP vs Pi Zero] | *[http://makezine.com/2015/11/28/chip-vs-pi-zero/ CHIP vs Pi Zero] | ||
*[[Arduino with linux]] | *[[Arduino with linux]] | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== See also == | == See also == |
Revision as of 04:36, 11 October 2019
The Raspberry Pi is a credit-card-sized single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools. The Raspberry Pi is manufactured through licensed manufacturing deals with Element 14/Farnell and RS. Both of these companies sell the Raspberry Pi online.
The Raspberry Pi has a Broadcom BCM2835 system on a chip (SoC), which includes a 700MHz ARM11 processor (The firmware includes a number of "Turbo" modes so that the user can attempt overclocking, up to 1 GHz, without affecting the warranty), VideoCore IV GPU, and was originally shipped with 256 megabytes of RAM, later upgraded to 512MB. It does not include a built-in hard disk or SSD, but uses an SD card for booting and long-term storage. The Foundation's goal is to offer two versions, priced at US$25 and US$35. The Foundation started accepting orders for the higher priced model B on 29 February 2012, and the lower cost model A on 4 February 2013.
The Foundation provides Debian and Arch Linux ARM distributions for download. Also planned are tools for supporting Python as the main programming language, with support for BBC BASIC, C, and Perl. On 17 December 2012 the Raspberry Pi Foundation, in collaboration with IndieCity and Velocix, opened the "Pi Store", as a "one-stop shop for all your Raspberry Pi (software) needs". Using an application included in Raspbian, users can browse through several categories and download what they want. Software can also be uploaded for moderation and release.
Contents
How it came about
The original idea in 2006 was a response to the gradual drop in computing skills seen in students applying for computing degrees at Cambridge. Everyone knew how to use Microsoft Word, PowerPoint, Excel, Access; they didn't know much about coding, though, or what actually happened inside the machine.
Those familiar with schools in the 1980s will know they were full of BBC Micro computers, and everyone learnt how to write programs in BASIC. Computer games back then ran on computers that were practically built for coding, and plenty of amateur enthusiasts now work in the computer science industry. Sadly, as computers have become more complicated, school lessons have changed to train students in simple computer usage, without understanding what goes on underneath. The sheer complexity and expense of computers also means that kids aren't encouraged to fiddle with them, and purpose-built games consoles now dominate where Sinclair ZXs, Amstrads and Commodore Amigas once stood.
Thus, the solution: make a cheap but very capable computer that can be used in classrooms, that can be replaced easily if broken, and that lets you play with computer code whether at school or at home. Make it so it plugs into the TV at home, like computers used to do.
Installation with Raspbian
Raspbian is a Debian variant based on the ARM hard-float (armhf)-Debian architecture port but optimised for the ARM instruction set of the Raspberry Pi hardware. Raspbian provides over 35,000 available deb packages pre-compiled for easy installation on a Raspberry Pi computer, specifically tuned for optimal performance on the Raspberry Pi ARM hardware. The Raspbian distribution basically contains the LXDE desktop environment, the Openbox window manager, the Midori web browser, software development tools and example source code for multimedia functions. Raspbian is a project of a small, dedicated team of developers, and is not affiliated with the Raspberry Pi Foundation.
We use the Raspbian Lite which you can download from here. Lite is stripped down version of Raspbian with other software packages bundled as compared to the usual desktop-oriented Raspbian distribution which is best for headless servers.
Simply write the bootable Raspbian image to your SDcard with your favourite disk utility, and then add an empty file called "ssh" to the root directory of the boot partition which will ensure that youu have ssh access after the system is booted. If you also want to give it some default wifi connection details, add them in a file in the same place called wpa_supplicant.conf with the following format:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
ssid="WiFi_SSID"
psk="WiFi_Password"
}
- Note1: The wpa_supplicant.conf file will be copied into /etc/wpa_supplicant which is where it can be created or modified after the system is up and running.
- Note2: If you'd like the file to apply only to specific interfaces (in the case that you have more than one wifi adapter) you can name the file e.g. wpa_supplicant-wlan1.conf.
Put the card in the Pi and power it up. It will connect to the networks over LAN and/or wifi using DHCP. You can find it's IP with nmap, e.g
nmap -sP 192.168.0.0/24
Here's some example output showing the Pi's information:
Starting Nmap 7.70 ( https://nmap.org ) at 2019-09-17 13:00 -03
Nmap scan report for 192.168.0.1
Host is up (0.0040s latency).
MAC Address: CD:0E:DC:E9:B3:E3 (Cisco Spvtg)
Nmap scan report for 192.168.0.5
Host is up (-0.087s latency).
MAC Address: B8:31:EB:3C:5C:6F (Raspberry Pi Foundation)
Nmap scan report for 192.168.0.14
Host is up.
Nmap done: 256 IP addresses (3 hosts up) scanned in 3.60 seconds
If you want to give it a fixed IP, you can set this up using in your router's DHCP server using the Pi's MAC address. Once you have discovered the Pi's IP you can ssh into it with the default credentials of user name "pi" and password "raspberry". Then you can begin configuring it starting by removing the default password! One very useful thing you may like to do straight away is make your Pi into a wifi hotspot :-)
External drives
Adding external drives to be mounted on boot in the Pi seems to be a bit dodgy sometimes, I've been having problems with transfers of large data freezing after a few minutes and then the drive finally being remounted in read-only. I didn't get the errors from the log unfortunately, but so far I've found nofail,noatime 0 0 seems to give the best results for an external mechanical 2.5" disk (defaults, 0 2 was not good).
This problem was a power supply issue as syslog is showing a lot of under voltage warnings, when using a 1A cellphone charger, I tried a 3.1A "fast charger" from an African on the street which worked a bit better, but still ran nto the same problem. Eventually I found that you need to use an official Raspberry Pi power supply because they have 5.1v output to account for this voltage drop that happens regardless of the current your power supply produces.
One way of making the system less reliant on the SD card is to have it used only for initial booting and then use the external drive for root partition. This is set in the /boot/cmdline.txt file, see this for more detail.
Making a wifi signal extender
In a few AirBnB's we've stayed at recently we've found that the wifi signal is very weak in some parts of the house where we like to use the computers a lot. I decided to make a general purpose solution using a Pi with an extra wifi adapter added via USB. This extra wifi adpater could also be further extended using a 5m USB extension cable in the case of very extreme cases involving concrete walls etc.
It's easiest to get an official wifi module so that you now it's supported by the Pi out of the box, but in my case I already had a USB adapter that was based on the RTL8192EU and took a few hours to get installed. In the end I found these instructions that use this script which worked flawlessly:
sudo wget http://fars-robotics.net/install-wifi -O /usr/bin/install-wifi
sudo chmod +x /usr/bin/install-wifi
sudo install-wifi
After running this, I could then see my two wifi adapters listed in ifconfig. To see which one is which you can check the drivers that each one are using:
readlink /sys/class/net/wlan0/device/driver
readlink /sys/class/net/wlan1/device/driver
In my case I found that the original on-board one showing up as wlan1, and the new one as wlan0. I figure that it would be best to use the new one as the one that connects wirelessly to the internet router, because it has an external antenna and so probably can reach the router from further away than the on-board one could. The connection details (the router SSID and password) are usually added to the /etc/wpa_supplicant/wpa_supplicant.conf file to have the wifi adapter automatically connect to the router on boot up. But if we do that then both of the wifi adapters will connect to the router, to have the details in the file only apply to a specific interface, the interface name can be included in the file name - in this case we call the file wpa_supplicant{!-wlan0!}.conf.
Now for the internal wlan1 wifi, we want to configure that one as a hotspot. The easiest way to do this for Raspbian is using the create-ap utility which is covered in the hotspot page. Once you've gone through the installation of that, you can then configure it in /etc/create_ap.conf, the minimal settings involve setting the interface names and specifying an SSID and password.
WIFI_IFACE=wlan1
INTERNET_IFACE=wlan0
SSID=PiFi_Extension
PASSPHRASE=MyPwd
Then I set the hotspot service to start on bootup and rebooted it to test everything was working :-)
systemctl enable create_ap
Pi based projects
- Set up a wifi hotspot
- CutiePi - all-in-one RaspberryPi tablet
- Onion Pi - TOR on Pi
- Snips - the first Private by Design voice assistant that runs on your Raspberry Pi
- pi-hole - network-wide ad blocking
- Kano OS - Kids OS for Raspberry Pi
- Charge controller project
Useful links
- My page on eLinux.org
- Analog Inputs for Raspberry Pi Using the MCP3008
- How to configure I2C
- RPi schematics
- RPi Hub
- RPi Tutorials
- How to use your Raspberry Pi like an Arduino
- Wiring Pi
- Measuring Tilt Angle with Gyro and Accelerometer
- How to set up a ad-hoc network with the Raspberry Pi
- Pharo on the Pi
- Testing out e-paper options for the Pi
Other options
- Banana Pi
- Other more powerful options for a similar cost
- Another tiny computer
- CHIP vs Pi Zero
- Arduino with linux
See also
- Raspberry Pi Foundation
- Introducing the Raspberry Pi
- Quake III bounty: we have a winner!
- Jetson TK1 Development Kit
- Installing Ethereum on the Raspberry Pi - see also Ethereum
- Raspberry Pi Zero: the $5 computer
- Headless Pi
- Some bad points about the Pi
- Software solution to harden against spontaneous power loss
- Hardware solution to harden against spontaneous power loss
- Exploring The Raspberry Pi 4 USB-C Issue In-Depth
- Backing up and restoring the SDcard