scp [email protected]:~/tfjs-yolo-tiny/demo/test.jpg ~stephanie/Desktop
sudo raspi-config
- Select option 5, Interfacing options, then option P6, Serial, and select No. Exit raspi-config.
sudo nano /boot/cmdline.txt
- Make sure it doesn't include:
console=ttyAMA0,115200
(fyi, this is ok:console=tty1
)
- Add
enable_uart=1
. This assigns the mini UART (serial1) to the Bluetooth module, since we are using serial0 now as our main serial for the GPIO pins. - Disable BT to be safe:
dtoverlay=pi3-disable-bt
Ensure UART pins 15,16 are in state ALT0.
- Install wiringpi:
sudo apt-get install wiringpi
- gpio readall
- Change to ALT0 if they aren't:
gpio mode 15 ALT0
gpio mode 16 ALT0
sudo reboot
sudo minicom -D /dev/serial0
(should be able to type in console)- Run
python test_uart.py
#!/usr/bin/env python
# test_uart.py
# Will also work on Python3.
# Serial port loopback testing for a RaspberryPi.
from __future__ import print_function
import serial
test_string = "Testing 1 2 3 4".encode('utf-8')
#test_string = b"Testing 1 2 3 4" ### Will also work
port_list = ["/dev/serial0", "/dev/ttyAMA0", "/dev/serial1", "/dev/ttyS0"]
for port in port_list:
try:
serialPort = serial.Serial(port, 115200, timeout = 2)
serialPort.flushInput()
serialPort.flushOutput()
print("Opened port", port, "for testing:")
bytes_sent = serialPort.write(test_string)
print ("Sent", bytes_sent, "bytes")
loopback = serialPort.read(bytes_sent)
if loopback == test_string:
print ("Received", len(loopback), "valid bytes, Serial port", port, "working \n")
else:
print ("Received incorrect data", loopback, "over Serial port", port, "loopback\n")
serialPort.close()
except IOError:
print ("Failed at", port, "\n")
sudo nano /etc/rc.local
- Add before
exit 0
:
gpio mode 15 ALT0
gpio mode 16 ALT0
https://www.raspberrypi.org/documentation/configuration/uart.md https://blainebooher.com/jekyll/update/2018/05/15/pi3-btle.html
-
Increase swap size to 1024mb (https://wpitchoune.net/tricks/raspberry_pi3_increase_swap_size.html)
sudo dphys-swapfile swapoff
sudo nano /etc/dphys-swapfile
&CONF_SWAPSIZE=1024
, save.sudo dphys-swapfile setup
sudo dphys-swapfile swapon
- check with
htop
(https://www.bitpi.co/2015/12/30/htop-linux-task-manager/)
-
node --max-old-space-size=500 index.js
<--- rpi has 1gb ram, this will tell node that GC needs to happen sooner around 500mb (https://stackoverflow.com/questions/40214669/raspberry-pi-3-script-ram-usage)
Or to remove SWAP completely (https://medium.com/@meeDamian/bitcoin-full-node-on-rbp3-revised-88bb7c8ef1d1):
pm2 unstartup
[PM2] Init System found: systemd [PM2] To setup the Startup Script, copy/paste the following command: sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 unstartup systemd -u pi --hp /home/pi
(https://appcodelabs.com/how-to-backup-clone-a-raspberry-pi-sd-card-on-macos-the-easy-way)
diskutil list
should be/dev/disk2
- make a folder:
cd ~ mkdir rpi_backups cd rpi_backups
- copy from sd card to mac:
sudo dd if=/dev/rdisk2 of=rpi_yolo_nodejs_backup_jul_6_2019.dmg
- format new SD card using SDformatter application on Mac
- check new SD card:
diskutil list
- Then unmount the SD card:
diskutil unmountDisk disk2
- Then copy backup file to SD card:
sudo dd if=rpi_yolo_nodejs_backup_jul_6_2019.dmg of=/dev/rdisk2