diff --git a/app/client/app.js b/app/client/app.js
index 03ea271..f1f2201 100644
--- a/app/client/app.js
+++ b/app/client/app.js
@@ -1,15 +1,15 @@
if (Meteor.isClient) {
Template.display.helpers({
- temperatures: function () {
- return Temperatures.find({}, {sort: {created_at: -1}})
+ sensorDataCollection: function () {
+ return SensorData.find({}, {sort: {created_at: -1}})
}
});
Template.display.events({
});
- Template.temperature.helpers({
+ Template.sensorData.helpers({
created_at_formatted: function() {
return moment(this.created_at).format("DD.MM.YYYY, hh:mm")
}
diff --git a/app/client/display.html b/app/client/display.html
index 03cf7be..f58e5f3 100644
--- a/app/client/display.html
+++ b/app/client/display.html
@@ -1,7 +1,7 @@
- {{#each temperatures}}
- {{> temperature}}
+ {{#each sensorDataCollection}}
+ {{> sensorData}}
{{/each}}
diff --git a/app/client/sensorData.html b/app/client/sensorData.html
new file mode 100644
index 0000000..d72211c
--- /dev/null
+++ b/app/client/sensorData.html
@@ -0,0 +1,3 @@
+
+ {{owner}} / {{temperatureValue}}°C / {{humidityValue}}% / {{created_at_formatted}}
+
diff --git a/app/client/temperature.html b/app/client/temperature.html
deleted file mode 100644
index a99f3e2..0000000
--- a/app/client/temperature.html
+++ /dev/null
@@ -1,3 +0,0 @@
-
- {{owner}} / {{value}}°C / {{created_at_formatted}}
-
diff --git a/app/common/collections.js b/app/common/collections.js
index aaa8038..d43b7be 100644
--- a/app/common/collections.js
+++ b/app/common/collections.js
@@ -1,2 +1,2 @@
-Temperatures = new Mongo.Collection("temperatures");
+SensorData = new Mongo.Collection("sensorData");
diff --git a/app/server/startup.js b/app/server/startup.js
index f1caf9f..2821300 100644
--- a/app/server/startup.js
+++ b/app/server/startup.js
@@ -9,12 +9,13 @@ if (Meteor.isServer) {
prettyJson: true
});
- Api.addRoute('temperatures', {
+ Api.addRoute('sensorData', {
authRequired: false
}, {
post: function() {
- Temperatures.insert({
- value: parseFloat(this.bodyParams.value),
+ SensorData.insert({
+ temperatureValue: parseFloat(this.bodyParams.temperatureValue),
+ humidityValue: parseFloat(this.bodyParams.humidityValue),
owner: this.bodyParams.owner,
created_at: new Date()
});
diff --git a/controller/controller.py b/controller/controller.py
index ae37883..ae53570 100644
--- a/controller/controller.py
+++ b/controller/controller.py
@@ -5,13 +5,13 @@ import Adafruit_DHT
GPIO_PIN = 4
-TEMPERATURE_URL = 'http://tfm.meteor.com/api/temperatures'
+SENSORDATA_URL = 'http://tfm.meteor.com/api/sensorData'
SENSOR_TYPE = Adafruit_DHT.DHT11
if len(sys.argv) == 2:
owner = sys.argv[1]
else:
- print 'usage: sudo ./conntroler.py [OWNER]#'
+ print 'usage: sudo ./controller.py [OWNER]#'
print 'example: sudo ./controller.py Senad - Send temperature as Senad'
sys.exit(1)
@@ -26,9 +26,10 @@ humidity, temperature = Adafruit_DHT.read_retry(SENSOR_TYPE, GPIO_PIN)
# the results will be null (because Linux can't
# guarantee the timing of calls to read the sensor).
# If this happens try again!
-if temperature is not None:
- response = requests.post(TEMPERATURE_URL, json={"owner": owner, "value": temperature})
+if temperature is not None and humidity is not None:
+ response = requests.post(SENSORDATA_URL, json={"owner": owner, "temperatureValue": temperature, "humidityValue":humidity})
print 'Temp={0:0.1f}*C'.format(temperature)
+ print 'Humidity={0:0.1f}%'.format(humidity)
if response.status_code != 200:
print 'Failed to send temperature!'
sys.exit(2)