Added gm3
This commit is contained in:
@@ -13,7 +13,7 @@ Create database: `create database dhtstats;`
|
||||
|
||||
Use database: `use dhtstats`
|
||||
|
||||
Create new table: `CREATE TABLE stats (id MEDIUMINT NOT NULL AUTO_INCREMENT, node_id int not null, pin int not null, humidity FLOAT NOT NULL, temperature FLOAT NOT NULL, isoutside int not null, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) );`
|
||||
Create new table: `CREATE TABLE stats (id MEDIUMINT NOT NULL AUTO_INCREMENT, node_id int not null, pin int not null, humidity FLOAT NOT NULL, temperature FLOAT NOT NULL, isoutside int not null, gm3 float not null, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) );`
|
||||
|
||||
Show all entries in table: `select * from stats;`
|
||||
|
||||
|
@@ -78,6 +78,7 @@ float absoluteHumidity(sensor *sensor) {
|
||||
}
|
||||
|
||||
int compareSensors(sensor *inside, sensor *outside) {
|
||||
//returns 1 if window should be opened
|
||||
if (absoluteHumidity(inside) <= absoluteHumidity(outside)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -8,6 +8,8 @@
|
||||
#include "restcurl.h"
|
||||
#include <string.h>
|
||||
|
||||
//Temporary include
|
||||
#include "calculate.h"
|
||||
|
||||
void freeNodeLinkedList(sensornode *node) {
|
||||
void *victim;
|
||||
@@ -61,7 +63,7 @@ int main(void) {
|
||||
nodedata.isoutside = currentNode->isoutside; //copy the boolean value
|
||||
printf("Acquiring rest response\n");
|
||||
|
||||
printf("Temperature: %f, Humidity: %f, NodeID: %i, Outside: %s\n", nodedata.temperature, nodedata.humidity, nodedata.node_id, nodedata.isoutside ? "Yes" : "No");
|
||||
printf("Temperature: %f, Humidity: %f, NodeID: %i, Outside: %s, AbsoluteHumidity: %f\n", nodedata.temperature, nodedata.humidity, nodedata.node_id, nodedata.isoutside ? "Yes" : "No", absoluteHumidity(nodedata));
|
||||
|
||||
//Insert data into database
|
||||
printf("Insert data into stats table\n");
|
||||
|
@@ -3,6 +3,7 @@
|
||||
//#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "calculate.h"
|
||||
#include "sendmysql.h"
|
||||
|
||||
void insertData(sensor *s) {
|
||||
@@ -42,7 +43,7 @@ void insertData(sensor *s) {
|
||||
char *pquerystring = NULL;
|
||||
|
||||
if (-1 == asprintf(&pquerystring,
|
||||
"INSERT INTO stats (node_id, pin, humidity, temperature, isoutside) VALUES (%i, %i, %f, %f, %i)", s->node_id, s->pin, s->humidity, s->temperature, s->isoutside)) {
|
||||
"INSERT INTO stats (node_id, pin, humidity, temperature, isoutside, gm3) VALUES (%i, %i, %f, %f, %i, %f)", s->node_id, s->pin, s->humidity, s->temperature, s->isoutside, absoluteHumidity(s))) {
|
||||
perror("asprintf() failed");
|
||||
} else {
|
||||
if (mysql_query(conn, pquerystring)) {
|
||||
|
Reference in New Issue
Block a user