Attic fan controller

Dependencies:   Chainable_RGB_LED DHT ESP8266Interface M2XStreamClient jsonlite mbed

Files at this revision

API Documentation at this revision

Comitter:
cantbewong
Date:
Sun Jan 03 19:03:51 2016 +0000
Commit message:
initial draft

Changed in this revision

Chainable_RGB_LED.lib Show annotated file Show diff for this revision Revisions of this file
DHT.lib Show annotated file Show diff for this revision Revisions of this file
ESP8266Interface.lib Show annotated file Show diff for this revision Revisions of this file
M2XStreamClient.lib Show annotated file Show diff for this revision Revisions of this file
jsonlite.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Chainable_RGB_LED.lib	Sun Jan 03 19:03:51 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Seeed/code/Chainable_RGB_LED/#50d0a66599e1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DHT.lib	Sun Jan 03 19:03:51 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/components/code/DHT/#df22ddf10d75
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ESP8266Interface.lib	Sun Jan 03 19:03:51 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/ESP8266/code/ESP8266Interface/#03fd9333670d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/M2XStreamClient.lib	Sun Jan 03 19:03:51 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/ATT-M2X-team/code/M2XStreamClient/#2610823f7f2e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jsonlite.lib	Sun Jan 03 19:03:51 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/citrusbyte/code/jsonlite/#807034181e02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jan 03 19:03:51 2016 +0000
@@ -0,0 +1,74 @@
+#include "mbed.h"
+#include "ChainableLED.h"
+#include "M2XStreamClient.h"
+#include "ESP8266Interface.h"
+#include "TCPSocketConnection.h"
+
+DigitalOut myled(LED1);
+// ChainableLED(clk, data, number_of_leds)
+ChainableLED color_led(D4, D5, 1);
+#include "DHT.h"
+
+DHT sensor(D3, DHT11);
+DigitalOut relay(D6);
+
+/*
+*  ESP8266 Wifi Config for nucleo 411
+*/
+ESP8266Interface wifi(D8,D2,D3,"SouthHackUp","",115200); // TX,RX,Reset,SSID,Password,Baud 
+
+//
+// Fill these field in from you ATT M2X Account
+//
+char deviceId[] = "<deviceID>"; // Device you want to push to
+char streamName[] = "<streamID>"; // Stream you want to push to
+char m2xKey[] = "<deviceAPIKey>"; // Your M2X API Key or Master API Key
+
+
+int main() {
+// dht related
+    int error = 0;
+    float h = 0.0f, c = 0.0f, f = 0.0f, k = 0.0f, dp = 0.0f, dpf = 0.0f;
+     
+    
+    printf("Starting...\r\n");
+
+    // connect to wifi
+    wifi.init(); //Reset
+    wifi.connect(); //Use DHCP
+    printf("IP Address is %s \n\r", wifi.getIPAddress());    
+    
+    while(1) {
+        // generate random RGB values for LED's
+        uint8_t R = rand();
+        uint8_t G = rand();
+        uint8_t B = rand();
+        // print message to terminal
+        //printf("R=%x,G=%x,B=%x,",R,G,B);
+
+        // ChainableLED.setColorRGB(index_of_led, red, green, blue)
+        color_led.setColorRGB(0, R, G, B);     
+        myled = 1; // LED is ON
+        relay = 1;
+        
+        wait(1.0); // 200 ms
+        
+        
+        myled = 0; // LED is OFF
+        relay = 0;
+        error = sensor.readData();
+        if (0 == error) {
+            c   = sensor.ReadTemperature(CELCIUS);
+            f   = sensor.ReadTemperature(FARENHEIT);
+            k   = sensor.ReadTemperature(KELVIN);
+            h   = sensor.ReadHumidity();
+            dp  = sensor.CalcdewPoint(c, h);
+            dpf = sensor.CalcdewPointFast(c, h);
+            printf("Temperature in Kelvin: %4.2f, Celcius: %4.2f, Farenheit %4.2f\r\n", k, c, f);
+            printf("Humidity is %4.2f, Dewpoint: %4.2f, Dewpoint fast: %4.2f\r\n", h, dp, dpf);
+        } else {
+            printf("Error: %d\n", error);
+        }
+        wait(1.0); // 1 sec
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Jan 03 19:03:51 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file