In this documentation, we will use the terminal to perform some command lines. Here, every command will be prefixed by $.
In your favorite terminal (for Mac we advice you to get iTerm2, for linux the default terminal with ohmyzsh)
$ cd ~ # tilde means home
$ git clone git@github.com:Tactyk/arbreole.git # retrieve code
$ cd arbreole # cd: change directory
$ ./setup.sh # Set up ip address and port
You can see now the project structure in your 'arbreole' folder
$ ls # list the current folder
The _doc
folder contains more informations about the technologies used in this project.
The arduino
folder contains the code related to manipulating the leds and the sounds.
The client
folder contains the webSocket client hosted on the Raspberry Pi.
The config
folder contains configuration data, which can be edited by hand but is meant to be auto-generated by setup.sh
.
The interface
folder contains the code used in the web client.
The scripts
folder contains scripts used to update the RaspberryPi.
The server
folder contains the web server interacting with the RaspberryPi and web clients.
-
Download and install PyCharm Community Edition
-
Configuration:
Preferences > Project > Project Interpreter >
- Format your SD Card
- Follow this link to initialize the Raspberry Pi (use the Raspbian Stretch LITE image)
- The default login / password is: pi / raspberry
-
First enable the ssh on your rPi by following this link
-
Make sure that your rPi and your computer are connected to the same network (via direct ethernet cable or WIFI dongle).
- If you have a WIFI Dongle, follow this link to configure it
- If you don't have a router, you can share your computer's Ethernet connection, see:
-
From your computer you should now be able to connect to your raspberryPi via ssh.
- For Windows environment, use putty as a ssh client
$ ssh pi@raspberry.local
pi
is the rPi userraspberry
is the rPi hostnameraspberry.local
is the rPi host address- The default password for the pi user is: raspberry
Follow this link if you want to change the rPi hostname
In this project, we use python3. In order to install python3 packages, use the pip3 packages installer. It should be already in rPi but nevertheless:
-
SSH into your pi, then
$ sudo apt-get update # Update packages $ sudo apt-get install python3-pip # Install pip3 and python3 $ pip3 install websocket-client pyserial tinydb # Install packages
To communicate with the server, we will use websockets, with the websocket-client library.
Each module will be recognize by your IDE (PyCharm or other) because it knows the PYTHONPATH global environment var. If you needed to put modules in a special folder. You should add its path to PYTHONPATH var to avoid errors in your IDE:
$ export PYTHONPATH="${PYTHONPATH}:/my/other/path"
-
In your machine from your project root folder (arbreole/), execute the following script to copy the raspberry :
$ ./scripts/deploy_raspberry_pi.sh pi raspberrypi.local #raspberrypi.local is the rPi host address
It may ask you for the rPi password (default = raspberry)
In order to have a Python Webserver and an easy websocket usage, we're going to use the python Tornado framework.
In your machine:
-
Prerequisites are same than for rPi session.
-
Install tornado for your web server and tinydb to handle module states:
$ pip3 install tornado tinydb
Everything is now installed !
To run the local webserver, go to your project folder and type
python3 ./server/webserver.py
You should see something along the lines of Server listening on ip: 192.168.1.20 at port 8080
.
In your browser, got o http://{host-ip}:{host-port}/
to see the interface page.
A first client is now connected to the server via websocket.
NB: Open the developer console tool to see logs for debugging. (Right click > inspect > Console tab)
SSH into the RaspberryPi and run
$ cd arbreole/src
$ python3 webSocketClient.py
you should see Server connection opened
in your rPi terminal side and New connection
at the server host side terminal.
Everything is now connected by websocket. Try to add a text in your web client, enter and see every logs in terminal/console.
-
Plug the router antenna and turn on the TP-link router.
-
Wait a few minutes and connect your computer to the router WIFI:
- WifiId:
Arbreole
- pwd:
tiepstieps
- WifiId:
-
The router dashboard is reachable with the address: http://tplinkwifi.net/ or http://192.168.0.1/
- The admin password is:
tieps
- In the dashboard
basic
tab, you should see the number of connected client (wired and wireless).
- The admin password is:
-
To connect the raspberry pi to the router, follow this link: https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md
You can find some useful scripts into ./scripts/ folder. To run it, from your project root folder, type ./scripts/{script-name}.sh
./scripts/deploy_raspberry.sh
: deploy the local client code to all the raspberry pis./scripts/deploy_raspberry.sh pi raspberry.local
: deploy the local client code to pi@raspberry.local
If you want to add your code to the project, submit a Pull Request. Please follow the instructions here
- TroubleShootings - Import not recognize
- Open one folder at once with PyCharm