add SD support for capteur
This commit is contained in:
parent
b454c04c48
commit
1d1b20e5c3
11
IOT/Capteur/.vscode/settings.json
vendored
11
IOT/Capteur/.vscode/settings.json
vendored
@ -1,6 +1,15 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.html": "html",
|
"*.html": "html",
|
||||||
"cmath": "cpp"
|
"cmath": "cpp",
|
||||||
|
"array": "cpp",
|
||||||
|
"deque": "cpp",
|
||||||
|
"list": "cpp",
|
||||||
|
"string": "cpp",
|
||||||
|
"unordered_map": "cpp",
|
||||||
|
"vector": "cpp",
|
||||||
|
"string_view": "cpp",
|
||||||
|
"initializer_list": "cpp",
|
||||||
|
"ranges": "cpp"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -66,3 +66,7 @@ build_flags =
|
|||||||
-D LORA_SPI_MOSI=G_MOSI
|
-D LORA_SPI_MOSI=G_MOSI
|
||||||
|
|
||||||
-D LORA_FREQUENCY=433
|
-D LORA_FREQUENCY=433
|
||||||
|
|
||||||
|
-D USE_SD_LOG
|
||||||
|
-D SD_SS=SD_CS
|
||||||
|
-D LOG_FILENAME=\"log_capteur_01.txt\"
|
@ -2,17 +2,9 @@
|
|||||||
// #include <esp8266WiFi.h>
|
// #include <esp8266WiFi.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
// FARM DATA RELAY SYSTEM
|
|
||||||
//
|
|
||||||
// LoRa Sensor Example
|
|
||||||
//
|
|
||||||
// Developed by Timm Bogner (timmbogner@gmail.com) in Urbana, Illinois, USA.
|
|
||||||
// An example of how to send data via LoRa using FDRS.
|
|
||||||
//
|
|
||||||
|
|
||||||
// #include "fdrs_node_config.h"
|
|
||||||
#include <fdrs_globals.h>
|
#include <fdrs_globals.h>
|
||||||
#include <fdrs_node.h>
|
#include <fdrs_node.h>
|
||||||
|
#include <SD.h>
|
||||||
|
|
||||||
float readTemp() {
|
float readTemp() {
|
||||||
return 21.0;
|
return 21.0;
|
||||||
@ -29,12 +21,40 @@ float data2;
|
|||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
beginFDRS();
|
beginFDRS();
|
||||||
|
if (!SD.begin(SD_CS)) {
|
||||||
|
Serial.println("Fail, verifier que la carte SD est presente.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
data1 = readHum();
|
data1 = readHum();
|
||||||
loadFDRS(data1, HUMIDITY_T);
|
loadFDRS(data1, HUMIDITY_T);
|
||||||
data2 = readTemp();
|
data2 = readTemp();
|
||||||
loadFDRS(data2, TEMP_T);
|
loadFDRS(data2, TEMP_T);
|
||||||
sendFDRS();
|
sendFDRS();
|
||||||
|
|
||||||
|
File dataFile = SD.open(LOG_FILENAME, FILE_WRITE);
|
||||||
|
if (dataFile) {
|
||||||
|
DBG("SD OK");
|
||||||
|
dataFile.print("[{\"id\":");
|
||||||
|
dataFile.print(READING_ID);
|
||||||
|
dataFile.print(",\"type\":");
|
||||||
|
dataFile.print(HUMIDITY_T);
|
||||||
|
dataFile.print(",\"data\":");
|
||||||
|
dataFile.print(data1);
|
||||||
|
dataFile.print("},{\"id\":");
|
||||||
|
dataFile.print(READING_ID);
|
||||||
|
dataFile.print(",\"type\":");
|
||||||
|
dataFile.print(TEMP_T);
|
||||||
|
dataFile.print(",\"data\":");
|
||||||
|
dataFile.print(data2);
|
||||||
|
dataFile.println("}]");
|
||||||
|
dataFile.close();
|
||||||
|
}else{
|
||||||
|
DBG("SD fail");
|
||||||
|
}
|
||||||
|
|
||||||
|
// [{"id":2,"type":3,"data":66},{"id":2,"type":1,"data":21}]
|
||||||
sleepFDRS(10); //Sleep time in seconds
|
sleepFDRS(10); //Sleep time in seconds
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user