diff --git a/hardware/docs/MQ-7.PDF b/hardware/docs/MQ-7.PDF new file mode 100644 index 0000000..cdc2e59 Binary files /dev/null and b/hardware/docs/MQ-7.PDF differ diff --git a/hardware/docs/OKY3259-2.PDF b/hardware/docs/OKY3259-2.PDF new file mode 100644 index 0000000..e3e5d41 Binary files /dev/null and b/hardware/docs/OKY3259-2.PDF differ diff --git a/hardware/include/json.hpp b/hardware/include/json.hpp new file mode 100644 index 0000000..e69de29 diff --git a/hardware/include/main.hpp b/hardware/include/main.hpp index f44a7ec..c079e00 100644 --- a/hardware/include/main.hpp +++ b/hardware/include/main.hpp @@ -1,6 +1,9 @@ #include -#include -#include -#include + +#include "json.hpp" +#include "rest.hpp" +#include "wifi.hpp" +#include "test.hpp" +#include "mqtt.hpp" #define LED 2 \ No newline at end of file diff --git a/hardware/include/mqtt.hpp b/hardware/include/mqtt.hpp new file mode 100644 index 0000000..e69de29 diff --git a/hardware/include/rest.hpp b/hardware/include/rest.hpp new file mode 100644 index 0000000..2617b4f --- /dev/null +++ b/hardware/include/rest.hpp @@ -0,0 +1 @@ +#include \ No newline at end of file diff --git a/hardware/include/test.hpp b/hardware/include/test.hpp new file mode 100644 index 0000000..e69de29 diff --git a/hardware/include/wifi.hpp b/hardware/include/wifi.hpp new file mode 100644 index 0000000..cf7ed35 --- /dev/null +++ b/hardware/include/wifi.hpp @@ -0,0 +1,7 @@ +#include +#include + +#define SSID "iPhone de Jose" +#define PASSWORD "bombardeenlaus" + +int setup_wifi(); \ No newline at end of file diff --git a/hardware/platformio.ini b/hardware/platformio.ini index 5d17103..c982bcf 100644 --- a/hardware/platformio.ini +++ b/hardware/platformio.ini @@ -13,7 +13,6 @@ platform = espressif32 board = esp32dev framework = arduino lib_deps = - knolleary/PubSubClient@^2.8 - mikalhart/TinyGPSPlus@^1.0.2 - bblanchon/ArduinoJson@^6.17.3 - robbie-remote/RESTClient@^1.0.0 \ No newline at end of file + knolleary/PubSubClient@^2.8 + mikalhart/TinyGPSPlus@^1.0.2 + bblanchon/ArduinoJson@^6.17.3 \ No newline at end of file diff --git a/hardware/src/json.cpp b/hardware/src/json.cpp new file mode 100644 index 0000000..df2ffdf --- /dev/null +++ b/hardware/src/json.cpp @@ -0,0 +1 @@ +#include "json.hpp" \ No newline at end of file diff --git a/hardware/src/main.cpp b/hardware/src/main.cpp index 09123b9..1554bd2 100644 --- a/hardware/src/main.cpp +++ b/hardware/src/main.cpp @@ -1,16 +1,12 @@ #include "main.hpp" -const char* ssid = "SiempreHome"; -const char* password = "d7?a35D9EnaPepXY?c!4"; -const char* mqtt_server = "192.168.0.155"; - -WiFiClient espClient; -PubSubClient client(espClient); -long lastMsg = 0; -char msg[50]; - void setup() { + Serial.begin(9600); + if(setup_wifi() != 0) + { + Serial.print("Error connecting to WiFI"); + } } void loop() { diff --git a/hardware/src/mqtt.cpp b/hardware/src/mqtt.cpp new file mode 100644 index 0000000..131e5ea --- /dev/null +++ b/hardware/src/mqtt.cpp @@ -0,0 +1 @@ +#include "mqtt.hpp" \ No newline at end of file diff --git a/hardware/src/rest.cpp b/hardware/src/rest.cpp new file mode 100644 index 0000000..f3b0775 --- /dev/null +++ b/hardware/src/rest.cpp @@ -0,0 +1 @@ +#include "rest.hpp" \ No newline at end of file diff --git a/hardware/src/test.cpp b/hardware/src/test.cpp new file mode 100644 index 0000000..ac97f27 --- /dev/null +++ b/hardware/src/test.cpp @@ -0,0 +1 @@ +#include "test.hpp" \ No newline at end of file diff --git a/hardware/src/wifi.cpp b/hardware/src/wifi.cpp new file mode 100644 index 0000000..7f54b49 --- /dev/null +++ b/hardware/src/wifi.cpp @@ -0,0 +1,35 @@ +#include + +WiFiClient espClient; +PubSubClient client(espClient); + +int setup_wifi() +{ + Serial.println(); + Serial.print("Connecting to "); + Serial.println(SSID); + + WiFi.mode(WIFI_STA); + WiFi.begin(SSID, PASSWORD); + + while (WiFi.status() != WL_CONNECTED) + { + delay(500); + Serial.print("."); + } + + Serial.println(""); + Serial.println("WiFi connected"); + Serial.println("IP address: "); + Serial.println(WiFi.localIP()); + Serial.println("Setup!"); + + if(WiFi.status() == WL_CONNECTED) + { + return 0; + } + else + { + return 1; + } +}