Saturday, 31 August 2019

Preparing SD cards for Raspberry Pi

Step by Step instructions on how I do it.

First use Etcher to download the program to the SD card.  Today this is Raspbian Buster.

Use the browser to connect to the Boot partition of the SD card and create an empty file called 'ssh'

Now plug the SD card into the R-Pi and power it on. Connect via Ethernet. Use a utility like fing on a tablet to determine the IP address.

We need to configure networking. I have three files on my PC that are copies of the networking files from the R-Pi that are set up the way that I like them. I use a fixed wireless and a fixed Wired ethernet address on my devices.

The IP address found by fing is 192.168.1.22.  In a terminal, use ssh to connect to the R-Pi.
ssh  -l pi 192.168.1.22.  I always have to reset keygen when I am operating on a different IP address here.

cd ..
cd ..
cd etc
sudo nano dhcpcd.conf  and toward the end of the file add the lines:
# Example static IP configuration:
interface eth0
static ip_address=192.168.1.9/27
static routers=192.168.1.1
static domain_name_servers=192.168.011 8.8.8.8

interface wlan0
static ip_address=192.168.1.8/27
static routers=192.168.1.1
static domain_name_servers=192.168.1.1  8.8.8.8

This may vary depending on your network and Sub-network mask. 

Comment out the line "slaac private"
CTRL o to write file and CTRL x to exit

cd wpa_supplicant
sudo nano wpa_supplicant.conf
change this file to be:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB

network={
ssid="bmth-wireless"
psk="3C0M5PGM"
# proto=RSN
key_mgmt=WPA-PSK
# pairwise=TKIP
# auth_alg=OPEN
}

Save and exit
Don't forget to change the ESSID and PSK to your own values.

I had to change the properties of this file so that it was accessible.
sudo chmod 777 wpa_supplicant.conf.

Now other  Raspberry pi preparations and setup
Use sudo raspi-config to expand the file system (Under advanced settings).
sudo apt-get update

At this point I reboot to get the new IP addresses. You will need to ssh in again.

sudo apt-get install python3-flask.
mkdir rc-car
cd rc-car
mkdir templates
save app.py in the rc-car directory
save index.html in the templates directory


sudo apt install python3-gpiozero

Use filezilla and transfer files to the Pi  or copy and paste contents of files using nano.

Need a script file to start Flask. It is in the /pi directory    go-car.scr
It is:
export FLASK_APP=/home/pi/rc-car/app.py
flask run –host=192.168.1.8

sudo chmod 777 go-car.scr   to make it executable. 

Also edit /etc/rc.local and add these two lines to it.

Setting up Ad-Hoc networking:
sudo apt-get install dnsmasq hostapd    --> done


stopped dnsmasq and hostapd, and rebooted. 

got as far as installing and shutdown instead of reboot.
Changed wireless SSID to 'rc-car' and WPA to 'Ashmeads'
IP range is dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
Edit /etc/dnsmasq.conf to contain
interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
If Wireless doesn't work, it is because the firmware is not installed:

sudo apt-get install firmware-zd1211










No comments: