Spaniard89
Spaniard89

Reputation: 2419

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.

Upvotes: 1

Views: 3199

Answers (2)

jeroendoggen
jeroendoggen

Reputation: 101

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.

Upvotes: 2

mtsr
mtsr

Reputation: 3142

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);
    });
  });
});

Upvotes: 1

Related Questions