Giter Site home page Giter Site logo

paragraphica's Introduction

Test Script Explanation

The test-api.py script located in the api folder, is a simple python script that connects to custom Paragraphica API server. Use this script through a terminal to test conenctivity and to see if images are stored. The test script needs a API key, that is shared separatly for security reasons.

Run the test in your terminal with using python3

python3 test-api.py

Settings in the test file inlcude:

  • Loacation = lat and lon
  • style = default photograph
  • image strength = how close to reality
  • year = what year the image should depict

๐Ÿ“ก Initial RPI setup

set up SD card with Raspberry Pi Imager and make sure it is able to connect to the internet fot the initial setup. Then ssh into the device:

password is: paragraphica

if that does not work run the nmap on your routers ip:

nmap -sn 192.168.1.1/24

Find the ip adress for your pi, then ssh using the ip adress directly:

if you have key varification failed error, simply reset it and try again:

ssh-keygen -R 192.168.1.175

๐Ÿ“ก Setup WiFi Access Point

Install the necessary software:

sudo apt update
sudo apt install dnsmasq hostapd

Then stop these services as we will configure them:

sudo systemctl stop dnsmasq
sudo systemctl stop hostapd

Create the virtual wireless interface by opening /etc/dhcpcd.conf:

sudo nano /etc/dhcpcd.conf

and then add the following lines to the end of the file:

interface ap0
    static ip_address=192.168.50.1/24
    nohook wpa_supplicant

Save and exit.

The next step is to configure the DHCP server (dnsmasq). Move the default configuration file and create a new one:

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig  
sudo nano /etc/dnsmasq.conf

Then add the following to the new dnsmasq.conf:

interface=ap0
dhcp-range=192.168.50.50,192.168.50.150,255.255.255.0,12h

Save and exit.

Now, set up the access point. Create the hostapd configuration file:

sudo nano /etc/hostapd/hostapd.conf

Add the following lines to this file:

interface=ap0
driver=nl80211
ssid=paragraphica
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=starmole
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Modify /etc/default/hostapd to point to this configuration file:

sudo nano /etc/default/hostapd

Find the line #DAEMON_CONF="" and replace it with:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Save and exit.

Enable and start hostapd and dnsmasq:

sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd
sudo systemctl start dnsmasq

enable IP forwarding. Open /etc/sysctl.conf:

sudo nano /etc/sysctl.conf

And uncomment this line: net.ipv4.ip_forward=1

Save and exit.

The Raspberry Pi should now be set up to run a WiFi network on startup. However, we still need to create the ap0 interface on boot. For that, we need to add a line to /etc/rc.local:

sudo nano /etc/rc.local

Add this line before exit 0:

iw dev wlan0 interface add ap0 type __ap

Save and exit and reboot your Pi:

sudo reboot

You should be able to see "Paragraphica Connect" on your network list.

You can also check if wlan0 and ap0 are both on the list when running:

iwconfig

๐Ÿ’พ Clone and Update Git Repository

If not already installed then make sure you have git installed:

sudo apt update
sudo apt install git

Clone the Paragraphica-v2 repository to the root

git clone https://github.com/bjoernkarmann/Paragraphica-v2.git

to update the git repository run:

cd Paragraphica-v2
git fetch origin
git reset --hard origin/main

๐Ÿšจ Prepare Project Requirements

Enable SPI interface:

sudo raspi-config

Then, navigate to "Interface Options" > "SPI" and select "Yes" to enable SPI.

Install pip3 and gps modules

sudo apt-get install python3-pip gpsd gpsd-clients

install the rest through pip3

sudo pip3 install flask gpiozero spidev requests luma.lcd pillow gpsd-py3

Set up a .env file to store the API key:

touch .env
nano .env

Now paste the API key into the file (note that this key is only provided by auther and is higly sensitive information):

API_KEY=PARAGRAPHICA-API-KEY-HERE

Save and exit.

Now we can try run the main.py to check if the captive portal appears when connecting to the network "Paragraphica Connect":

sudo python3 main.py

๐Ÿฅพ Setup Boot Script

Untested!

Create a new service file:

sudo nano /etc/systemd/system/main.service

And enter the following:

[Unit]
Description=Pargraphica main script
After=network.target

[Service]
ExecStart=/usr/bin/python3 /home/pi/Paragraphica-v2/main.py
Restart=always
Environment=PYTHONUNBUFFERED=1

[Install]
WantedBy=multi-user.target

Then, enable and start the service:

sudo systemctl enable main
sudo systemctl start main

You can check its status with

sudo systemctl status main

paragraphica's People

Contributors

bjoernkarmann avatar

Stargazers

nav avatar

Watchers

 avatar  avatar

Forkers

alter-nimbus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.