Git Product home page Git Product logo

stormiks / weather-express Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 597 KB

Service for collecting data on temperature and fluctuations in the body. Based on the HDC1080 sensor. The repository is a clone of its own locally running git server.

JavaScript 14.43% Python 53.83% Less 6.38% EJS 25.36%
arduino dayjs express hdc1080 less nodejs raspberry-pi raspberry-pi-zero-2-w sqlite3 vuejs weather weather-app adafruit i2c smbus sequelize bootstrap3 lessjs ejs debian

weather-express's Introduction

INSTALL TO RASPBERRY PI ZERO 2W (Debian 11)

Tested on Debian 11

  • OS: Raspbian GNU/Linux 11 (bullseye) armv7l
  • Host: Raspberry Pi Zero 2 W Rev 1.0
  • Kernel: 5.15.32-v7+
  • CPU: BCM2835 (4) @ 1.000GHz

Requirements

  • NVM
  • NODE.JS >= 16.17.1

Install and build project

Install dependencies

yarn install --no-lockfile

CRONTAB

Find out the location of the binaries

which node && which sqlite3
crontab -e

Add the following lines to the end:

@reboot sleep 30 && /home/<$USER>/.nvm/versions/node/v16.17.1/bin/node /home/<$USER>/www/weather-express-arduino/app.js < /dev/null & // not recommended
0 */6 * * * /usr/bin/sqlite3 /home/<$USER>/<DB_NAME>.sqlite3 .dump > /home/<$USER>/<DB_NAME>_dump.sql
// or
0 */6 * * * /usr/bin/sqlite3 /home/<$USER>/www/weather-express-arduino/<DB_NAME>.sqlite3 .dump > /home/<$USER>/<DB_NAME>_dump.sql
  • "@reboot sleep 30" // 30 seconds after the system starts, run the project
  • "0 */6 * * *" - // Create a database backup every 6 hours

Systemd service (Recommended)

[Unit]
Description=Weather Application Service
After=network.target

[Service]
WorkingDirectory=/home/<$USER>/www/weather-express-arduino
ExecStart=/home/<$USER>/.nvm/versions/node/v16.17.1/bin/node app.js
Restart=on-failure
User=<$USER>
Environment=PORT=3000

[Install]
WantedBy=multi-user.target

NVM install

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
nvm install 16.17.1
node --version
nvm alias default 16
npm i -g yarn sequelize-cli // Required to install migrations

Additional dependencies

To perform database backups

sudo apt install make cmake gcc sqlite3

NGINX configuration

If you plan to run other node.js applications using NGINX. Then for such applications, there will be approximately the following configuration:

server {
  listen 80;
  server_name example.test www.example.test;
  root /var/www/your_project;

  location / {
    try_files $uri @express;
  }

  location @express {
    proxy_pass http://localhost:3000;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
}

If you plan to open the application page on the local network, then you must specify the "*.test" domain zone, otherwise browsers will be forced to redirect from the "http" protocol to "https". The known methods of bypass checked by me - do not work.


P.S.: When run via "crontab", the database is created in the user's home folder

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.