lab10

Dependencies:   ATParser TSL2561 mbed

Files at this revision

API Documentation at this revision

Comitter:
kmhatre
Date:
Sat Apr 28 01:16:30 2018 +0000
Commit message:
lab10;

Changed in this revision

ATParser.lib Show annotated file Show diff for this revision Revisions of this file
TSL2561.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/ATParser.lib	Sat Apr 28 01:16:30 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/teams/components/code/ATParser/#6b8190f55d83
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSL2561.lib	Sat Apr 28 01:16:30 2018 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/kenjiArai/code/TSL2561/#05d322353720
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Apr 28 01:16:30 2018 +0000
@@ -0,0 +1,83 @@
+#include "mbed.h"
+#include "ATParser.h"
+#include "TSL2561.h"
+#include <string>
+#include <algorithm>
+#include <iostream>
+
+
+
+
+
+BufferedSerial pc(SERIAL_TX, SERIAL_RX);
+BufferedSerial dev(PA_9, PA_10);
+DigitalOut myled(LED1);
+TSL2561 light_sensor(PB_7, PB_6); 
+
+
+
+int main() {
+    pc.baud(115200);
+    dev.baud(115200);
+    
+    ATParser at = ATParser(dev, "\r\n");
+    
+    printf("Program Started\n\r");
+    
+        pc.printf("\n\rConnecting Lora\n\r");
+        if (at.send("AT")) {
+           if(at.recv("OK")){
+           pc.printf("Lora Device Working\r\n");
+           }
+           else {
+            pc.printf("Lora Device NOT Working\r\n");
+           }
+        }
+        if (at.send("AT+NI=1,MTCDT-19400691")) {
+           if(at.recv("OK")){
+           pc.printf("Network ID Working\r\n");
+           }
+           else {
+            pc.printf("Network ID NOT Working\r\n");
+           }
+        }
+        if (at.send("AT+NK=1,MTCDT-19400691")) {
+           if(at.recv("OK")){
+           pc.printf("Network Key Working\r\n");
+           }
+           else {
+            pc.printf("Network Key NOT Working\r\n");
+           }
+        }
+        if (at.send("AT+FSB=1")) {
+           if(at.recv("OK")){
+           pc.printf("Frequency Sub Band set to 1\r\n");
+           }
+           else {
+            pc.printf("Frequency Sub Band NOT set\r\n");
+           }
+        }
+        if (at.send("AT+JOIN")) {
+           if(at.recv("OK")){
+           pc.printf("Successfully joined network\r\n");
+           }
+           else {
+            pc.printf("ERROR Unable to join Network\r\n");
+           }
+        }
+    int i = 0;
+    while(1) {
+        float data[24];
+        if(i == 24) {
+            char dataS[3200];
+            sprintf(dataS, "%3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f %3.2f", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7], data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15], data[16], data[17], data[18], data[19], data[20], data[21], data[22], data[23]);
+            at.send("AT+SEND=\"%s\"", dataS);  
+            i = 0;
+        }
+        float light = light_sensor.lux();
+        data[i] = light;
+        pc.printf("%f\n\r", data[i]);
+        i++;
+        wait(3600); 
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Apr 28 01:16:30 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file