E-Ink: Moon / ISS / People in Space ...

by emihermes in Circuits > Raspberry Pi

548 Views, 2 Favorites, 0 Comments

E-Ink: Moon / ISS / People in Space ...

ezgif-2-f07e811dfa51.gif

I had a Raspberry and a e-Paper HAT and I wanted to use it to show information like where is the ISS or how many people are now in the space...

I stated to look if there are APIs on the Internet to get those data, and I found them.
OK, gotcha !!!!

Wait, this HAT has 4 buttons, and then, I need 4 data to be shown...

- Where is now the ISS?
- How many people are now in the space?
- In which phase is the Moon?
- Is it going to rain? Is it so warm?...

Right now, I'm showing those information, but I could update this "Instructable" as soon as I got a good idea, or if you know a good one, you can suggest it to me !!!

Well, I made it on one evening and the "FrontEnd" was ended a few days after.
Don't complain about how the information is shown, I don't like to make this part :)

Supplies

- Raspberry PI (Zero is enough).
- 2.7inch e-Paper HAT. (I bought mine here)
- SD card (4Gb is enough).

You also need a Token from OpenWeather to use them APIs (from here)

Update Software (SO)

PI-Raspi-Config001.jpg
PI-Raspi-Config002.jpg
PI-Raspi-Config003.jpg
PI-Raspi-Config004.jpg
SPI-Enable.jpg

The first step, as always, is to prepare your Raspberry PI with the latest OS.

- Download the latest OS (with desktop) from here.
- Write the image on an empty SD card.
- Create an empty file "ssh" to enable the SSH connection.
- Save the "wpa_supplicant.conf" file on the SD card to have your Wifi configured to connect to your Raspberry PI via SSH (you have it prepared on your computer, I know it).

Start your Raspberry Pi.

