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 57:a2340579d7ad, committed 2018-03-10
- Comitter:
- Ottomanslap
- Date:
- Sat Mar 10 17:46:39 2018 +0000
- Parent:
- 56:bea82468efd3
- Child:
- 58:44e839410957
- Commit message:
- Json print temp co2 hum light
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CCS811.lib Sat Mar 10 17:46:39 2018 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/andcor02/code/CCS811/#64a96d555ef0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sht31.lib Sat Mar 10 17:46:39 2018 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/andcor02/code/Sht31/#c84a60326ecf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSL2561.lib Sat Mar 10 17:46:39 2018 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/andcor02/code/TSL2561/#8146a28a20cc
--- a/main.cpp Fri Mar 09 11:30:49 2018 +0000
+++ b/main.cpp Sat Mar 10 17:46:39 2018 +0000
@@ -17,6 +17,11 @@
#include "mbed.h"
#include "TCPSocket.h"
#include "C12832.h"
+#include "Sht31.h"
+#include "CCS811.h"
+#include "TSL2561.h"
+#include <string>
+using std::string;
#define WIFI_ESP8266 1
#define WIFI_IDW0XX1 2
@@ -43,6 +48,11 @@
Serial pc(USBTX, USBRX); // tx, rx
C12832 lcd(PE_14, PE_12, PD_12, PD_11, PE_9);
+Sht31 sht31(PF_0, PF_1); //TEMP SENSOR: I2C_SDA, I2C_SCL
+CCS811 ccs811(PF_0, PF_1); //IAQ SENSOR: I2C_SDA, I2C_SCL
+TSL2561 tsl2561(PF_0, PF_1, TSL2561_ADDR_HIGH); //LIGHT SENSOR: I2C_SDA, I2C_SCL
+
+
void lcd_print(const char* message)
{
@@ -139,6 +149,9 @@
// Close the socket to return its memory and bring down the network interface
socket.close();
}
+void display(const char* out){
+ printf("%s\n", out);
+ }
int main()
{
@@ -171,4 +184,65 @@
wifi.disconnect();
printf("\nDone\n");
+
+ ccs811.init();
+ tsl2561.begin();
+ tsl2561.setGain(TSL2561_GAIN_0X);
+ tsl2561.setTiming(TSL2561_INTEGRATIONTIME_402MS);
+
+ while(1) {
+
+ string json = "{\n";
+
+ //Light
+
+ int x = tsl2561.getLuminosity(TSL2561_VISIBLE);
+
+ //printf("VIS: %d\n", x);
+
+ char buffer [8];
+ int n;
+ n = sprintf (buffer, "%d", x);
+
+ json += "\t \"Light\" : ";
+ json += buffer;
+ json += ".0,\n";
+
+ //Air
+
+ uint16_t eco2, tvoc;
+ ccs811.readData(&eco2, &tvoc);
+
+ //printf("eCO2:%dppm\n", eco2);
+
+ n = sprintf (buffer, "%d", eco2);
+
+ json += "\t \"eCO2\" : ";
+ json += buffer;
+ json += ".0,\n";
+
+ //Hum and Temp
+
+ float t = sht31.readTemperature();
+ float h = sht31.readHumidity();
+
+ //printf("TEMP:%3.2fC\n", t);
+ //printf("HUM:%3.2f%%\n", h);
+
+ n = sprintf (buffer, "%3.2f", t);
+
+ json += "\t \"Tempr\" : ";
+ json += buffer;
+ json += ",\n";
+
+ n = sprintf (buffer, "%3.2f", h);
+
+ json += "\t \"Humid\" : ";
+ json += buffer;
+ json += ",\n";
+
+ json += "}\n\n";
+ printf("%s", json);
+ wait(1);
+ }
}
--- a/mbed_app.json Fri Mar 09 11:30:49 2018 +0000
+++ b/mbed_app.json Sat Mar 10 17:46:39 2018 +0000
@@ -6,11 +6,11 @@
},
"wifi-ssid": {
"help": "WiFi SSID",
- "value": "\"SnackBeans\""
+ "value": "\"AndroidAP3323\""
},
"wifi-password": {
"help": "WiFi Password",
- "value": "\"crocodile\""
+ "value": "\"ffa52a3f122f\""
},
"wifi-tx": {
"help": "TX pin for serial connection to external device",
