Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.
/ raspi-temp-report Public archive

Node.js app to monitor and log temperature and humidity data using a Raspberry Pi and a sensor.

License

Notifications You must be signed in to change notification settings

mcdado/raspi-temp-report

Repository files navigation

Temperature Monitor

This is a simple Node.js app to collect ambient data using a DHT22/AM2302 sensor attached to a Raspberry Pi and send it to a datastore (under development, ideally PostgreSQL).

Requirements

Installation

Open an SSH session on your Raspberry Pi, then type the following commands:

git clone https://github.com/mcdado/raspi-temp-report.git # to run on the Pi
cd raspi-temp-report # to run on the Pi
npm run setup # to run on the Pi

Alternatively, you can checkout the project locally on your coding machine, and use the deploy script.

npm run deploy raspberrypi.local # to run on your coding machine

You have to change raspberrypi.local to whatever hostname you Pi has, or even better to the name of the SSH configuration you might have set up.
The deploy script will copy the necessary project files, but will not run the setup on the Pi.
You have to run the setup the first time you deploy the app to the Pi.

Setup the sensor

In .env file declare the id of the sensor as UNITNAME, the type of sensor as UNITTYPE, and the pin to which it is connected with UNITPIN.

Storage: PostgreSQL

Setup PostgreSQL with these tables:

create table sensors (
    id serial PRIMARY KEY,
    name text
);

create table recordings (
    id serial PRIMARY KEY,
    sensor text,
    temperature float(2),
    humidity float(2),
    timestamp timestamp
);

Debugging

You can run the app on the Raspberry Pi in debug mode by running with the dedicated npm script:

npm run debug

Behind the scenes, it will will run node app.js with the inspect flag, binded on the Raspberry Pi's IP address and port 9229. Now you can use Visual Studio Code's built-in debugging tools to start a Debug session.

Releases

No releases published

Packages

No packages published