Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 1.44 KB

nodejs-logger.md

File metadata and controls

23 lines (16 loc) · 1.44 KB

Node.js Datalogger

system diagram of a wifi-datalogger, as described below.

Figure 1. System diagram of the node datalogging server

This node-datalogging-server is written in node.js. It has a RESTful API that accepts data formatted as a JSON string in the body of a POST request. The client should send sensor readings in a POST request with a JSON body to the server. The server writes the JSON string to a text file, as diagrammed in Figure 1.

You can also read all the records from the server by making a GET request.

The JSON data in the POST request should look like this:

{
   "uid": client ID (string),
   "location": client physical location (string),
   "lux": client lux reading (number),
   "ct": client color temperature reading (number)
}

You can also include any sensor characteristics that you want to add. The Arduino example in this collection sends light and color temperature levels in lux (lux) and degrees Kelvin (ct), respectively. The server doesn't check the names of the characteristics in the JSON data, so you can add anything you want.

This server can be run on any host that can run node.js. You can see it running on Glitch.com at this link. It also includes a web-based client, as a test example.