Deep Slumber, codename ISA, is a program made for the arm MBED during Hack The Burgh 2018 that analyses light, temperature, humidity and CO2 levels in a room. It uploads this information onto an SQL server through a rest API, providing the necessary environment for data processing. Further improvements we hope to provide are the regulation of said parameters by wifi connection to electric heaters, wifi enabled controllable lightbulbs and other iot gadgets as well as a website that will provide recommendations for sleep cycle improvements.
Dependencies: C12832 CCS811 Sht31 TSL2561
Fork of ARM_HACK_THE_BURGH by
Revision 56:bea82468efd3, committed 2018-03-09
- Comitter:
- CJW
- Date:
- Fri Mar 09 11:30:49 2018 +0000
- Parent:
- 55:31af282f6ea5
- Child:
- 57:a2340579d7ad
- Commit message:
- WiFi Example
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832.lib Fri Mar 09 11:30:49 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/askksa12543/code/C12832/#990d5eec2ef6
--- a/esp8266-driver.lib Fri Feb 16 10:15:02 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://github.com/armmbed/esp8266-driver/#264468722a97cc2c8e0a517da06a542eb52fb9cb
--- a/main.cpp Fri Feb 16 10:15:02 2018 +0000
+++ b/main.cpp Fri Mar 09 11:30:49 2018 +0000
@@ -16,11 +16,12 @@
#include "mbed.h"
#include "TCPSocket.h"
+#include "C12832.h"
#define WIFI_ESP8266 1
#define WIFI_IDW0XX1 2
-#if TARGET_UBLOX_EVK_ODIN_W2
+#if 1
#include "OdinWiFiInterface.h"
OdinWiFiInterface wifi;
@@ -39,6 +40,16 @@
#endif // MBED_CONF_APP_WIFI_SHIELD == WIFI_IDW0XX1
#endif
+Serial pc(USBTX, USBRX); // tx, rx
+
+C12832 lcd(PE_14, PE_12, PD_12, PD_11, PE_9);
+
+void lcd_print(const char* message)
+{
+ lcd.cls();
+ lcd.locate(0, 3);
+ pc.printf(message);
+}
const char *sec2str(nsapi_security_t sec)
{
@@ -63,7 +74,7 @@
{
WiFiAccessPoint *ap;
- printf("Scan:\n");
+ pc.printf("Scan:\n");
int count = wifi->scan(NULL,0);
@@ -72,13 +83,12 @@
ap = new WiFiAccessPoint[count];
count = wifi->scan(ap, count);
- for (int i = 0; i < count; i++)
- {
- printf("Network: %s secured: %s BSSID: %hhX:%hhX:%hhX:%hhx:%hhx:%hhx RSSI: %hhd Ch: %hhd\n", ap[i].get_ssid(),
- sec2str(ap[i].get_security()), ap[i].get_bssid()[0], ap[i].get_bssid()[1], ap[i].get_bssid()[2],
- ap[i].get_bssid()[3], ap[i].get_bssid()[4], ap[i].get_bssid()[5], ap[i].get_rssi(), ap[i].get_channel());
+ for (int i = 0; i < count; i++) {
+ pc.printf("Network: %s secured: %s BSSID: %hhX:%hhX:%hhX:%hhx:%hhx:%hhx RSSI: %hhd Ch: %hhd\n", ap[i].get_ssid(),
+ sec2str(ap[i].get_security()), ap[i].get_bssid()[0], ap[i].get_bssid()[1], ap[i].get_bssid()[2],
+ ap[i].get_bssid()[3], ap[i].get_bssid()[4], ap[i].get_bssid()[5], ap[i].get_rssi(), ap[i].get_channel());
}
- printf("%d networks available.\n", count);
+ pc.printf("%d networks available.\n", count);
delete[] ap;
return count;
@@ -104,8 +114,7 @@
char sbuffer[] = "GET / HTTP/1.1\r\nHost: www.arm.com\r\n\r\n";
nsapi_size_t size = strlen(sbuffer);
response = 0;
- while(size)
- {
+ while(size) {
response = socket.send(sbuffer+response, size);
if (response < 0) {
printf("Error sending data: %d\n", response);
@@ -135,22 +144,22 @@
{
int count = 0;
- printf("WiFi example\n\n");
+ pc.printf("WiFi example\n\n");
count = scan_demo(&wifi);
if (count == 0) {
- printf("No WIFI APNs found - can't continue further.\n");
+ pc.printf("No WIFI APNs found - can't continue further.\n");
return -1;
}
printf("\nConnecting to %s...\n", MBED_CONF_APP_WIFI_SSID);
int ret = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
if (ret != 0) {
- printf("\nConnection error\n");
+ pc.printf("\nConnection error\n");
return -1;
}
- printf("Success\n\n");
+ pc.printf("Success\n\n");
printf("MAC: %s\n", wifi.get_mac_address());
printf("IP: %s\n", wifi.get_ip_address());
printf("Netmask: %s\n", wifi.get_netmask());
--- a/mbed-os.lib Fri Feb 16 10:15:02 2018 +0000 +++ b/mbed-os.lib Fri Mar 09 11:30:49 2018 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#569159b784f70feaa32ce226aaca896fb83452f7 +https://github.com/ARMmbed/mbed-os/#8b54959f5bca08a8ad44a701bafd634afbb38b03
--- a/mbed_app.json Fri Feb 16 10:15:02 2018 +0000
+++ b/mbed_app.json Fri Mar 09 11:30:49 2018 +0000
@@ -6,11 +6,11 @@
},
"wifi-ssid": {
"help": "WiFi SSID",
- "value": "\"SSID\""
+ "value": "\"SnackBeans\""
},
"wifi-password": {
"help": "WiFi Password",
- "value": "\"PASSWORD\""
+ "value": "\"crocodile\""
},
"wifi-tx": {
"help": "TX pin for serial connection to external device",
--- a/wifi-x-nucleo-idw01m1.lib Fri Feb 16 10:15:02 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://github.com/ARMmbed/wifi-x-nucleo-idw01m1/#5871f7011d7ff2c50e3faf992ebab88e9f69dc95 \ No newline at end of file
