Key Features • Hardware Requirements • Install • How To Use • Credits • License
- control your garden via web interface
- log temperature, humidity and soil status automatically
- control your water pump remotely (or any other device your relais support)
- full authentication support for security
- Raspberry Pi 3
- DHT11 Sensor
- Soil Moisture Sensor
- Relais
- A bunch of Dupont cables
Before we can run this, your raspberry pi must be set up.
I'll assume you have raspbian running already, and have ssh access or direct access to your Pi.
First we want to update our packages
sudo apt-get update
sudo apt-get upgrade
This is gonna be our web server that will handle http requests and pass them to our NodeJS application.
Install nginx
sudo apt-get install nginx
Start the service
sudo /etc/init.d/nginx start
Nginx keeps the configuration file for each application it serves in the sites-available
folder: cd /etc/nginx/sites-available/
You can either modify the default
one, or create your own.
The file should look like this
server {
listen 80;
root /var/www/my-app/; # identifies the location of the application you are configuring
server_name my-app.dev; # identifies the hostname used by this application's traffic
location / {
proxy_pass http://localhost:8080/; # configures the back-end destination for this traffic
}
}
Then we can restart nginx to reload the settings
sudo service nginx reload
To download the most recent LTS version use the following command
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
Now we can install it by running
sudo apt-get install -y nodejs
Once this is completed, we can check if node is available by typing
node --version
We'll be using mongodb as our database server.
Install it by typing
sudo apt-get install mongodb-server
Then start the service with
sudo service mongod start
You can test if it worked out by typing
mongo
This should put you into the mongo shell, where you can execute mongodb commands
TODO
If you want to test the application on windows, you should know that you can only test the webapp as we wont have access to the Raspberry Pi GPIO ports if we're not running on the Raspberry Pi directly.
You'll need to have those packages installed on your machine as well:
on raspberry pi the only supported mongoose version is 4.x, due to the last MongoDB x32 version being 2.4. So make sure package.json read
"mongoose": "^4.0.14",
for your raspberry pi. http://mongoosejs.com/docs/compatibility.html
- pm2:
sudo env PATH=$PATH:/usr/local/bin pm2 startup systemd -u pi --hp /home/pi
- Google Search