{"id":16366774,"url":"https://github.com/jeff1evesque/raspberry-pi","last_synced_at":"2025-03-23T02:32:43.564Z","repository":{"id":22691758,"uuid":"26035598","full_name":"jeff1evesque/raspberry-pi","owner":"jeff1evesque","description":"Raspberry Pi connects ZigBee wireless devices to an apache server.","archived":false,"fork":false,"pushed_at":"2017-01-28T15:22:41.000Z","size":72,"stargazers_count":6,"open_issues_count":18,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-01T20:45:24.227Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeff1evesque.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-31T22:46:10.000Z","updated_at":"2022-09-25T23:55:37.000Z","dependencies_parsed_at":"2022-08-17T16:55:25.473Z","dependency_job_id":null,"html_url":"https://github.com/jeff1evesque/raspberry-pi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeff1evesque%2Fraspberry-pi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeff1evesque%2Fraspberry-pi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeff1evesque%2Fraspberry-pi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeff1evesque%2Fraspberry-pi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeff1evesque","download_url":"https://codeload.github.com/jeff1evesque/raspberry-pi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244263385,"owners_count":20425312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T02:47:31.991Z","updated_at":"2025-03-23T02:32:43.289Z","avatar_url":"https://github.com/jeff1evesque.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Raspberry Pi\n============\n\n###Definition\n\nThe [Raspberry Pi](http://en.wikipedia.org/wiki/Raspberry_Pi) is a credit-card sized computer containing at least 1 USB slot, which can be used for any USB device containing a [linux](http://en.wikipedia.org/wiki/Linux) driver.  Since the inception of the Raspberry Pi ([model A](http://www.raspberrypi.org/products/model-a/)) in February 2012, there have been two additional models made available, the [model B](http://www.raspberrypi.org/products/model-b/), and the [model B+](http://www.raspberrypi.org/products/model-b-plus/).\n\nThe major schematic are as follows:\n\n                | Model A       | Model B       | Model B+       | Model 3B       | Model Zero     |\n---------------:| --------------|:-------------:|:--------------:|:--------------:| --------------:|\n**Processor**   | 700 MHz       | 900 MHz       | 700 MHz        | 1.2 GHz        | 1 GHz          |\n**RAM**         | 256 MB        | 1 GB          | 512 MB         | 1 GB           | 512 MB         |\n**USB Ports**   | Single USB    | Quad USB      | Quad USB       | Quad USB       | Double Micro   |\n\n**Note:** one of the [micro usb](https://learn.adafruit.com/introducing-the-raspberry-pi-zero/a-tour-of-the-pi-zero#usb-port) ports,\n on the [model zero](https://learn.adafruit.com/introducing-the-raspberry-pi-zero), is required for a power source.\n\nNumerous [*linux-based*](http://en.wikipedia.org/wiki/Linux) operating systems can be run on the [Raspberry Pi](http://en.wikipedia.org/wiki/Raspberry_Pi). The [Rasbian](http://www.raspbian.org/) is generally preferred, since it is tailored specific to the Pi.  Other operating systems such as [Risc](https://www.riscosopen.org/), [Plan 9](http://plan9.bell-labs.com/plan9/), [Android](http://www.android.com/), and [Arch](http://arch-os.com/) is just as savy.  Though, not recommended, linux distributions such as [Ubuntu](www.ubuntu.com) will work.  Keep in mind, the requirements of such operating systems tend to require more resources than the Pi has to offer (so grab an older distro).\n\n###Overview\n\n##Installation\n\n###Linux Packages\n\nThe following packages need to be installed through terminal:\n\n```\n# Update / GIT Core\nsudo apt-get update\nsudo apt-get install git-core\n\n# Python Package Manager:\nsudo apt-get install python-setuptools\nsudo easy_install pip\n\n# LAMP (with phpmyadmin):\nsudo apt-get install apache2\nsudo apt-get install mysql-server mysql-client\nsudo apt-get install php5 php5-mysql libapache2-mod-php5\nsudo apt-get install phpmyadmin\n\n# Python MariaDB / MySQL Connector:\nsudo apt-get install python-mysqldb\n\n# FTP\nsudo apt-get install vsftpd\n```\n\n**Note:** This project assumes [Raspbian](http://www.raspbian.org) (i.e. [Wheezy](http://raspberrypi.org/debian-wheezy-public-beta/)) as the operating system. To upgrade to the newer [Jessie](http://www.raspberrypi.org/forums/viewtopic.php?f=66\u0026t=47944) distribution, modify the following:\n\n```\nsudo pico /etc/apt/sources.list\n```\n\nby changing any reference(s) of [`wheezy`](http://www.raspberrypi.org/debian-wheezy-public-beta/) to [`jessie`](http://www.raspberrypi.org/forums/viewtopic.php?f=66\u0026t=47944). Then, upgrade the distribution:\n\n```\nsudo apt-get dist-upgrade\n```\n\nThe above *upgrade* would allow the use of [MariaDB](https://mariadb.org), in place of its predecessor [MySQL](http://www.mysql.com). Therefore, the above:\n\n```\n...\nsudo apt-get install mysql-server mysql-client\n...\n```\n\nwould be replaced by the following:\n\n```\n...\nsudo apt-get install mariadb-server mariadb-client\n...\n```\n\n##Configuration\n\n###SD Boot Partition\n\nThe [SD Card](http://en.wikipedia.org/wiki/Secure_Digital) is an important and integral part of the [Raspberry Pi](http://en.wikipedia.com/wiki/Raspberry_Pi). When a [power supply](http://www.raspberrypi.org/help/faqs/#power) is provided, the Raspberry Pi seeks a [boot loader](http://en.wikipedia.org/wiki/Booting#BOOT-LOADER) [partition](http://en.wikipedia.org/wiki/Disk_partitioning) from its SD Card slot. If either the SD Card, or boot loader partition is absent, the Raspberry Pi will not start-up.\n\nTo ensure the presence of a *boot loader* partition, an acceptable [linux distribution](http://en.wikipedia.org/wiki/Linux_distribution) [image](http://www.raspberrypi.org/documentation/installation/installing-images/) must be placed on the SD Card. The following are the necessary steps to add the Raspbian ([Wheezy](http://www.raspberrypi.org/debian-wheezy-public-beta/)) image:\n\n```\n# create temporary directory\n$ sudo mkdir /raspbian/\n$ cd /raspbian/\n\n# install 'Raspbian' image (not on SD card)\n$ sudo wget -P /raspbian/ http://downloads.raspberrypi.org/raspbian_latest\n$ ls\nraspbian_latest\n$ sudo unzip raspbian_latest\n$ ls\n2014-09-09-wheezy-raspbian.img          raspbian_latest\n\n# get partition listing\n$ diskutil list\n/dev/disk0\n   #:                       TYPE NAME                    SIZE       IDENTIFIER\n   0:      GUID_partition_scheme                        *1.0 TB     disk0\n   1:                        EFI EFI                     209.7 MB   disk0s1\n   2:                  Apple_HFS Macintosh HD            999.3 GB   disk0s2\n   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3\n/dev/disk1\n   #:                       TYPE NAME                    SIZE       IDENTIFIER\n   0:     Apple_partition_scheme                        *27.9 MB    disk1\n   1:        Apple_partition_map                         32.3 KB    disk1s1\n/dev/disk2\n   #:                       TYPE NAME                    SIZE       IDENTIFIER\n   0:     FDisk_partition_scheme                        *7.8 GB     disk2\n   1:                 DOS_FAT_32 SD-RPI                  7.8 GB     disk2s1\n\n# copy 'Raspbian' image to SD card\n$ sudo diskutil unmountDisk /dev/disk2\n$ sudo dd if=2014-09-09-wheezy-raspbian.img | sudo pv | sudo dd of=/dev/rdisk2 bs=1m\n6400000+0 records in6MiB/s] [                                                             \u003c=\u003e   ]\n6400000+0 records out\n3276800000 bytes transferred in 248.722375 secs (13174528 bytes/sec)\n3.05GiB 0:04:08 [12.6MiB/s] [                                                              \u003c=\u003e  ]\n0+50020 records in\n0+50020 records out\n3276800000 bytes transferred in 248.744377 secs (13173363 bytes/sec)\n\n# delete temporary directory\n$ sudo rm -rf /raspbian/\n```\n\n**Note:** [`dd`](http://linux.die.net/man/1/dd) *may* take up to [`20mins`](http://www.raspberrypi.org/forums/viewtopic.php?f=66\u0026t=21995#p309093), with [`pv`](http://linux.die.net/man/1/pv) displaying a [transfer rate](http://en.wikipedia.org/wiki/Data_rate_units) between `3.9-5.23MiB/s`. For example, when using [Dane-Elec](http://www.newdane.com/?page_id=1255) (Class 4), the [transfer rate](http://en.wikipedia.org/wiki/Data_rate_units) is about 11 minutes. This is reasonable, since the SD card is expected to have a minimum [transfer rate](http://en.wikipedia.org/wiki/Data_rate_units) of 4MiB/s.  However, a [SanDisk](http://www.sandisk.com/products/memory-cards/sd/) with 48MiB/s capacity would write the Raspbian image in roughly 4 minutes (as shown above).\n\n**Note:** if `bs=1m` was included *only* before the first pipe, or excluded entirely from the command, the [transfer rate](http://en.wikipedia.org/wiki/Data_rate_units) could vary between `660-740KiB/s` ([Dane-Elec](http://www.newdane.com/?page_id=1255), Class 4), or roughly 8x slower.\n\n**Note:** if `sudo dd of=/dev/disk2` was used instead of `sudo dd of=/dev/rdisk2`, the [transfer rate](http://en.wikipedia.org/wiki/Data_rate_units) could be `1MiB/s` ([Dane-Elec](http://www.newdane.com/?page_id=1255), Class 4), or roughly 5x slower.\n\n###USB System Partition\n\nThe system partition is the disk partition that contains the [operating system](http://en.wikipedia.org/wiki/Operating_system) folder, known as system root. By default, in Linux, operating system files are mounted at `/` (the [root directory](http://en.wikipedia.org/wiki/Root_directory)).\n\n- http://en.wikipedia.org/wiki/System_partition_and_boot_partition#Common_definition\n\nThe Raspberry Pi requires the *boot loader* partition to be located on the SD card. However, the *system partition* can be stored on any another medium, such as the USB flash drive.\n\nThe steps required to install a system partition on a USB flash drive, is similar to the earlier configured *boot partition* on the SD card. Plug in the USB flash drive to a computer, format the drive to `MS-DOS (FAT)`, then open up terminal:\n\n```\n$ diskutil list\n/dev/disk0\n   #:                       TYPE NAME                    SIZE       IDENTIFIER\n   0:      GUID_partition_scheme                        *500.1 GB   disk0\n   1:                        EFI EFI                     209.7 MB   disk0s1\n   2:                  Apple_HFS Macintosh HD            499.2 GB   disk0s2\n   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3\n/dev/disk3\n   #:                       TYPE NAME                    SIZE       IDENTIFIER\n   0:     FDisk_partition_scheme                        *3.9 GB     disk3\n   1:             Windows_FAT_32 boot                    58.7 MB    disk3s1\n   2:                      Linux                         3.2 GB     disk3s2\n/dev/disk4\n   #:                       TYPE NAME                    SIZE       IDENTIFIER\n   0:     FDisk_partition_scheme                        *64.0 GB    disk4\n   1:                 DOS_FAT_32 USB-RPI-1               64.0 GB    disk4s1\n$ sudo diskutil unmountDisk /dev/disk4\nUnmount of all volumes on disk4 was successful\n$ sudo dd if=2014-09-09-wheezy-raspbian.img | sudo pv | sudo dd of=/dev/rdisk4s1 bs=1m\n6400000+0 records in7MiB/s] [                                                                    \u003c=\u003e]\n6400000+0 records out\n3276800000 bytes transferred in 650.785056 secs (5035149 bytes/sec)\n3.05GiB 0:10:50 [ 4.8MiB/s] [                                                                  \u003c=\u003e  ]\n0+50007 records in\n0+50007 records out\n3276800000 bytes transferred in 650.881670 secs (5034402 bytes/sec)\n```\n\nOnce the USB flash drive contains a system partition, specifically the *Raspbian* operating system, the boot loader partition on the SD card, needs to know where this system partition is located. In terminal, open `cmdline.txt` from the earlier configured SD Card (boot partition):\n\n```\ncd /Volumes/boot/\nsudo pico cmdline.txt\n```\n\n**Note:** on linux distributions, navigate to `/media/boot/` subdirectory to modify `cmdline.txt`.\n\nNext, modfiy the contents of `cmdline.txt`:\n\n```\ndwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait\n```\n\nby changing the `root` variable as follows:\n\n```\ndwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/sda2 rootfstype=ext4 elevator=deadline rootwait\n```\n\nThis modifies the boot sequence, and tells the Raspberry Pi to boot the system partition from the USB flash drive, instead of the SD card. By default, the earlier configured SD card would boot the existing Raspbian operating system already on it. Now, after the Raspberry Pi has booted, the SD card could be removed, or unmounted. This means, the SD card is only needed during the initial boot.\n\n###SSH Server\n\n[Secure Shell](http://en.wikipedia.org/wiki/Secure_Shell) (SSH), sometimes known as *Secure Socket Shell*, is a [network protocol](http://en.wikipedia.org/wiki/Network_protocol) which allows a client to remotely connect to a host machine over a [secure channel](http://en.wikipedia.org/wiki/Secure_channel). This secure channel, many times over an insecure network, allows the client to run various commands on the designated host machine.\n\nTo enable the SSH protocol on the Raspberry Pi, enter the following in terminal:\n\n```\n$ sudo raspi-config\n```\n\nScroll down to the *ssh* option, `Enable or disable ssh server`, hit enter, and select `Enable`.\n\n###FTP Server\n\nA [file transfer protocol](http://en.wikipedia.org/wiki/File_Transfer_Protocol) (FTP) can be used to transfer files from one [host](http://en.wikipedia.org/wiki/Host_(network)), to another host machine over a [TCP](http://en.wikipedia.org/wiki/Transmission_Control_Protocol)-based network (i.e. [internet](http://en.wikipedia.org/wiki/Internet)). Specifically, the raspberry pi can be enabled with an FTP server. This would allow files to be exchanged with other machines.\n\nTo enable an FTP server on the raspberry pi, the file `vsftpd.conf` must be edited:\n\n```\n$ sudo pico /etc/vsftpd.conf\n```\n\nSpecifically, the following lines need to be changed:\n\n- `anonymous_enable=YES` to `anonymous_enable=NO`\n- `#local_enable=YES` to `local_enable=YES`\n- `#write_enable=YES` to `write_enable=YES`\n\nThen, `force_dot_files=YES` must be added to the bottom of the file, before restarting the FTP server:\n\n```\n$ sudo service vsftpd restart\n```\n\n###GIT\n\nSince we installed GIT earlier, we have to remember to configure our GIT user.  Only change the values within the double quotes (remove the quotes for the email):\n\n```\ngit config --global user.email \"YOUR-EMAIL@DOMAIN.COM\"\ngit config --global user.name \"YOUR-NAME\"\n```\n\nFork this project in your GitHub account, then clone your repository:\n\n```\ncd /var/www/html/\nsudo git clone https://[YOUR-USERNAME]@github.com/[YOUR-USERNAME]/raspberry-pi.git [PROJECT-NAME]\n```\n\nThen, change the *file permissions* for the entire project by issuing the command:\n\n```\ncd /var/\nsudo chown -R jeffrey:sudo www\n```\n\n**Note:** change 'jeffrey' to the user account YOU use.\n\nThen, add the *Remote Upstream*, this way we can pull any merged pull-requests:\n\n```\ncd /var/www/html/raspberry-pi/\ngit remote add upstream https://github.com/[YOUR-USERNAME]/raspberry-pi.git\n```\n\n####GIT Submodule\n\nWe need to initialize our git *submodules*:\n\n```\nsudo git submodule init\nsudo git submodule update\n```\n\nThe above two commands will update submodules within the cloned repository, according to the versioned master branch. If they are already initialized in the cloned repository, then the latter command will suffice.\n\nThe following updates submodule(s):\n\n```\ncd /var/www/html/raspberry-pi/\ngit checkout -b NEW_BRANCH master\ncd [YOUR_SUBMODULE]/\ngit checkout master\ngit pull\ncd ../\ngit status\n```\n\nto the latest code-base, within the cloned repository branch, `NEW_BRANCH`.\n\n###Static IP\n\nBy default, the Raspberry Pi is assigned a [dynamic IP](http://en.wikipedia.org/wiki/IP_address#Uses_of_dynamic_address_assignment) address. This means, each time the raspberry pi boots up, a new IP address is assigned to it. Many times, however, it is more useful to have a fixed, [static IP](http://en.wikipedia.org/wiki/IP_address#Uses_of_static_addressing) address.\n\nThe first step to acquiring a *static ip* is to list the [network interface](http://en.wikipedia.org/wiki/Network_interface) currently available:\n\n```\n$ cat /etc/network/interfaces\nauto lo\n\niface lo inet loopback\niface eth0 inet dhcp\n\nallow-hotplug wlan0\niface wlan0 inet manual\nwpa-roam /etc/wpa_supplicant/wpa_supplicant.conf\niface default inet dhcp\n```\n\nThe line that reads `iface etho0 inet dhcp`, specifically `dhcp`, indicates that the [IP address](http://en.wikipedia/org/wiki/IP_address) is being dynamically created by the [router](http://en/wikipedia.org/wiki/Router_%28computing%29).\n\nNow, more information on the router is needed:\n\n```\n$ ifconfig\neth0      Link encap:Ethernet  HWaddr b8:27:eb:09:af:96\n          inet addr:192.178.71.179  Bcast:192.178.1.255  Mask:255.255.255.0\n          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1\n          RX packets:461 errors:0 dropped:0 overruns:0 frame:0\n          TX packets:492 errors:0 dropped:0 overruns:0 carrier:0\n          collisions:0 txqueuelen:1000\n          RX bytes:42776 (41.7 KiB)  TX bytes:332384 (324.5 KiB)\n\nlo        Link encap:Local Loopback\n          inet addr:127.0.0.1  Mask:255.0.0.0\n          UP LOOPBACK RUNNING  MTU:65536  Metric:1\n          RX packets:33 errors:0 dropped:0 overruns:0 frame:0\n          TX packets:33 errors:0 dropped:0 overruns:0 carrier:0\n          collisions:0 txqueuelen:0\n          RX bytes:2592 (2.5 KiB)  TX bytes:2592 (2.5 KiB)\n```\n\nThe following from above are important:\n\n```\neth0      Link encap:Ethernet  HWaddr b8:27:eb:09:af:96\n          inet addr:192.178.71.179  Bcast:192.178.1.255  Mask:255.255.255.0\n```\n\nSpecifically, these values:\n\n```\ninet addr - 192.178.71.179\nBcast     - 192.178.1.255\nMask      - 255.255.255.0\n```\n\nAlso, two additional pieces of information are needed:\n\n```\n$ netstat -nr\nKernel IP routing table\nDestination     Gateway         Genmask         Flags   MSS Window  irtt Iface\n0.0.0.0         192.168.1.254   0.0.0.0         UG        0 0          0 eth0\n192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0\n```\n\nSpecifically, the values:\n\n```\nGateway     - 192.168.1.254\nDestination - 192.168.1.0\n```\n\nFinally, plug the determined values into the Raspberry Pi's network configuration file:\n\n```\n$ sudo pico /etc/network/interfaces\n```\n\nSpecifically, change the line that reads:\n\n```\niface eth0 inet dhcp\n```\n\nto the following:\n\n```\niface eth0 inet static\n```\n\nThen, add the values found earlier directly below it:\n\n```\naddress 192.178.71.179\nnetmask 255.255.255.0\nnetwork 192.168.1.0\nbroadcast 192.178.1.255\ngateway 192.168.1.254\n```\n\nFinally, reboot the machine:\n\n```\n$ sudo reboot\n```\n\n**Note:** check `ifconfig` as needed, to see if the above changes are reflected. If not, most likely a typo needs to be fixed.\n\n##Testing / Execution\n\n###Test Scripts\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeff1evesque%2Fraspberry-pi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeff1evesque%2Fraspberry-pi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeff1evesque%2Fraspberry-pi/lists"}