New Version 2019

Setup

Raspberry Pi Installation

On Ubuntu:
download Raspbian Stretch
install Raspbian on micro SD card using startup disk creator

Raspberry Pi Configuration

sudo raspi-config
enable I2C
enable serial port
disable serial port shell
enable built-in VNC Server (RealVNC)

VNC Server

in options, make sure authentication is set to VNC
https://raspberrypi.stackexchange.com/questions/68838/i-failed-to-remote-connect-to-raspberry-pi-3-from-ubuntu
On Ubuntu client side, using vinagre
headless VNC server
https://thisdavej.com/beginners-guide-to-installing-node-js-on-a-raspberry-pi/

File Sharing

mkdir /home/user/sshfs_pi/

sudo sshfs -o allow_other pi@192.168.0.100:/ /home/user/sshfs_pi/

Testing communication with Arduino

minicom -b 9600 -o -D /dev/ttyAMA0 Set fixed IP

Install Node.js

Zero requires different installation than biger RPi because it uses ARM 6 architecture
https://eddielee.me/running-node-js-on-a-raspberry-pi-zero/
Steps:
wget https://nodejs.org/dist/latest/node-v11.6.0-linux-armv6l.tar.gz
tar -xzf node-v11.6.0-linux-armv6l.tar.gz
sudo cp -R node-v11.6.0-linux-armv6l/* /usr/local/
nano ~/.profile
Add
PATH=$PATH:/usr/local/bin
at the end then press ctrl + x to exit. Type yes to save.
simple web server:
sudo npm install http-server -g
http-server
https://www.npmjs.com/package/http-server
serial to web socket:
npm install express
npm install ws
npm install serialport
npm install ip
(-g, module not found?)

Autostart node server on Pi startup

add the MPPT software as a service using systemd.
add file MPPT.service to /etc/systemd/system.
Start and stop:
sudo systemctl start MPPT.service
sudo systemctl stop MPPT.service
check status:
sudo systemctl status MPPT.service
during development
sudo systemctl daemon-reload
sudo systemctl restart MPPT.service
To start automatically at boot:
sudo systemctl enable MPPT.service
To list all services:
sudo systemctl list-unit-files
or
sudo systemctl list-unit-files | grep MPPT.service
To see output from service:
journalctl -u MPPT.service -b
To shorten journal file:
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s

Software

Operating System

How to Setup Raspberry Pi Zero W for Headless https://www.youtube.com/watch?v=LlCr09B2HZI https://www.npmjs.com/package/raspi-pwm

Application Software

npm install rpio
npm install raspi
npm install raspi-pwm

PWM on Raspberry Pi

https://www.npmjs.com/package/raspi-pwm
https://github.com/nebrius/raspi-pwm
https://raspberrypi.stackexchange.com/questions/4906/control-hardware-pwm-frequency

Raspberry Pi Power Consumption

https://www.jeffgeerling.com/blogs/jeff-geerling/raspberry-pi-zero-conserve-energy

Raspberry Pi Zero Pins


https://learn.sparkfun.com/tutorials/raspberry-gpio/all

Wifi

https://github.com/tlhunter/node-wireless