Used to automate the startup and shutdown of the laser cutter and all of the dependant devices from a Raspberry Pi
It is also used to control access to the laser. Access is handled by the membership management application.
- install
node, v22 or greater ideally. - create a
./config.jsonfile, see./src/Configuration.tsfor the schema of this file. npm installwill install packages.npm run buildwill compile the typescript code into./dist.npm run startwill compile the code and run it.npm run testwill compile the code and test it.- visit
http://127.0.0.1:3000/to view the running server
NODE_ENV=test npm startdisable mqtt while running (see./comms/MqttManager.ts)npm start -- --gpio-infor testing, type 0+newline or 1+newline to toggle the main switch on and off (see./src/hardware/MockGpio.ts)npm node ./dist/main.jsrun without re-compiling firstNODE_ENV=test npm node ./dist/main.js --gpio-incombine all of the above
This app will check for "ok" status over MQTT before allowing the laser switch to be unlocked. This status is set by LCC and gives the LCC a quick way to take the laser out of service whenever necessary.
This code is to be run on a raspberry pi at the hack space, with a "hat" board on it that provides the relays, switches, and other connections. Here are instructions for getting it running on a pi:
- Flash Raspbian to an SD card
- user laser passwork hacktheplanet
- Boot the pi from the sd card, and ssh to it or use keyboard+monitor.
- complete any setup you're prompted with.
- Install necessary software:
sudo apt updateupdate package listssudo apt install git vimlife withoutgitandvimis no life at all.- install node. Per instructions here nodesource and the official nodejs builds don't work on a pi v1, so we have to use an unofficial build
wget https://unofficial-builds.nodejs.org/download/release/v22.19.0/node-v22.19.0-linux-armv6l.tar.gztar -xvf node-v22.19.0-linux-armv6l.tar.gzunzip itsudo mv node-vX.X.X-linux-armv6l /usr/local/nodeput it in placecd /usr/binsudo ln -s /usr/local/node/bin/node nodesudo ln -s /usr/local/node/bin/npm npmnode -vverify that the Node.js install workednpm -vverify that the npm install workedecho PATH="/usr/local/node/bin:\$PATH" >> ~/.profileadd node global binaries path to your profilesource ~/.profilereload .profile to activate the new PATH
- checkout this repo, build, and run
git clone https://github.com/vhs/vhs-laser-accesscheckout repocd vhs-laser-accessenter repogit fetch origin stripdown-auth && git checkout stripdown-authfor now, we're using a version off the main branchnpm installinstall repo dependencies- setup a
config.jsonfile with the structure described insrc/Configuration.ts npm startrun for the first time - visit it athttp://laser.local:3000/
- Persist the web app with pm2
sudo npm intall -g pm2installpm2, which starts and restarts the webapp if it crashes or the system rebootspm2 startupfollow instructions - this persists pm2, so it starts on bootpm2 start dist/main.js --name laserrun the apppm2 savemake sure the app re-starts if the system is reset
- Chiller Relay - GPIO17, pin 11 - Green Wire Pin 4
- Ventilation Relay - GPIO27 pin 13 - Orange Wire Pin 5
- Laser Relay - GPIO22 pin 15 - White Wire Pin 3
- Main On/Off Switch - GPIO4 pin 7
- Green LED - GPIO23 pin 16
- Red LED - GPIO24 pin 18
The following pins are used for NFC but it's currently not enabled.
- Buzzer - GPIO18 pin 12
- NFC Reset GPIO25 pin 22
- NFC MOSI GPIO10 pin 19
- NFC MOSO GPIO09 pin 21
- NFC CLK GPIO11 pin 23
- NFC CE0 GPIO08 pin 24
- NFC CE1 GPIO07 pin 26