75 lines
1.8 KiB
C++
75 lines
1.8 KiB
C++
|
|
|
|
/*
|
|
* Software basico sersor domotica con esp8266 / esp32 nodemcu
|
|
* Controlado por mqtt
|
|
* ---------------------------------------------------------------
|
|
* compatible con:
|
|
* sensor temperatura y humedad hdt22
|
|
* sensores digitales de entrada (gestionado por interrupciones)
|
|
* presion y altura por sensor bmp180
|
|
* sensores digitales de salida
|
|
* receptor rf
|
|
* emisor rf
|
|
* --------------------------------------------------------------
|
|
*/
|
|
|
|
/*
|
|
* la temperatura se tiene que cambiar a digital interrupcion
|
|
*/
|
|
/*falta transimsion en rf out
|
|
Y PROBAR RF*/
|
|
|
|
#define VERSION_PROG "V0201"//indica version del programa
|
|
//#define CONEXION_ETERNET 0//indica si la conexion es ethernet o wifi (para aruino uno)
|
|
//falta guardar estado de relees en eprom--------------------------
|
|
|
|
|
|
//includes-----------------------------------------
|
|
#include <SPI.h>
|
|
#include <ESP8266WiFi.h>//este para esp8266
|
|
//#include <WiFi.h>//este para esp32
|
|
|
|
#include <SimpleDHT.h>
|
|
#include <Wire.h>
|
|
#include <Adafruit_BMP085.h>
|
|
//#include <PubSubClient.h>
|
|
|
|
|
|
#include "DomoEspManager.h"
|
|
#include "config_rf.h"
|
|
|
|
//variables globales----------------------------
|
|
DomoEspManager domoManager;
|
|
|
|
|
|
DomoEspManager domoEspManager;
|
|
WiFiClient EspClient;
|
|
PubSubClient clienteMqtt(EspClient);
|
|
LiquidCrystal *plcd=NULL;
|
|
#if CON_LCD
|
|
LiquidCrystal lcd(
|
|
ConfiguracionActual.lcd.rs,
|
|
ConfiguracionActual.lcd.en,
|
|
ConfiguracionActual.lcd.d0,ConfiguracionActual.lcd.d1,ConfiguracionActual.lcd.d2,ConfiguracionActual.lcd.d3);
|
|
|
|
#endif
|
|
//funciones principales------------------------
|
|
void setup()
|
|
{
|
|
plcd=&lcd;
|
|
#ifdef DEBUG_PS
|
|
Serial.begin(ConfiguracionActual.velocidadPortSerie);
|
|
delay(10);
|
|
Serial.println("");
|
|
Serial.println("Iniciando");
|
|
#endif
|
|
domoManager.inicia(plcd,&clienteMqtt,&EspClient,&ConfiguracionActual);
|
|
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
domoManager.loop();
|
|
}
|