Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SX1272PingPong by
Diff: main.cpp
- Revision:
- 19:e50e4a513de1
- Parent:
- 18:1ee53f77b90d
- Child:
- 21:307b5bf141cb
diff -r 1ee53f77b90d -r e50e4a513de1 main.cpp
--- a/main.cpp Mon Mar 13 17:23:03 2017 +0000
+++ b/main.cpp Tue Mar 28 12:20:45 2017 +0000
@@ -5,10 +5,14 @@
#include "debug.h"
// DHT11 Lib (air temperature and humidity)
#include "DHT11.h"
+// SHT10 (soil temperature and humidity)
+#include "SHTx/sht15.hpp"
/* Set this flag to '1' to display debug messages on the console */
#define DEBUG_MESSAGE 1
+/* DELAY between two transmission (in seconds) */
+#define DELAY 1800
#define RF_FREQUENCY 868000000 // Hz
#define TX_OUTPUT_POWER 14 // 14 dBm
@@ -57,9 +61,12 @@
int msglen = 0;
// Air temperature and humidity sensor
-DHT11 d(D6);
+DHT11 airSensor(D6);
int DHT11_state;
+// Soil temperature and humidity sensor
+SHTx::SHT15 soilSensor(D9, D8);
+
int main()
{
uint8_t i;
@@ -90,6 +97,11 @@
LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
LORA_CRC_ENABLED, LORA_FHSS_ENABLED, LORA_NB_SYMB_HOP,
LORA_IQ_INVERSION_ON, 2000000 );
+
+ // Soil sensor configuration
+ soilSensor.setOTPReload(false);
+ soilSensor.setResolution(true);
+ soilSensor.setScale(false);
debug_if( DEBUG_MESSAGE, "Starting sending loop\r\n" );
@@ -97,9 +109,11 @@
while(1) {
// Retrieving sensors data
- DHT11_state = d.readData();
+ DHT11_state = airSensor.readData();
if (DHT11_state == DHT11::OK) {
- sprintf((char*) msg, "Temp=%d \r\nHumi=%d \r\n", d.readTemperature(), d.readHumidity());
+ sprintf((char*) msg, "TempA=%d \r\nHumiA=%d \r\nTempS=%3.2f \r\nHumiS=%3.2f \r\n", airSensor.readTemperature(), airSensor.readHumidity(), soilSensor.getTemperature(), soilSensor.getHumidity());
+ } else {
+ sprintf((char*) msg, "TempS=%3.2f \r\nHumiS=%3.2f \r\n", soilSensor.getTemperature(), soilSensor.getHumidity());
}
// Sending a new packet
@@ -116,8 +130,8 @@
// Reversing the led state
led = 1-led;
- // wait 3 seconds before resend data
- wait(3);
+ // wait DELAY seconds before resend data
+ wait(DELAY);
}
}