Connect to it via SSH (you can also do it if you have a monitor, keyboard and mouse, but I don't have and I prefer to connect via SSH) and update it....

sudo apt-get update -y
sudo apt-get upgrade -y

Now, you have to enable VNC to be able to connect remotely and SPI for the e-Paper HAT:

sudo raspi-config

Interfacing Options > VNC > Yes
Interfacing Options > SPI > Yes

And reboot it.

Needed Software

eInk-Software.jpg

Ok, now we have a running Raspberry PI with the latest software and all the basic to connect to it.

It's the moment to start installing the needed software to control the e-Paper HAT.

If you didn't plug the HAT on your Raspberry PI, now is the latest moment to connect it.
Switch off your Raspberry PI and put the HAT on it.

For the next steps you can follow the instructions from Waveshare or follow it with the next steps....

Install BCM2835 libraries:

wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz
tar zxvf bcm2835-1.60.tar.gz
cd bcm2835-1.60/ 
sudo ./configure 
sudo make 
sudo make check 
sudo make install 
#For more details, please refer to http://www.airspayce.com/mikem/bcm2835/

Install wiringPi libraries:

sudo apt-get install wiringpi
#For Pi 4, you need to update it: 
cd /tmp wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb gpio -v 
#You will get 2.52 information if you install it correctly

Install Python libraries:
(If you updated the SO with the latest version, all of these steps will be like "Requirement already satisfied").

sudo apt-get update 
sudo apt-get install python3-pip 
sudo apt-get install python3-pil 
sudo apt-get install python3-numpy 
sudo pip3 install RPi.GPIO 
sudo pip3 install spidev

Now you can download the examples from Waveshare:
(This part is NOT needed, but you can download them to know how it works).

sudo git clone https://github.com/waveshare/e-Paper
cd e-Paper/RaspberryPi\&JetsonNano/

I recommend you to remove some folders:
- e-Paper/Arduino (It's a Raspberry PI).
- e-Paper/STM32 (It's a Raspberry PI).
- e-Paper/Raspberry & JetsonNano/c (we'll use python on this project).

You will not use them, and you don't need them on a Raspberry PI.

And, if you wish, you can remove all the files that you don't need from the "lib" folder, like:
- epd1in02.py
- epd1in54.py
- epd2in9.py
- ...

If we are going to use a 2.7inch, the rest of the files are NOT needed.

I recommend you to move the "lib" folder a bit back to use it easily:

sudo mv lib /home/pi/e-Paper/

However, in my code (from GitHub) the libraries are included.

All the needed software is installed.

The next step is our code!

Download My Code

Now we need to download the code from GitHub:

sudo git clone https://github.com/EmiHermes/eInk_Moon_ISS_PeopleSpace.git

With this we'll have all the needed code, including the libraries from Waveshare into the actual project.

Edit the file "ShowInfo.py" to insert your API-Token from OpenWeather.com....
...and the City (use the name or the ID of the city):

def WeatherForecast():
    url = "http://api.openweathermap.org/data/2.5/forecast?"
    #url = url + "q={city_name}" 
    #url = url + "q=Düsseldorf"        # ASCII problems  !!!
    url = url + "id=2934246"
    #url = url + "&appid={your_API_key}" 
    url = url + "&units=metric"        # In Metric 
    url = url + "&cnt=6"               # Only 6 results


However, we need to install the font files that we use on the project.
The files were downloaded with all the code.

The fonts are on the "e-Paper/fonts" folder.

To unzip:

sudo unzip Bangers.zip -d /usr/share/fonts/truetype/google/
sudo unzip Bungee_Inline.zip -d /usr/share/fonts/truetype/google/
sudo unzip Bungee_Outline.zip -d /usr/share/fonts/truetype/google/
sudo unzip Bungee_Shade.zip -d /usr/share/fonts/truetype/google/
sudo unzip droid-sans.zip -d /usr/share/fonts/truetype/google/
sudo unzip Indie_Flower.zip -d /usr/share/fonts/truetype/google/
sudo unzip Jacques_Francois_Shadow.zip -d /usr/share/fonts/truetype/google/
sudo unzip Londrina_Outline.zip  -d /usr/share/fonts/truetype/google/
sudo unzip Londrina_Shadow.zip -d /usr/share/fonts/truetype/google/
sudo unzip Londrina_Sketch.zip -d /usr/share/fonts/truetype/google/
sudo unzip Oswald.zip -d /usr/share/fonts/truetype/google/
sudo unzip Roboto.zip -d /usr/share/fonts/truetype/google/
sudo unzip Vast_Shadow.zip -d /usr/share/fonts/truetype/google/

I recommend you to delete the zip files after the installation, because we don't need anymore those files:

sudo rm -R fonts

Execute the TEST

Test001-a.jpg
Test001-b.jpg

Go to the correct folder where we have the test file:

cd ~/eInk_Moon_ISS_PeopleSpace/e-Paper/ShowEInk

Execute the test file with the version 3 of Python:

python3 Test001.py

You will have a traced comments meanwhile the program is executed.

And in the e-Paper screen you will see the messages.

For each button, the screen will show a different message.

Show the Moon / Space / ISS Information....

WeatherForecast.jpg
People_Space.jpg
ISS.jpg
Moon_phase.jpg

OK, we have all running and we now want to see where is the ISS over the World, or the phase of the Moon...

First you have to execute the file"ShowInfo.py" (located on "~/eInk_Moon_ISS_PeopleSpace/e-Paper/ShowEInk").

python3 ~/eInk_Moon_ISS_PeopleSpace/e-Paper/ShowEInk/ShowInfo.py

And now, if you press one button, you'll have the information programmed to this button:

● Button 1: Weather forecast.

● Button 2: Who is on the Space and where.

● Button 3: Where is the ISS over the World.

● Button 4: Information of the Moon.

Execute It As a Service

As an alternative, the Python script can be started during boot by creating a service - more info at https://www.raspberrypi.org/documentation/linux/u...

Create a new file called ShowInfo.service and copy the contents below to the new file - adjust the WorkingDirectory path accordingly:

[Unit] 
Description=ShowInfo 
After=network-online.target
Wants=network-online.target

[Service] 
ExecStart=/usr/bin/python3 ShowInfo.py 
WorkingDirectory=/home/pi/eInk_Moon_ISS_PeopleSpace/e-Paper/ShowEInk/
StandardOutput=inherit 
StandardError=inherit 
Restart=always 
User=pi

[Install] 
WantedBy=multi-user.target

Copy the ShowInfo.service file into /etc/systemd/system as root:

sudo cp ShowInfo.service /etc/systemd/system/

Start the service:

sudo systemctl start ShowInfo.service

Check if the service is running:

sudo systemctl status ShowInfo.service

The output should be similar to:

● ShowInfo.service - ShowInfo
   Loaded: loaded (/etc/systemd/system/ShowInfo.service; disabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-09-11 15:17:16 CEST; 14s ago
 Main PID: 1453 (python3)
   CGroup: /system.slice/ShowInfo.service
           └─1453 /usr/bin/python3 ShowInfo.py
Sep 11 15:33:17 eInk systemd[1]: Started ShowInfo.

If the service is running fine, you can enable it and reboot the Raspberry Pi to load it automatically during boot:

sudo systemctl enable ShowInfo.service

To stop the service:

sudo systemctl stop ShowInfo.service

And that's all !!!!!

Thanks !!!!!