Pushing data from a sensor to database


I would like to push my data from sensor to a non-sql database.

Let me give a overview of my project outline.

Sensor-->Databse-->Webserver(node.js+express)-->IOS device(RestKit)

As it can be seen, I have a web server developed using node and express. The web server as of now, reads a value from MongoDB database and the value is displayed onto an IOS device.

I would now like to store the values from a sensor to a non-SQL database(Preferably MongoDB).

To test the whole setup i would use Arduino as sensor to measure temperature.

Any suggestion would be really appreciated. Thanks a lot in advance.

12/4/2012 1:54:12 PM

Accepted Answer

You can either use one of the available MongoDB REST interfaces (http://www.mongodb.org/display/DOCS/Http+Interface) or write a very basic one of your own.

Very rough sketch:

// assuming express app and mongodb native module with open collection
app.post('/datapoint', function(req, res) {
    collection.insert(req.body, function(err, record) {
      if (err) return res.send(500, err);
      res.send('Datapoint stored as ' + record.id);
12/4/2012 2:46:24 PM

How is the Arduino hardware connected to the system?

If it is connected directly over the serial port, you can just reuse parts of my code at: Arduino sensor logging with collectd & RRDtool

In this example, I write Arduino measurements to a RRDtool database.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow