4.8 KiB
4.8 KiB
Introduction
New goal on pi4 without kotlin and django, and with only one dataserver.
Installation
Get Raspbrain into SD card
Download Raspbian Buster Lite
Copy raspbian.img into SD card
# check disk
lsblk
# copy data to sd card
sudo dd bs=4M if=yyyy-mm-dd-raspbian-buster.img of=/dev/sdX conv=fsync status=progress
# enable ssh on first boot
add ssh.txt in boot folder
Setup pi3 environment
raspi-config setting
* means neccessary
△ means under some circumstances not need to change the options
* Change Password
* Change Locale
- sudo nano /etc/locale.gen
* uncomment # en_US.UTF-8 UTF-8 -> en_US.UTF-8 UTF-8
- sudo raspi-config
* Localisation Options
* Change Locale
* en_US.UTF-8 UTF-8
* en_US.UTF-8 UTF-8 (Configuring locales)
* Change TimeZone
- Localisation Options
* Change Timezone
* Asia
* Taipei
△ Change Keyboard Layout
- Localisation Options
* Change Keyboard Layout
* Generic 105-key PC (intl.) (default)
* Other (escape UK menu)
* English (US)
* The default for the keyboard layout
* No compose key
* Change Wifi Country
- Localisation Options
* Change WLAN Country
* TW Taiwan
△ Wifi setting
- Network Options
* Wireless LAN
* SSID (wifi-name)
* password (wifi-pass)
△ Enable SSH service
- Interfacing Options
* SSH
* Yes
* Reboot
sudo reboot
* System update
sudo apt-get update
sudo apt-get upgrade
Install dependencies
sudo apt-get install vim git wiringpi build-essential libi2c-dev i2c-tools python-dev libffi-dev python3-pip postgresql
Setup project
Clone project
cd ~
git clone https://gitlab.com/bioproscientific/bioprorelife.git
Install python dependencies
cd ~/bioprorelife
pip3 install -r requirements.txt
Packages version
fake-rpi 0.6.3
gprof2dot 2019.11.30
matplotlib 3.2.1
objgraph 3.4.1
paho-mqtt 1.5.0
pycrypto 2.6.1
PyInstaller 3.6
pyserial 3.4
RPi.GPIO 0.7.0
smbus-cffi 0.5.1
Sphinx 2.4.4
sphinx-autodoc-typehints 1.10.3
spidev 3.2
yappi 1.2.3
psycopg2 2.8.5
Build C extension
cd ~/bioprorelife/python/biopro/ext/
rm -rf *.so build
python3 setup.py build_ext --inplace
Check setup-uart file
cd ~/bioprorelife
sudo vim ./run-setup-uart.sh
Modify the code as following
# for pi3
if [ -z "$(grep dtoverlay=pi3-disable-bt /boot/config.txt)" ]; then
echo 'dtoverlay=pi3-disable-bt' >> /boot/config.txt
fi
# for pi4
if [ -z "$(grep dtoverlay=pi4-disable-bt /boot/config.txt)" ]; then
echo 'dtoverlay=pi4-disable-bt' >> /boot/config.txt
fi
Enable uart, spi, serial_port and disable bluetooth
sudo ./run-setup-uart.sh
sudo raspi-config
Interfacing options
serial
no
yes
reboot
Auto run program when device start
sudo vim /etc/rc.local
add the code following as:
sudo -H -u pi nohup /home/pi/bioprorelife/run-data-server.sh > /home/pi/.data_server.out &
MQTT broker install
- Install mosquitto
sudo apt-get install mosquitto mosquitto-clients
- Enable Remote Access
sudo vim /etc/mosquitto/conf.d/default.conf
add the code following as:
listener 1883
protocol mqtt
listener 8083
protocol websockets
restart mqtt broker
sudo systemctl restart mosquitto
- Robust MQTT create mosquitto_restart.sh
cd ~
sudo vim mosquitto_restart.sh
add the code following as:
if [ "`ps -aux | grep /usr/sbin/mosquitto | wc -l`" == "1" ]
then
echo "mosquitto wasnt running so attempting restart" >> /home/ubuntu/cron.log
systemctl restart mosquitto
exit 0
fi
echo "$SERVICE is currently running" >> /home/ubuntu/cron.log
exit 0
add mosquitto_restart.sh to root routing
sudo chmod +x mosquitto_restart.sh
sudo -i
crontab -e
add the code following as:
*/5 * * * * /home/pi/mosquitto_restart.sh
- Auto run MQTT broker when when pi-start
sudo vim /etc/rc.local
add the code following as:
sudo nohup systemctl restart mosquitto
Setup routed wireless access point
raspberry website document:
https://www.raspberrypi.org/documentation/configuration/wireless/access-point-routed.md