https://github.com/webcooltz/buddy-lamp
Buddy lamp project for Raspberry Pi - Server (Node JS) and Client (Python)
https://github.com/webcooltz/buddy-lamp
buddy-lamp express iot nodejs python raspberry-pi rpi rpi-zero-w rpi3 rpi4 server
Last synced: 3 months ago
JSON representation
Buddy lamp project for Raspberry Pi - Server (Node JS) and Client (Python)
- Host: GitHub
- URL: https://github.com/webcooltz/buddy-lamp
- Owner: webcooltz
- Created: 2023-06-22T20:47:24.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-26T16:40:46.000Z (about 3 years ago)
- Last Synced: 2025-02-03T09:47:51.891Z (over 1 year ago)
- Topics: buddy-lamp, express, iot, nodejs, python, raspberry-pi, rpi, rpi-zero-w, rpi3, rpi4, server
- Language: JavaScript
- Homepage:
- Size: 65.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# buddy-lamp
A wifi lamp project.
## Server
### Setup
* Download the buddy-lamp folder (only onto one machine in the network).
* Put buddy-lamp folder in the Documents folder.
* Follow the directions below to start up the server on boot.
### Port Forwarding
* You will need to forward ports on your router to allow the server to be accessed from outside your home network.
### Start Server on Boot
#### Create Server Start Script
* Create a shell script called start-server.sh in ~/Documents:
`nano ~/Documents/start-server.sh`
* Paste the following into it:
```
#!/bin/bash
# Navigate to the server folder
cd /home/pi/Documents/buddy-lamp/server || { echo "Server folder not found!"; exit 1; }
# Run npm (use full path to npm)
/usr/bin/npm run start
```
* Make the script executable:
`chmod +x ~/Documents/start-server.sh`
* Create a systemd service:
`sudo nano /etc/systemd/system/buddy-lamp.service`
* Paste the following into it:
```
[Unit]
Description=Buddy Lamp Node Server
After=network.target
[Service]
Type=simple
User=pi
WorkingDirectory=/home/pi/Documents/buddy-lamp/server
ExecStart=/home/pi/Documents/start-server.sh
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
```
#### Enable and Start the Service
* Reload systemd to detect the new service:
`sudo systemctl daemon-reload`
* Enable the service to start on boot:
`sudo systemctl enable buddy-lamp.service`
* Start the service immediately:
`sudo systemctl start buddy-lamp.service`
* Check its status:
`sudo systemctl status buddy-lamp.service`
## Client Setup
### Installing/Running
* Download the `client` repo to your Raspberry Pi.
* Alter the values (see the section below this).
* Open a terminal, go to the directory where the file is.
* Run `python main.py`.
### Customizing
Hard-coding
* Hard-code the values for API URL, household name, and lamp color.