Relay is switching on (re)boot
GPIO 14 is used which is testing the UART on boot so take another GPIO
Communication between 2 raspberry pi’s over serial (UART)
Below a summary of the linked page
- sudo nano /boot/config.txt > enable_uart=1
- sudo systemctl disable serial-getty@ttyS0.service
- sudo nano /boot/cmdline.txt > Remove “console=serial0,115200” (If applicable)
- sudo reboot
- sudo apt-get install minicom -y
- minicom -b 115200 -o -D /dev/ttyS0
- Ctrl-A E for local echo
- Ctrl-A A for line feed
Baud rate 250000 (DMX) Didn’t get it working
https://bookspaceworld.com/Article/configuring-uart-rpi-uart-speeds-baud-rate
Raspberry pi 2
- Disable console > sudo raspi-config
- interface options > Serial port
- login shell > no
- serial port enabled > yes
- Finish
- enable and adapt UART settings in /boot/config.txt
- Check UART > enable_uart=1
- Add > init_uart_clock=1627604
(init_uart_clock=26041667) - init_uart_baud=460800
- Reboot
- Check current settings serial port > stty < /dev/ttyAMA0
- Set baud rate > stty -F /dev/ttyAMA0 speed 38400
RS485 CAN HAT waveshare example
Trouble shooting
- Measure core speed >
vcgencmd measure_clock core - Measure UART speed >
vcgencmd measure_clock uart - sudo nano /boot/config.txt
- sudo nano /boot/cmdline.txt
- Current settings serial port > stty -F /dev/ttyS0
- Set baud rate > stty -F /dev/ttyS0 115200
- Send to serial port > echo -e “hello world\r\n” > /dev/ttyS0
- https://bitwizard.nl/wiki/Dmx_interface_for_raspberry_pi
- https://www.mnm-team.org/pub/Fopras/edel17/PDF-Version/edel17.pdf
WiFi to Ethernet bridge
Write image to PI and connect to WiFi.
To change accesspoint:
sudo raspi-config
or
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
sudo apt-get update -y && sudo apt-get upgrade -y sudo apt-get install dnsmasq
- nano /etc/dhcpcd.conf
- interface eth0
- static ip_address=192.168.220.1/24
- static routers=192.168.220.0
- static domain_name_servers=8.8.8.8
- metric 300
- interface wlan0
- metric 200
- sudo service dhcpcd restart
To check service = systemctl status dhcpcd.service
Save dnsmask config = sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Create new dnsmask config = sudo nano /etc/dnsmasq.conf
- interface=eth0 # Use interface eth0
- listen-address=192.168.220.1 # Specify the address to listen on
bind-interfaces # Bind to the interfaceThe service won’t start with disconnected Eth0- domain-needed # Don’t forward short names
- bogus-priv # Drop the non-routed address spaces.
- dhcp-range=192.168.220.50,192.168.220.150,12h # IP range and lease time
To check service = systemctl status dnsmasq.service
Enable IPv4 packet forwarding
- sudo nano /etc/sysctl.conf
- Uncomment this line or add it to the bottom
- net.ipv4.ip_forward=1
to activate directly = sudo sh -c “echo 1 > /proc/sys/net/ipv4/ip_forward”
Configure firewall
- sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
- sudo iptables -A FORWARD -i wlan0 -o eth0 -m state –state RELATED,ESTABLISHED -j ACCEPT
- sudo iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
Save FW rules = sudo sh -c “iptables-save > /etc/iptables.ipv4.nat”
use FW rules at startup
- sudo nano /etc/rc.local
- Before exit0 insert iptables-restore < /etc/iptables.ipv4.nat
- sudo service dnsmasq start
reboot raspberry PI