-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created service to getData from greenhouse
- Loading branch information
Showing
24 changed files
with
649 additions
and
27 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
############################################################################# | ||
# | ||
# Makefile for librf24 examples on Raspberry Pi | ||
# | ||
# License: GPL (General Public License) | ||
# Author: gnulnulf <[email protected]> | ||
# Date: 2013/02/07 (version 1.0) | ||
# | ||
# Description: | ||
# ------------ | ||
# use make all and make install to install the examples | ||
# You can change the install directory by editing the prefix line | ||
# | ||
prefix := /usr/local | ||
|
||
ARCH=armv6zk | ||
ifeq "$(shell uname -m)" "armv7l" | ||
ARCH=armv7-a | ||
endif | ||
|
||
# Detect the Raspberry Pi from cpuinfo | ||
#Count the matches for BCM2708 or BCM2709 in cpuinfo | ||
RPI=$(shell cat /proc/cpuinfo | grep Hardware | grep -c BCM2708) | ||
ifneq "${RPI}" "1" | ||
RPI=$(shell cat /proc/cpuinfo | grep Hardware | grep -c BCM2709) | ||
endif | ||
|
||
ifeq "$(RPI)" "1" | ||
# The recommended compiler flags for the Raspberry Pi | ||
CCFLAGS=-Ofast -mfpu=vfp -mfloat-abi=hard -march=$(ARCH) -mtune=arm1176jzf-s -std=c++0x | ||
endif | ||
|
||
|
||
# define all programs | ||
PROGRAMS = createFile addFile telemetryNetwork | ||
SOURCES = ${PROGRAMS:=.cpp} | ||
|
||
all: ${PROGRAMS} | ||
|
||
${PROGRAMS}: ${SOURCES} | ||
g++ ${CCFLAGS} -Wall -I../ $@.cpp -lrf24-bcm -lrf24network -lsqlite3 -o $@ | ||
|
||
clean: | ||
rm -rf $(PROGRAMS) | ||
|
||
install: all | ||
test -d $(prefix) || mkdir $(prefix) | ||
test -d $(prefix)/bin || mkdir $(prefix)/bin | ||
for prog in $(PROGRAMS); do \ | ||
install -m 0755 $$prog $(prefix)/bin; \ | ||
done | ||
|
||
.PHONY: install |
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#include <iostream> | ||
#include <stdio.h> | ||
#include <fstream> | ||
#include <ctime> | ||
|
||
using namespace std; | ||
|
||
|
||
|
||
int main() | ||
{ | ||
|
||
time_t ttime = time(0); | ||
tm* gmt_time = localtime(&ttime); | ||
|
||
//time_t ttime = time(0); | ||
/*//tm* gmt_time = localtime(&ttime); | ||
cout << gmt_time->tm_mday << "/" | ||
<< 1 + gmt_time->tm_mon << "/" | ||
<< 1900 + gmt_time->tm_year << " " | ||
<< gmt_time->tm_hour << ":" | ||
<< gmt_time->tm_min << ":" | ||
<< gmt_time->tm_sec << endl;*/ | ||
|
||
//Date | ||
int day = gmt_time->tm_mday; | ||
int month = 1 + gmt_time->tm_mon; | ||
int year = 1900 + gmt_time->tm_year; | ||
//Hour | ||
int hour = gmt_time->tm_hour; | ||
int min = gmt_time->tm_min; | ||
int second = gmt_time->tm_sec; | ||
string space = " "; | ||
string slash = "/"; string points = ":"; string fecha = to_string(day) + slash + to_string(month) + slash + to_string(year) + space + to_string(hour) + points + to_string(min) + points + to_string(second); | ||
printf("%s\n",fecha.c_str()); | ||
|
||
/* | ||
// file pointer | ||
std::fstream fout; | ||
// opens an existing csv file or creates a new file. | ||
fout.open("weatherData.csv", ios::out | ios::app); | ||
//Header Doc | ||
fout << << ", " | ||
<< 11 << ", " | ||
<< 11 << ", " | ||
<< 11 << ", " | ||
<< 11 << ", " | ||
<< 11 << ", " | ||
<< 11 << ", " | ||
<< 11 << ", " | ||
<< 22 << ", " | ||
<< 22 << ", " | ||
<< 22 << ", " | ||
<< 22 << ", " | ||
<< 22 << ", " | ||
<< 22 << ", " | ||
<< 22 << ", " | ||
<< 33 << ", " | ||
<< 33 << ", " | ||
<< 33 << ", " | ||
<< 33 << ", " | ||
<< 33 << ", " | ||
<< 33 << ", " | ||
<< 33 << ", " | ||
<< 44 << ", " | ||
<< 44 << ", " | ||
<< 44 << ", " | ||
<< 44 << ", " | ||
<< 44 << ", " | ||
<< 44 << ", " | ||
<< 44 << ", " | ||
<< 55 << ", " | ||
<< 55 << ", " | ||
<< 55 << ", " | ||
<< 55 << ", " | ||
<< 55 << ", " | ||
<< 55 << ", " | ||
<< 55 <<"\n"; | ||
fout.close(); | ||
*/ | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <iostream> | ||
#include <stdio.h> | ||
#include <fstream> | ||
|
||
using namespace std; | ||
|
||
|
||
int main() | ||
{ | ||
// file pointer | ||
std::fstream fout; | ||
// opens an existing csv file or creates a new file. | ||
fout.open("weatherData.csv", ios::out | ios::app); | ||
|
||
//Header Doc | ||
fout << "dateCaptured" << ", " | ||
<< "airTempSensationOne" << ", " | ||
<< "airHumSensationOne" << ", " | ||
<< "airTempOne" << ", " | ||
<< "airHumOne" << ", " | ||
<< "earthTempOne" << ", " | ||
<< "earthHumOne" << ", " | ||
<< "lightOne" << ", " | ||
|
||
<< "airTempSensationTwo" << ", " | ||
<< "airHumSensationTwo" << ", " | ||
<< "airTempTwo" << ", " | ||
<< "airHumTwo" << ", " | ||
<< "earthTempTwo" << ", " | ||
<< "earthHumTwo" << ", " | ||
<< "lightTwo" << ", " | ||
|
||
<< "airTempSensationThree" << ", " | ||
<< "airHumSensationThree" << ", " | ||
<< "airTempThree" << ", " | ||
<< "airHumThree" << ", " | ||
<< "earthTempThree" << ", " | ||
<< "earthHumThree" << ", " | ||
<< "lightThree" << ", " | ||
|
||
<< "airTempSensationFour" << ", " | ||
<< "airHumSensationFour" << ", " | ||
<< "airTempFour" << ", " | ||
<< "airHumFour" << ", " | ||
<< "earthTempFour" << ", " | ||
<< "earthHumFour" << ", " | ||
<< "lightFour" << ", " | ||
|
||
<< "airTempSensationFive" << ", " | ||
<< "airHumSensationFive" << ", " | ||
<< "airTempFive" << ", " | ||
<< "airHumFive" << ", " | ||
<< "earthTempFive" << ", " | ||
<< "earthHumFive" << ", " | ||
<< "lightFive" << ", " | ||
<< "statusCloud" << ", " | ||
<< "timeSent" << "\n"; | ||
|
||
fout.close(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//crear base de dados desde terminal | ||
sqlite3 sensordata.db | ||
|
||
//Iniciar a crear tablas dentro de db sensordata | ||
BEGIN; | ||
|
||
//crear tablas | ||
CREATE TABLE greenhouseData (id INTEGER PRIMARY KEY AUTOINCREMENT, currentdate DATE, airTempSensationOne REAL, airHumSensationOne REAL, airTempOne REAL, airHumOne REAL, earthTempOne REAL, earthHumOne REAL, lightOne INTEGER, airTempSensationTwo REAL, airHumSensationTwo REAL, airTempTwo REAL, airHumTwo REAL, earthTempTwo REAL, earthHumTwo REAL, lightTwo INTEGER, airTempSensationThree REAL, airHumSensationThree REAL, airTempThree REAL, airHumThree REAL, earthTempThree REAL, earthHumThree REAL, lightThree INTEGER, airTempSensationFour REAL, airHumSensationFour REAL, airTempFour REAL, airHumFour REAL, earthTempFour REAL, earthHumFour REAL, lightFour INTEGER, airTempSensationFive REAL, airHumSensationFive REAL, airTempFive REAL, airHumFive REAL, earthTempFive REAL, earthHumFive REAL, lightFive INTEGER); | ||
|
||
|
||
//EJECUTAR TODOS LOS DATOS | ||
COMMIT; | ||
|
||
|
||
|
||
//VER LAS TABLAS CREADAS | ||
.tables | ||
|
||
|
||
//ver el esquema de la tablas | ||
.fullschema | ||
|
||
|
||
//INSERT | ||
sqlite> BEGIN; | ||
sqlite> INSERT INTO dhtreadings (temperatura , humedad , fecha actual, hora actual , dispositivo) valores (22.4, 48, fecha ('ahora'), hora ('ahora'), "manual"); | ||
sqlite> COMMIT; | ||
|
||
|
||
MAKEFILE SE DEBE MODIFICAR PARA AGREGAR SQLITE | ||
${PROGRAMS}: ${SOURCES} | ||
g++ ${CCFLAGS} -Wall -I../ [email protected] -lrf24-bcm -lrf24network -lsqlite3 -o $@ | ||
|
||
|
||
|
||
//Modificar tabla desde el cli de SQLITE | ||
|
||
sqlite> SELECT * FROM greenhouseData; | ||
1|2020-08-09 08:26:05|1.95|1.06|1.0|13.1|19.3|8.9|12.6|1.95|1.06|1.0|13.1|19.3|8.9|12.6|1.95|1.06|1.0|13.1|19.3|8.9|12.6|1.95|1.06|1.0|13.1|19.3|8.9|12.6|1.95|1.06|1.0|13.1|19.3|8.9|12.6 | ||
2|2020-08-09 08:26:09|1.67|1.68|17.3|3.7|3.7|16.2|2.7|1.67|1.68|17.3|3.7|3.7|16.2|2.7|1.67|1.68|17.3|3.7|3.7|16.2|2.7|1.67|1.68|17.3|3.7|3.7|16.2|2.7|1.67|1.68|17.3|3.7|3.7|16.2|2.7 | ||
|
||
//BORRA TODOS LOS REGUISTROS DE LA TABLA | ||
sqlite> DELETE FROM greenhouseData; | ||
//REINICIA EL CONTADOR DE LA TABLA | ||
sqlite> UPDATE SQLITE_SEQUENCE SET SEQ=0 WHERE NAME='greenhouseData'; | ||
//SALE DEL CLI | ||
sqlite> .quit | ||
|
0
sensordata.db → rf24/sensordata.db
100644 → 100755
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Service cron to get data of Nodes in greenhouse and save in csv and sqliteDB | ||
After=multi-user.target | ||
|
||
[Service] | ||
Type=idle | ||
ExecStart=/home/pi/iot/rf24/telemetryNetwork | ||
StandardOutput=inherit | ||
StandardError=inherit | ||
Restart=always | ||
User=pi | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
|
Binary file not shown.
Oops, something went wrong.