Raspberry Pi Setup and projects

(last update 2023-03-30)




Projects

Project 1

PT1000 interfacing
Project
Project 2

Model railway points controller

Using Restful API interface


                     point     button 

playpoints      




Setup   

Setup - Headless
Raspberry Pi 3 Model B+ PC
phone
Setup Full
Raspberry Pi 3 Model B+ screen
keyboard mouse





Headless - this is preparing the Raspberry Pi SD card so that when it starts up you don't need a screen, keyboard or mouse attached, just use a remote connection to it To use option 1 in the office you will need
- a PC/Mac with an SD or micro SD card slot and
- Raspberry Pi imager software, to create the image

on site or in the office, a phone or PC/Mac
- Fing software, to find the IP address of the Raspberry Pi once running
- an SSH remote control software, to configure it
- a VNC remote control software, to operate it
Connected - where you plug in all the peripherals and can operate it like a standalone PC for configuration, for example, when you don't know the WiFi information. To use option 2 in the office you will need
- a USB key
- a USB mouse
- an HDMI terminal

To operate and configure on site or in the office,  either

- a USB key
- a USB mouse
- an HDMI terminal

or on a phone or PC/Mac
- Fing software, to find the IP address of the Raspberry Pi once running
- a VNC remote control software, to operate it
Links,  instructions and commands collection

For the Raspberry Pi Imager, to build a Micro SD card to boot from

https://www.raspberrypi.com/software/

For Fing to find the Raspberry pi IP address on the network, available free for most platforms.

https://www.fing.com/products

For VNC remote control of Raspberry Pi without screen keyboard, mouse, available free for most platforms.

https://www.realvnc.com/en/connect/download/viewer/

SSH depends on platform
 
Download and install Raspberry Pi Imager to a computer with an SD card reader.
Put the SD card you'll use with your Raspberry Pi into the reader and run Raspberry Pi Imager.
Load default image and be sure to Config before starting and enter and enable everything.

https://www.youtube.com/watch?v=u8bbp79haN4

https://www.youtube.com/watch?v=gGCtbn0d5uQ

SSH to devicename@ip address

//sudo ln -s /usr/lib/systemd/system/vncserver-x11-serviced.service /etc/systemd/system/multi-user.target.wants/vncserver-x11-serviced.service
//sudo systemctl start vncserver-x11-serviced


sudo raspi-config

enable VNC

sudo reboot
sudo  shutdown

sudo apt update
sudo apt upgrade

Flask already installed

//sudo apt install python3-venv
// sudo apt-get install python3-flask

cd Documents
mkdir rpiWebServer
cd rpiWebServer
mkdir static
mkdir templates


// sudo python3 RestAPI.py

#!/bin/bash

export FLASK_APP=RestAPI.py
flask run --host=0.0.0.0


Setup automatic start
sudo nano /lib/systemd/system/RestfulAPI.service

RestfulAPI.service =

[Unit]
Description=Start Restful API server
After=multi-user.target

[Service]
ExecStart=sh /home/
pi3/Desktop/startup.sh

[Install]
WantedBy=multi-user.target

or
ExecStart=/home/pi3/Desktop/startup.sh


sudo systemctl daemon-reload

sudo systemctl enable RestfulAPI.service

systemctl status RestfulAPI

sudo systemctl stop RestfulAPI.service

sudo systemctl status RestfulAPI.service

edit wifi
Generate PSK - make sure SSID has correct case and password
wpa_passphrase my_SSID my_password

Add to this file
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf