Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ATParser TSL2561 mbed
Diff: main.cpp
- Revision:
- 0:c88efeed88e3
- Child:
- 1:62d78e5748b6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Apr 13 15:56:06 2018 +0000
@@ -0,0 +1,80 @@
+#include "mbed.h"
+#include "ATParser.h"
+#include "TSL2561.h"
+#include <string.h>
+#include <stdlib.h>
+
+BufferedSerial pc(SERIAL_TX, SERIAL_RX);
+BufferedSerial device(PA_9, PA_10); // tx, rx
+DigitalOut myled(LED1);
+TSL2561 lightsensor(PB_7,PB_6);
+
+int main()
+{
+ pc.baud(115200);
+ device.baud(115200);
+ pc.printf("Hola\n\r");
+ ATParser at = ATParser(device, "\n\r", 256, 2000, false);
+ if(at.send("AT") && at.recv("\n\r"))
+ {
+ pc.printf("Bueno#1\n\r");
+ myled = !myled;
+ }
+ else
+ pc.printf("Nope#1\n\r");
+ if(at.send("AT+NI=1,MTCDT-19400691") && 1)
+ pc.printf("Bueno#2\n\r");
+ else
+ pc.printf("Nope#2\n\r");
+ if(at.send("AT+NK=1,MTCDT-19400691") && 1)
+ pc.printf("Bueno #3\n\r");
+ else
+ pc.printf("Nope #3\n\r");
+ if(at.send("AT+FSB=1") && 1)
+ pc.printf("Bueno #4\n\r");
+ else
+ pc.printf("Nope #4\n\r");
+ if(at.send("AT+JOIN")&& 1)
+ pc.printf("Bueno #5\n\r");
+ else
+ pc.printf("Nope #5\n\r");
+
+ char devID[24];
+ if(at.send("AT+DI") && at.recv("%s\r\n\r\nOK", &devID))
+ pc.printf("Bueno#6\n\r");
+ else
+ pc.printf("Nope #6\n\r");
+
+ int i = 0;
+ char *day[24];
+ while(1)
+ {
+ float lightnum = lightsensor.lux();
+ pc.printf("light = %f\n\r", lightnum);
+ char light = malloc(sizeof(char)*10);
+ day[i] = light;
+ i++;
+ int n;
+ n = sprintf(light, "%f", lightnum);
+ pc.printf("String transfer worked: %s\n\r", light);
+
+ if (i == 24)
+ {
+ int j;
+ for(j = 0; j < 24; j++)
+ {
+ if(at.send("AT+SEND=\"%s\"", day[j]) && 1)
+ pc.printf("isesux\n\r");
+ else
+ pc.printf("iserox\n\r");
+ }
+ i = 0;
+ for(j=0; j < 24; j++)
+ {
+ free(day[j]);
+ }
+
+ }
+ wait(3600);
+ }
+}