View it live at IPSA Weather Station
... so far
Or
Click here for details about sensors and connections
DT80M Datalogger - details
//Create a TCP socket to read data from datalogger var tcp_socket = net.createConnection(TCP_PORT, TCP_HOST); tcp_socket.on('connect', function(connect) { // Send this string to set the output format for the Datalogger tcp_socket.write("/h/E/M/R"); console.log('connection established with TCP host: ' + TCP_HOST); tcp_socket.setEncoding('ascii'); });
//Connect to the database - using the module mongojs - which exposes mongodb like API var db = require("mongojs").connect(databaseUrl, collections); //Insert data - now formatted to dbString - into the collection raw_data db.raw_data.insert(dbString, function(err, saved) { if( err || !saved ) console.log("Data not saved"); else console.log("Data saved"); });
// Save the cloud db on MongoLab mongodb.MongoClient.connect(uri, function (err, cloud_db) { cloud_db.collection('raw_data', function(err, collection) { if(!err) { collection.insert(dbString, function(docs) { collection.count(function(err, count) { if(!err) { console.log("Saved to mongolab"); } }); }); } }); });
To OpenWeatherMap.org
// Upload data to openweathermap.org request.post(url_owm, {form:{'temp':dbString.temp_c, 'wind_dir': dbString.wind_dir, 'wind_speed': dbString.wind_speed_mps, 'humidity': dbString.humidity, 'pressure': dbString.pressure_mbar, 'lat': dbString.lat, 'long': dbString.long, 'lum': dbString.solar_rad_wpsqm, 'name': "AWSIES1" }}, function optionalCallback (err, httpResponse, body) { if (err) { return console.error('upload failed:', err); } console.log('Upload successful on OWM! Server responded with:', body); });
On the server
// Hook Socket.io into Express var io = require('socket.io').listen(server); tcp_socket.on('data', function(data) { // This event is emitted, observe the matching event in the frontend controller. // It receives this sent livedata and updates the view accordingly. io.sockets.emit('livedata', { livedata: data });
On the client
<!-- Include the socket.io - in html scope now --> <script type="text/javascript" src="/socket.io/socket.io.js"></script> var socket = io.connect("103.9.12.125:8000"); socket.on('livedata', function(data) { //Do something with the data
<tbody ng-repeat="weather_row in weatherdata"> <tr> <td>{{ $index + 1 }}</td> <td>{{ weather_row.sensor }}</td> <td>{{ weather_row.value + " " + weather_row.unit }}</td> </tr> </tbody>
... of the weather
all in real-time ... automatically