This code reads a simple temperature value from DHT11 then send via RF24 in every 5 secs.

Dependencies:   DHT11 RF24_fork WakeUp mbed

Files at this revision

API Documentation at this revision

Comitter:
Makodan
Date:
Thu May 03 17:13:20 2018 +0000
Commit message:
First commit to share this project

Changed in this revision

DHT11.lib Show annotated file Show diff for this revision Revisions of this file
RF24.lib Show annotated file Show diff for this revision Revisions of this file
WakeUp.lib Show annotated file Show diff for this revision Revisions of this file
config.h 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 49273053c399 DHT11.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DHT11.lib	Thu May 03 17:13:20 2018 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/fossum_13/code/DHT11/#5da6f6de3e42
diff -r 000000000000 -r 49273053c399 RF24.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RF24.lib	Thu May 03 17:13:20 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/mrcrsch/code/RF24_fork/#0a3f44454ee7
diff -r 000000000000 -r 49273053c399 WakeUp.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WakeUp.lib	Thu May 03 17:13:20 2018 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/Sissors/code/WakeUp/#49ca85e8822f
diff -r 000000000000 -r 49273053c399 config.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.h	Thu May 03 17:13:20 2018 +0000
@@ -0,0 +1,32 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+
+//This header contains calibration data
+
+
+ 
+    #define RadioChannel 90
+    #define DataAddress 0xF0F0F0F0F0
+
+    #define ledpin      PA_8
+    #define unused_pin  PA_1
+    
+    #define nrf_CE      PB_4
+    #define nrf_CSN     PB_3
+    #define spi_SCK     PA_5
+    #define spi_MOSI    PA_7
+    #define spi_MISO    PA_6
+    #define nrf_irq     PA_15 
+    
+    #define i2c_sda     PB_7 
+    #define i2c_scl     PB_6
+    
+    #define RXD         PA_3
+    #define TXD         PA_2
+    
+
+
+#endif
+
+
diff -r 000000000000 -r 49273053c399 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 03 17:13:20 2018 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "config.h"
+#include "RF24.h"
+#include "WakeUp.h"
+#include "Dht11.h"
+
+DigitalOut myled(ledpin);
+Dht11 sensor(RXD);
+RF24 radio(spi_MOSI, spi_MISO, spi_SCK, nrf_CE, nrf_CSN );
+
+
+const int hb = 9999;
+void RadioSetup();
+
+int main(){
+    int s;
+    int temp = 0;
+    myled=1;
+    RadioSetup();
+    radio.stopListening();
+    myled=0;
+    
+     while(1){
+        
+        WakeUp::set_ms(5000);
+        myled=1;
+        deepsleep();
+        myled=0;
+         
+        sensor.read();
+        temp=getCelsius();
+        radio.powerUp();
+        radio.write(&temp, 4);
+        radio.powerDown();
+    }
+}
+    
+    void RadioSetup(){
+    radio.begin();
+    radio.setPALevel(RF24_PA_LOW);
+    radio.setChannel(RadioChannel);
+    radio.setRetries(0,2);
+    radio.enableDynamicAck();
+    radio.enableDynamicPayloads();
+    radio.openWritingPipe(DataAddress);
+    }
\ No newline at end of file
diff -r 000000000000 -r 49273053c399 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 03 17:13:20 2018 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/4eea097334d6
\ No newline at end of file