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 installin the root directory of this repo - Add a
/config/folder and create adb.jsfile in it - Add this code to your
db.jsfile:
module.exports = {
url : <username>:<password>@<your-database-ip>
}- Run
npm startin 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 like1or a string likelivingroomtime: a timestamp in the following format:yyyy-MM-dd HH:mm:ss.ffffffwhere y = year, M = month, d = day, H = hour, m = minute, s = second, f = fraction of secondtemp: your temperature measurementhum: your humidity measurement Just sendPOSTrequests 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...