- This code works with
Raspberry Pi 3
withJessie 8 Lite OS
- Install newest
node
andnpm
(at time of writing this text version 8.2.1 of node and version 5.3 of npm was avaliable)curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.bashrc
nvm install stable
- Test the installation with
node -v
andnpm -v
- Update system with
sudo apt-get update
and thensudo apt-get upgrade
(without it next step may not work) - Install
mpc
andmpd
(sudo apt-get install mpc mpd
) - Add some radio station (for example from https://www.internet-radio.com/stations/chillout/; open any .pls file and find station url) to music player:
mpc add https://www.internet-radio.com/stations/chillout/
and test it withmpc play
- Install
git
withsudo apt-get install git -y
- Clone this repo to Raspberry Pi machine (
git clone https://github.com/tBlabs/RaspberryPiDemo.Machine
) - Create manually
.env
file. AddHOST={url of server side}
entry (copy link directly from browser address bar) - Run
npm i
to installnode_modules
- In case of any problems run
npm rebuild
. If rebuild will hang on this kind of message:make: Warning: File '../../../../.node-gyp/8.2.1/include/node/common.gypi' has modification time 1219765 s in the future ACTION Regenerating Makefile
update system clock withsudo sntp -s time.google.com
- Execute main script (
machine.js
) without sudo permissions (GPIO will not start withsudo
) or add entry./startup.sh
to.bashrc
file
- Connect led to GPIO 17
- Test led by running test script
node gpiotest.js
- Connect speakers to audio output
- Test speakers with
mpc volume 100 && mpc play
- Set
HOST
in.env
file to localhost (ex.http://localhost:3000
) node machine.js
- You can see comunication results in console
- Download
Jessie Lite
from https://www.raspberrypi.org/downloads/raspbian/ - Burn OS image with
Etcher
https://www.raspberrypi.org/documentation/installation/installing-images/README.md - Put SD card to Raspberry and power on
- Login with
pi
andraspberry
password - Open config with
sudo raspi-config
- In
Boot Options
selectDesktop / CLI
and thenConsole Autologin
- In
Interfacing Options
enable SSH if you gonna use it Change User Password
andHostname
topi
if you like- Switch to "normal keyboard layout" with
sudo nano /etc/default/keyboard
and changeXKBLAYOUT="gb"
onXKBLAYOUT="us"
. Exit nano withCtrl+X
and thenY
and thenEnter
(^X
=Ctrl+X
) - Reboot with
sudo reboot
- Enable wifi by adding entry to
/etc/wpa_supplicant/wpa_supplicant.conf
at the end:network={<new line><tab>ssid="<network name>"<new line><tab>psk="<password>"<new line>}
- Reboot again
- Test internet connection with
ping www.wp.pl
. Interrupt withCtrl+C
- Now Raspberry is ready to action :)
- In command line write
hostname -I
to obtain Raspberry IP - Enable SSH (if you didn't already):
sudo raspi-config
>Interfacing Options
> enable SSH
- Use obtained IP with command
ssh pi@<raspberry IP>
- Enter password
pi
- You can now control your Raspberry from your terminal
- Exit with
exit
command