Raspberry Pi Robotics WiFi Configuration and Web Interface ---------------------------------------------------------- Andrew Davison, Jan Czarnowski, Duncan White, Jacek Zienkiewicz, Lukas Platinsky, Jan Jachnik, Stefan Leutenegger 2014--2019 WiFi Setup ---------- 1. Insert the MicroSD card in the Raspberry Pi, connect a USB keyboard, and connect the Raspberry Pi to a display with the provided HDMI-DVI cable. Using the Y-cable, power the BrickPi up by plugging in the wall charger. You should also immediately plug your battery into the other Y-cable port to start charging. 2. The Raspberry Pi should now boot. Login (username: pi, password: raspberry), and IMMEDIATELY change the password (using the command: passwd) to a stronger password that only you and your group members know (this should NOT be a student's Imperial password). 3. Setup WiFi: type: "sudo bash setup_wifi.bash" (with no quotation marks) to run our WiFi setup script which is in the home directory. It will ask you to input the username and college password and one student in your group should do this. Note that this password will be stored in a hashed form on the Raspberry Pi so other group members are not able to see the password. However, please note that when you connect to WiFi from this Raspberry Pi it will be via that person's login credentials so please observe all of the usual rules with regard to proper use of the college network (all actions are traceable to that account!) 4. Run "ifconfig wlan0" and you should see information on your IP address (a numerical code of the format ***.***.***.***) to confirm that you have successfully connected to WiFi. Also here you will see the MAC address of your Raspberry Pi (this is listed under "ether" and is a hexadecimal code of the format **:**:**:**:**:** which is the unique identifier of your RPi's WiFi chip). Note this down because you can use it later to connect to your Pi. (To explain, because your Pi connects to the college network with DHCP, it gets a dynamically allocated IP address each time. We have a cron job on your Pi which publishes your Pi's current IP address to a database on the college network, and then a script which enables you to connect to your Pi via the MAC address without having to always check the IP address). 5. Try to ssh your Raspberry Pi from a lab PC using the command: "ssh pi@IP_ADDRESS" with the IP address you detected, entering the strong password you chose back in (2) to log in. 6. If that works, log-out and try "ssh-pi MAC_ADDRESS" instead from a lab PC, which uses our database which links the MAC address to your current IP address. 7. You can test running programs on your RPi remotely via now; when you are logged onto your RPi via ssh you can cd to a directory with programs and run them. Refer to the practical sheet for details. Web Interface ------------- Once you have WiFi working, you can set up our web explorer interface (based on nodejs), which is an alternative way to interace with your RPi which is very convenient, and will be particularly important later in term when we can use it to draw real-time graphics from your programs. It is a web server which runs on your Raspberry Pi so that you can connect to your robot from any web browser (e.g. on a laptop, tablet or smartphone), and run, edit and see output from your programs from there. 1. To configure the web server, on your Raspberry Pi, type "sudo bash setup_explorer.bash" in the home directory to run our setup script. Enter a password when prompted, which could be the same one as you used for your Raspberry Pi earlier or something different (NOT an individual student's Imperial password). This is the password that your group can use to connect to your Raspberry Pi's web server with a browser-based python editor. 2. Once the installation is complete, you should be able to connect to the Raspberry Pi at port 9000 from any web browser. Just go to http://YOUR_RASPBERRY_PI_IP:9000, e.g. http://129.31.209.7:9000/. Enter "pi" as the username and the password you have chosen to access the site. 3. There is an easier way to use the web interface, which is to browse to https://www.doc.ic.ac.uk/~ajd/robotics/ and enter the MAC address of your Raspberry Pi. The website will provide a link to connect straight through to your Raspberry Pi. Note that this website is only accessible if you are on the College network --- if you are using a phone or tablet, it must be connected to the Imperial-WPA WiFi network. It may ask for your college login details. If it finds your MAC address in the database it checks that you have a running web-server. If so a link will appear to forward you right through. 4. The web interface includes a Python editor will allow you to edit and run python scripts on your robot. In your browser you can now upload some Python files and they will appear on the left. You can run them by clicking on the file name. These files can be found in ~/prac-files directory on your Raspberry Pi. While on the Pi, you can also copy the files into the ~/prac-files directory and they should be automatically accessible via the web-browser. 5. Please, when you have finished with the keyboard, mouse and screen you have used with your Raspberry Pi, reconnect them to the lab machine they came from so it is ready for the next student.