A very basic nodejs REST api to store data from a DHT11 module using mongodb. Basically send your data from your client to a server and store it in a database. Useful for remote-access to the data. I used this to monitor our temperature & humidity in our office with a raspberry-pi
- Install nodejs
- Install npm
- Clone or download this repo
- Run
npm install
in the root directory of this repo - Add a
/config/
folder and create adb.js
file in it - Add this code to your
db.js
file:
module.exports = {
url : <username>:<password>@<your-database-ip>
}
- Run
npm start
in the root directory of this repo
This API requires a specific data pattern in x-www-form-urlencoded
form:
id
: the id of your client. This is designed to support multiple clients. Just choose a unique one for each one. Can be a numer like1
or a string likelivingroom
time
: a timestamp in the following format:yyyy-MM-dd HH:mm:ss.ffffff
where y = year, M = month, d = day, H = hour, m = minute, s = second, f = fraction of secondtemp
: your temperature measurementhum
: your humidity measurement Just sendPOST
requests with your data to<your-ip>:8000/entries
.
To GET
your data back (in JSON format) send a request to <your-ip>:8000/entries/<your-pi-id>
Caution! There is no form of authentication when using this. Temperature and humidity aren't really sensible data, but you never know...