sr501/BH1750/mq-2/dht11

Dependencies:   mbed

Fork of sensors_2 by w mx

Revision:
1:1197997ae0ea
Parent:
0:6dca851b4779
Child:
2:cd0ea77c7d66
--- a/sensors.h	Sun Sep 09 13:44:05 2018 +0000
+++ b/sensors.h	Wed Sep 12 15:51:26 2018 +0000
@@ -2,7 +2,28 @@
 #define SENSORS_H
 
 #include "mbed.h"
-//#include <stdlib.h>
+//+++++++++++++++++++++BH1750+++++++++++++++++++++++++++++
+#define BH1750_I2CADDR 0x46
+#define BH1750_POWER_DOWN 0x00                  // No active state
+#define BH1750_POWER_ON 0x01                    // Wating for measurment command
+#define BH1750_RESET 0x07                       // Reset data register value - not accepted in POWER_DOWN mode
+#define BH1750_CONTINUOUS_HIGH_RES_MODE  0x10   // Start measurement at 1lx resolution. Measurement time is approx 120ms.
+#define BH1750_CONTINUOUS_HIGH_RES_MODE_2  0x11 // Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
+#define BH1750_CONTINUOUS_LOW_RES_MODE  0x13    // Start measurement at 4lx resolution. Measurement time is approx 16ms.
+
+// Start measurement at 1lx resolution. Measurement time is approx 120ms.
+// Device is automatically set to Power Down after measurement.
+#define BH1750_ONE_TIME_HIGH_RES_MODE  0x20
+
+// Start measurement at 0.5lx resolution. Measurement time is approx 120ms.
+// Device is automatically set to Power Down after measurement.
+#define BH1750_ONE_TIME_HIGH_RES_MODE_2  0x21
+
+// Start measurement at 1lx resolution. Measurement time is approx 120ms.
+// Device is automatically set to Power Down after measurement.
+#define BH1750_ONE_TIME_LOW_RES_MODE  0x23
+//++++++++++++++++++++++++++++++++++++++++
+
 
 class sr501
 {
@@ -13,12 +34,29 @@
   private:
 //    DigitalIn signal;
     bool status;
-    InterruptIn signal;
+    InterruptIn signal1;
+    DigitalIn signal2;
     void triggered();
   public:
     sr501(PinName pSignal);
-    bool operator ==(const bool &target);
+    bool operator==(const bool &target);
     void reset();
+    int read();
 };
+//=========================================
+class BH1750
+{
+    
+/*****
 
+*****/
+  private:
+    I2C link;
+    char rawdata[2];
+    bool status;
+  public:
+    BH1750(PinName sda,PinName scl);
+    BH1750(PinName sda,PinName scl,char mode[]);
+    float getlightdata();
+};
 #endif