estructura basica del proecto + wifi
This commit is contained in:
BIN
hardware/docs/MQ-7.PDF
Normal file
BIN
hardware/docs/MQ-7.PDF
Normal file
Binary file not shown.
BIN
hardware/docs/OKY3259-2.PDF
Normal file
BIN
hardware/docs/OKY3259-2.PDF
Normal file
Binary file not shown.
0
hardware/include/json.hpp
Normal file
0
hardware/include/json.hpp
Normal file
@@ -1,6 +1,9 @@
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include <RESTClient.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
#include "json.hpp"
|
||||
#include "rest.hpp"
|
||||
#include "wifi.hpp"
|
||||
#include "test.hpp"
|
||||
#include "mqtt.hpp"
|
||||
|
||||
#define LED 2
|
||||
0
hardware/include/mqtt.hpp
Normal file
0
hardware/include/mqtt.hpp
Normal file
1
hardware/include/rest.hpp
Normal file
1
hardware/include/rest.hpp
Normal file
@@ -0,0 +1 @@
|
||||
#include <HTTPClient.h>
|
||||
0
hardware/include/test.hpp
Normal file
0
hardware/include/test.hpp
Normal file
7
hardware/include/wifi.hpp
Normal file
7
hardware/include/wifi.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <WiFi.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
#define SSID "iPhone de Jose"
|
||||
#define PASSWORD "bombardeenlaus"
|
||||
|
||||
int setup_wifi();
|
||||
@@ -16,4 +16,3 @@ lib_deps =
|
||||
knolleary/PubSubClient@^2.8
|
||||
mikalhart/TinyGPSPlus@^1.0.2
|
||||
bblanchon/ArduinoJson@^6.17.3
|
||||
robbie-remote/RESTClient@^1.0.0
|
||||
1
hardware/src/json.cpp
Normal file
1
hardware/src/json.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "json.hpp"
|
||||
@@ -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() {
|
||||
|
||||
1
hardware/src/mqtt.cpp
Normal file
1
hardware/src/mqtt.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "mqtt.hpp"
|
||||
1
hardware/src/rest.cpp
Normal file
1
hardware/src/rest.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "rest.hpp"
|
||||
1
hardware/src/test.cpp
Normal file
1
hardware/src/test.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "test.hpp"
|
||||
35
hardware/src/wifi.cpp
Normal file
35
hardware/src/wifi.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <wifi.hpp>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user