This project will demonstrate how to web-scrape and display the Seattle to Bainbridge ferry's location, schedule and "Did you know?" facts by using Qt, C++ and Python3 to communicate with a GUI.
Putting the Image onto the SD card
1. Download the .sdcard image for the PHERRY on your linux machine or linux virtual machine from the PHYTEC ftp server using the following link:
2. Transfer the downloaded image to an SD card.
A. Connect an SD card reader to your linux machine and plug in your SD card.
B. Open a terminal and execute ls /dev with and without the SD card connected to determine the device name of the SD card (Usually will be sdb, sdc, or sde, etc.).
Host PC: ls /dev
C. Once the correct device has been determined, unmount that partition by using the umount command below.
Host PC: umount /dev/<name of your device>*
D. Proceed by using the dd command to transfer the image to the SD card.
Host PC: sudo dd if=Downloads/pherry-phycore-imx6ull.sdcard of=/dev/<name of your device > bs=1MB conv=fsync
E. You should now have a bootable SD card. Now it's time to execute the demo!
Setting up the Hardware
With your new SD card you can run the PHERRY demo on your phyBOARD-i.MX6ULL Segin board.
3. Set up the phyBOARD-i.MX6ULL Segin board with an Ethernet cable, your SD card, a 12V power supply (plug in last), and the 7 inch display. Your setup should look similar to the following diagram:
B. Plug in your 12V power supply and wait for the board to boot
C. Wait for the boot to finish and the display should bring up the PHERRY demo! Demo could take 10 seconds to present content.
D. The application code for running this demo is located in a startup script that will be covered in the "Understanding the Start-up Script" section.Features and Development
Optional features include steps for the housing enclosure, a LED that flashes when the ferry is in dock at Bainbridge, an easy access reset button, how to create startup scripts, and connect to WiFi.
Note: If you would like to develop on this demo you will need a serial connection between the board and your host PC, as well as, a terminal emulator such as TeraTerm to communicate from your host PC to the board. If there is any confusion on how to communicate with the hardware refer to the following quickstart guide: https://www.phytec.de/fileadmin/user_upload/downloads/Manuals/L-840e_3_web.pdf
1. Download 3D image files
2. Program 3D Printer
- ~20hr of printing.
1. Ensure that the breadboard is small enough to fit within the enclosure.
2. Solder the LED, 390 ohm resistor, and 2 of the M/M wires to the breadboard
A. Connect one of the wires onto the D2 LED path by removing the resistor beside D2 and solder the wire’s end to the side of the D2 LED.
By depopulating the resistor you create a place for your LED to connect to D2’s path. D2 is a pre-exported path, allowing you to skip a couple steps. Additionally, by drawing power from 5V rather than the 3.3V you can produce a brighter LED. The path D2 was on had a transistor. That transistor will allow you to pull 5V from the expansion board’s power rail and not burn out the 3.3V GPIO input signal D2 LED was connected to.
B. Solder the other wire on the breadboard to pin 2 on the expansion board. This will connect the LED to a 5V power rail.
Note: The application for the LED is included in the demo image downloaded earlier and can be found in the GitHub repository page under led.py. There is also a startup script for implementing the LED that can be enabled using the following:
Target: systemctl enable led.service
1. Solder the remaining 2 M/M wires to the reset button.
A. Solder one wire to pin 43 on the expansion board.
This will connect the button to the “nResetIN” signal. This signal is connected to the same path the “Reset” button on the board is on. Allowing you to piggyback off of that path.
B. Complete the circuit by soldering the other wire to GND, pin 59, on the expansion board.
Connecting to WiFi (Requires Serial Connection)
1. Connect the WiFi module to the expansion board .
(More information on this can be found at this link-https://www.phytec.de/fileadmin/user_upload/downloads/Manuals/LAN-076e_1.pdf)
2. Connect to a wireless network.
- Set regulatory domain for country:
Target: iw reg set US
- Check regulatory domain:
Target: iw reg get
- Set up wireless interface.
Target: ip link
Target: ip link set up dev wlan0
- Scan available networks.
Target: iw wlan0 scan | grep SSID
3. Set credentials for WiFi and establish connection.
- Add the credentials to a wpa_supplicant.conf file.
Target: vi /etc/wpa_supplicant.conf
- Add the text, seen below, into your new wpa_supplicant. conf file with your respective credentials for the ssid and password.
- Establish connection.
Target: wpa_supplicant -Dnl80211 -c/etc/wpa_supplicant.conf -iwlan0 &
- Restart system daemon.
Target: systemctl restart systemd-networkd
- Reboot the system.
- Reconnect to the WiFi.
Target: wpa_supplicant -Dnl80211 -c/etc/wpa_supplicant.conf -iwlan0 &
- Ping a website, such as google to verify connection.
Target: ping google.com
Note: There is a start-up script that will automatically enable your WiFi if you have completed these previous steps and enabled the "enablewifi.service".
To enable the start-up script simply use the following:
Target: systemctl enable enablewifi.service
Understanding the Start-up Script Using the PHERRY as an Example(Requires Serial Connection)
On the SD card image containing the PHERRY demo there are three services that run from boot. There are services for WiFi, the ferry tracker demo, and the LED. The LED and ferry tracker demo services come enabled by default, allowing for the respective scripts to run off of boot. In this example it will be explained how the ferry tracker demo script was made into a start-up script!
1. First find the script that you would like to make into a start-up script's path (in this example it is /home/root/FerryTracker).
2. Make the script executable by using the chmod +x command.
HOST: chmod +x FerryTracker
3. Create a service in the system directory.
HOST: vi /etc/systemd/system/startPHERRY.service
A. Add the following text to the file startPHERRY.service to tell the service how to function.
ExecStartPre=-/bin/sh -c "echo 0 > /sys/devices/virtual/vtconsole/vtcon1/bind"
ExecStopPost=-/bin/sh -c "echo 1 > /sys/devices/virtual/vtconsole/vtcon1/bind; e
4. Save the service and enable it by using the following lines of code:
Target: systemctl daemon-reloads
Target: systemctl enable startPHERRY.service
5. Reboot your device. The service should be running!
6. If you would like to disable a service simply use the following:
Target: systemctl disable startPHERRY.service
Change the Refresh Rate
Background- Without any changes the PHERRY runs on a 5 second refresh rate, meaning the facts, schedule, and ferry tracker are ran every 5 seconds. This refresh rate can be changed a few ways, but the easiest is through modifying the python files. An example of this is shown bellow using ferryfacts.py.
- Open ferryfacts.py
Target: vi ferryfacts.py
- Add the following line to the bottom of the python file:
- Save your changes and the facts should update every 20 seconds now instead of every 5 seconds!Future Improvements
- Add Tabs or drop-down list to Qt display - The ferry.sched is capable of displaying multiple ferry schedules. If you look at the WSDOT URL, you will notice that each dock has a given value (SEA = 3, BI = 7). By adding tabs or a drop-down list to the display you can show more schedules.
- Adjust code to display ferry warning messages.
- Make an API to send alerts to other devices.
- Adjust housing enclosure to sit on desk.
- Adjust housing enclosure frame - change the front frame to show a crab, octopus, Space needle, you name it!