Send DHT11 & SHT10 sensors data through LoRa SX1272 board.

Dependencies:   DHT11 SHTx SX1272Lib mbed

Fork of SX1272-Transmitter by Antoine Boisadam

Files at this revision

API Documentation at this revision

Comitter:
Antoine38
Date:
Tue Mar 28 12:20:45 2017 +0000
Parent:
18:1ee53f77b90d
Child:
20:c4f5299fa99d
Commit message:
Compatibility with SHT10 Soil sensor

Changed in this revision

SHTx.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SHTx.lib	Tue Mar 28 12:20:45 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/NegativeBlack/code/SHTx/#8465801be23f
--- 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);
     }
 }