From f0d4749db32cf569663d41266c4f1057ef5561a6 Mon Sep 17 00:00:00 2001 From: mmcw-dev Date: Sun, 7 Oct 2018 14:16:47 -0400 Subject: [PATCH 01/11] Add dev instructions for raspberry pi zero w configuration --- howto/RaspberryPiZeroW.md | 59 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 howto/RaspberryPiZeroW.md diff --git a/howto/RaspberryPiZeroW.md b/howto/RaspberryPiZeroW.md new file mode 100644 index 0000000..07f5592 --- /dev/null +++ b/howto/RaspberryPiZeroW.md @@ -0,0 +1,59 @@ + +## Client Architecture + +* Raspberry Pi Zero W +* Raspberry Pi Zero (Development) +* Raspberry Pi 1 (Development) + +### Ethernet over USB + +From [this blog post](http://blog.gbaman.info/?p=791) + +1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card. +2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the ```config.txt``` file ```dtoverlay=dwc2``` on a new line, then save the file. +3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ```ssh``` in the SD card as well. By default SSH is now disabled so this is required to enable it. Remember - Make sure your file doesn't have an extension (like .txt etc)! +4. Finally, open up the ```cmdline.txt```. Be careful with this file, it is very picky with its formatting! Each parameter is seperated by a single space (it does not use newlines). Insert ```modules-load=dwc2,g_ether``` after ```rootwait```. To compare, an edited version of the ```cmdline.txt``` file at the time of writing, can be found here. +5. That's it, eject the SD card from your computer, put it in your Raspberry Pi Zero and connect it via USB to your computer. It will take up to 90s to boot up (shorter on subsequent boots). It should then appear as a USB Ethernet device. You can SSH into it using raspberrypi.local as the address. + +### Sharing internet from host machine (OSX) + +From [learn.adafruit.com](https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget?view=all) + +```sudo nano /etc/network/interfaces``` + +Add at the end: + +``` +allow-hotplug usb0 +iface usb0 inet static + address 192.168.7.2 + netmask 255.255.255.0 + network 192.168.7.0 + broadcast 192.168.7.255 + gateway 192.168.7.1 +``` + +This will give the Raspberry Pi the IP Address ```192.168.7.2```. Then run the following: + +``` +sudo ifdown usb0 +sudo ifup usb0 +ifconfig usb0 +``` + +In the OSX Network Preferences you'll see the device show up as an ```RNDIS/Ethernet Gadget```. It'll probably be set up for DHCP by default so change it to ```Configure IP4 Manually```. Use the following settings: + +``` +IP address: 192.168.7.1 +Subnet Mask: 255.255.255.0 +Router: 192.168.7.1 +``` + +Apply changes. Next, enable internet sharing from your machine (Ethernet or Wifi) to the ```CDC``` or ```RNDIS``` Raspberry Pi. + +On the Pi, change the line in ```/etc/network/interfaces``` that reads ```auto lo``` to ```auto lo usb0```. Remove or comment out the lines added to the file below ```allow-hotplug usb0``` previously and replace with ```iface usb0 inet manual```. + +### Modules and guides +* [BLE and pi and mobile app](https://www.hackster.io/inmyorbit/build-a-mobile-app-that-connects-to-your-rpi-3-using-ble-7a7c2c) +* [pi and i2c](http://www.maxbotix.com/Setup-Raspberry-Pi-Zero-for-i2c-Sensor-151/) +* [gpio module](https://www.npmjs.com/package/rpi-gpio) \ No newline at end of file From 3a4ee5798213673e8b8be2f089e6134a9eaab241 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sun, 7 Oct 2018 15:10:04 -0400 Subject: [PATCH 02/11] Use modern apt syntax and selectively use sudo where needed --- scripts/intval3-deps.sh | 16 ++++++++-------- scripts/intval3-install.sh | 32 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/scripts/intval3-deps.sh b/scripts/intval3-deps.sh index 299217b..c280d64 100644 --- a/scripts/intval3-deps.sh +++ b/scripts/intval3-deps.sh @@ -1,17 +1,17 @@ #!/bin/bash echo "Running intval3 dependency install script" -apt-get update -apt-get install git ufw nginx jq -y +sudo apt update +sudo apt install git ufw nginx jq -y echo "Installing node.js dependencies.." -apt-get install nodejs npm -y -npm install -g n -n latest -npm install -g npm@latest -npm install -g pm2 node-gyp +sudo apt install nodejs npm -y +sudo npm install -g n +sudo n latest +sudo npm install -g npm@latest +sudo npm install -g pm2 node-gyp echo "Installing bluetooth dependencies..." -apt-get install bluetooth bluez libbluetooth-dev libudev-dev -y +sudo apt install bluetooth bluez libbluetooth-dev libudev-dev -y echo "Finished installing intval3 dependencies" \ No newline at end of file diff --git a/scripts/intval3-install.sh b/scripts/intval3-install.sh index 06430fe..c14ca98 100644 --- a/scripts/intval3-install.sh +++ b/scripts/intval3-install.sh @@ -1,28 +1,28 @@ #!/bin/bash echo "Running intval3 install script" -apt-get update -apt-get install git ufw nginx jq -y +sudo apt update +sudo apt install git ufw nginx jq -y echo "Installing node.js dependencies.." -apt-get install nodejs npm -y -npm install -g n -n 9.1.0 -npm install -g npm@latest -npm install -g pm2 node-gyp +sudo apt install nodejs npm -y +sudo npm install -g n +sudo n 9.1.0 +sudo npm install -g npm@latest +sudo npm install -g pm2 node-gyp echo "Installing bluetooth dependencies..." -apt-get install bluetooth bluez libbluetooth-dev libudev-dev -y -systemctl disable bluetooth -hciconfig hci0 up +sudo apt install bluetooth bluez libbluetooth-dev libudev-dev -y +sudo systemctl disable bluetooth +sudo hciconfig hci0 up echo "Configuring ufw (firewall)..." -ufw default deny incoming -ufw default allow outgoing -ufw allow ssh -ufw allow http -ufw allow https -ufw enable +sudo ufw default deny incoming +sudo ufw default allow outgoing +sudo ufw allow ssh +sudo ufw allow http +sudo ufw allow https +sudo ufw enable echo "Installing intval3 project..." wget https://github.com/sixteenmillimeter/intval3/archive/master.zip From 5686a6b1bb37697d93f5d0b83e1e39cde20e18a9 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sun, 7 Oct 2018 15:10:30 -0400 Subject: [PATCH 03/11] Process must be run as root-level pi user --- scripts/intval3-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/intval3-install.sh b/scripts/intval3-install.sh index c14ca98..5bf922c 100644 --- a/scripts/intval3-install.sh +++ b/scripts/intval3-install.sh @@ -31,6 +31,6 @@ rm master.zip cd intval3 npm install -pm2 start process.json +sudo pm2 start process.json echo "Finished installing intval3" \ No newline at end of file From d2571aa36f3a23b5c7517cfa25e35ece6b995313 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sun, 7 Oct 2018 15:10:38 -0400 Subject: [PATCH 04/11] Install file --- howto/Readme.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 howto/Readme.md diff --git a/howto/Readme.md b/howto/Readme.md new file mode 100644 index 0000000..36a1d6a --- /dev/null +++ b/howto/Readme.md @@ -0,0 +1,18 @@ +## Assembly + +The essential components of the intval3 intervalometer are the following parts: + + +The electronics that interface with the Raspberry Pi can be created in a few different ways. A board can be purchased (soon), put together by hand on a prototyping bonnet, or etched from copper-clad board using the circuit board design files. + + +## Installation + +With a fresh [Raspian installation on the Raspberry Pi Zero W](RaspberryPiZeroW.md), you can install the intval3 software with two commands: + +``` +wget https://raw.githubusercontent.com/sixteenmillimeter/intval3/master/scripts/intval3-install.sh +sh ./intval3-install.sh + +``` + From f4685e9c7ccd5190ac481f5619162bd484b7ed1b Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sun, 7 Oct 2018 16:00:18 -0400 Subject: [PATCH 05/11] Update install script --- scripts/intval3-install.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/intval3-install.sh b/scripts/intval3-install.sh index 5bf922c..6fbd807 100644 --- a/scripts/intval3-install.sh +++ b/scripts/intval3-install.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo "Running intval3 install script" +echo "Running intval3 install script (this will take a while)..." sudo apt update sudo apt install git ufw nginx jq -y @@ -26,10 +26,19 @@ sudo ufw enable echo "Installing intval3 project..." wget https://github.com/sixteenmillimeter/intval3/archive/master.zip -unzip master.zip -d intval3/ +unzip master.zip rm master.zip - +mv intval3-master/ intval3/ cd intval3 + +echo "Configure nginx..." + +cp nginx.conf /etc/nginx/sites-available/intval3 +ln -s /etc/nginx/sites-available/intval3 /etc/nginx/sites-enabled/intval3 +rm /etc/nginx/sites-enabled/default + +echo "Install node" + npm install sudo pm2 start process.json From 58e6ba04585a68ce860f5ff80862246db5fdea8f Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sun, 7 Oct 2018 16:00:35 -0400 Subject: [PATCH 06/11] Initial nginx configuration file --- nginx.conf | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 nginx.conf diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..1e56831 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,36 @@ + +#uncomment to host with ssl and redirect from http +#not advised + +#server { +# listen 80; +# server_name example.com; +# return 301 https://$server_name$request_uri; +#} + +server { + listen 80; + #listen 443 ssl; + + #ssl on; + #ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; + #ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; + + #ssl_session_timeout 5m; + #ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + #ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; + #ssl_prefer_server_ciphers on; + + server_name intval3.local; + + location / { + proxy_pass http://127.0.0.1:6699/; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Real-IP $remote_addr; + #no need for gzip at this time, adds processing overhead + #gzip on; + #gzip_comp_level 5; + #gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json; + } +} \ No newline at end of file From 1517cd031f86b6a2bd7aceea77d1c1a3ccd5afec Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sun, 7 Oct 2018 17:05:51 -0400 Subject: [PATCH 07/11] Add necessary step for wifi configuration --- howto/RaspberryPiZeroW.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/howto/RaspberryPiZeroW.md b/howto/RaspberryPiZeroW.md index 07f5592..e594289 100644 --- a/howto/RaspberryPiZeroW.md +++ b/howto/RaspberryPiZeroW.md @@ -21,7 +21,17 @@ From [learn.adafruit.com](https://learn.adafruit.com/turning-your-raspberry-pi-z ```sudo nano /etc/network/interfaces``` -Add at the end: +Enable wlan0 by adding the following lines: + +``` +allow-hotplug wlan0 +iface wlan0 inet manual + wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf +``` + +Enable with ```sudo systemctl enable wpa_supplicant.service```. + +For usb connection, add at the end: ``` allow-hotplug usb0 From ca1d0c4bb742fa107d0ee89aaa9e97cb9ecf4ba2 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sun, 7 Oct 2018 17:16:04 -0400 Subject: [PATCH 08/11] Install and add state directory for gpio --- scripts/intval3-install.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/intval3-install.sh b/scripts/intval3-install.sh index 6fbd807..41c0bc2 100644 --- a/scripts/intval3-install.sh +++ b/scripts/intval3-install.sh @@ -1,6 +1,7 @@ #!/bin/bash echo "Running intval3 install script (this will take a while)..." +cd sudo apt update sudo apt install git ufw nginx jq -y @@ -25,17 +26,18 @@ sudo ufw allow https sudo ufw enable echo "Installing intval3 project..." -wget https://github.com/sixteenmillimeter/intval3/archive/master.zip -unzip master.zip -rm master.zip -mv intval3-master/ intval3/ +mkdir state +git clone https://github.com/sixteenmillimeter/intval3.git cd intval3 echo "Configure nginx..." -cp nginx.conf /etc/nginx/sites-available/intval3 -ln -s /etc/nginx/sites-available/intval3 /etc/nginx/sites-enabled/intval3 -rm /etc/nginx/sites-enabled/default +sudo cp nginx.conf /etc/nginx/sites-available/intval3 +sudo ln -s /etc/nginx/sites-available/intval3 /etc/nginx/sites-enabled/intval3 +sudo rm /etc/nginx/sites-enabled/default + +sudo nginx -t +sudo service nginx restart echo "Install node" From f86ab024621248562c46dad24c77fecb2ec8f34c Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sun, 7 Oct 2018 17:16:22 -0400 Subject: [PATCH 09/11] Update nginx config to use static dir --- nginx.conf | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/nginx.conf b/nginx.conf index 1e56831..6d155e4 100644 --- a/nginx.conf +++ b/nginx.conf @@ -9,7 +9,8 @@ #} server { - listen 80; + listen 80 default_server; + listen [::]:80 default_server; #listen 443 ssl; #ssl on; @@ -33,4 +34,16 @@ server { #gzip_comp_level 5; #gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json; } + + location /static/ { + alias /home/pi/intval3/app/www/static/; + + #uncomment to turn on caching + #expires modified 1y; + access_log off; + #add_header Cache-Control "public"; + gzip on; + gzip_comp_level 5; + gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/json; + } } \ No newline at end of file From d81d3a714b0b39e0ec296dee78bb0f7a41f48f36 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Sun, 7 Oct 2018 17:26:00 -0400 Subject: [PATCH 10/11] Add pm2 save and pm2 startup --- scripts/intval3-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/intval3-install.sh b/scripts/intval3-install.sh index 41c0bc2..2c6ab53 100644 --- a/scripts/intval3-install.sh +++ b/scripts/intval3-install.sh @@ -43,5 +43,7 @@ echo "Install node" npm install sudo pm2 start process.json +sudo pm2 save +sudo pm2 startup echo "Finished installing intval3" \ No newline at end of file From 23429ae359690753a847ba5ea796ebcd3555c987 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Tue, 9 Oct 2018 15:38:30 -0400 Subject: [PATCH 11/11] Tweak intval key for new bearings --- hardware/case.scad | 2 +- hardware/intval3.scad | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hardware/case.scad b/hardware/case.scad index 01edace..48387fc 100644 --- a/hardware/case.scad +++ b/hardware/case.scad @@ -408,7 +408,7 @@ module bearing (x, y, z, width= 8, hole = true, calval = 0) { module key_cap () { $fn = 60; thickness = .75; - innerD = 22.1; + innerD = 22.5; outerD = innerD + (thickness * 2); h = 18 - 2.5; diff --git a/hardware/intval3.scad b/hardware/intval3.scad index e8440ad..3761306 100644 --- a/hardware/intval3.scad +++ b/hardware/intval3.scad @@ -44,7 +44,7 @@ module exploded_view () { //intval_laser_panel_cover(true, ALL_RED=true); //rotate([0, 0, 13]) intval_panel_laser(); //rotate([0, 0, 13]) intval_laser_panel_cover(); -//key_cap(); +rotate([0, 180, 0]) key_cap(); //geared_motor_mount_120(); //motor_key(); //motor_key_120(); @@ -56,5 +56,5 @@ module exploded_view () { //translate([0, 0, 39 / 2 + 5.75]) bolt_guide(); //exploded_view(); -stl_plate(); +//stl_plate(); //dxf_plate(); \ No newline at end of file