2024-09-16
This commit is contained in:
parent
cb01d57999
commit
a311dccf29
|
@ -8,12 +8,32 @@
|
||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[env:lolin32]
|
[env]
|
||||||
platform = espressif32
|
platform = espressif32
|
||||||
board = lolin32
|
board = wemos_d1_mini32
|
||||||
framework = arduino
|
framework = arduino
|
||||||
upload_port = /dev/ttyUSB0
|
upload_port = /dev/ttyUSB0
|
||||||
monitor_port = /dev/ttyUSB0
|
monitor_port = /dev/ttyUSB0
|
||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
lib_deps =
|
lib_deps =
|
||||||
knolleary/PubSubClient @ 2.8
|
knolleary/PubSubClient @ 2.8
|
||||||
|
|
||||||
|
|
||||||
|
[env:debug] ; Entwicklungssystem
|
||||||
|
build_flags = ${env.build_flags}
|
||||||
|
-DDEBUG=0
|
||||||
|
-DNOADS=0
|
||||||
|
-DNAME=\"WETTERSTATION\"
|
||||||
|
-DSTASSID=\"MagentaWLAN-RGDO\"
|
||||||
|
-DSTAPSK=\"93329248424922704583\"
|
||||||
|
-DGATEWAY=\"192.168.127.1\"
|
||||||
|
-DDNS=\"192.168.127.1\"
|
||||||
|
-DKMYIP=\"192.168.127.42\"
|
||||||
|
-Dmqtt_server=\"hjkmqtt.dedyn.io\"
|
||||||
|
-Dmqtt_port=61883
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
21
src/main.cpp
21
src/main.cpp
|
@ -15,22 +15,32 @@
|
||||||
#include <Ticker.h>
|
#include <Ticker.h>
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
|
|
||||||
String Adresse = "CF:D7:AB:1F:24:2C"; // Bluetooth Adresse die zu Anwesenheitserkennung überwacht wird
|
//cf:d7:ab:1f:24:2c
|
||||||
const int RelaisPin = 22; // Pin an dem Relais hängt
|
String Adresse = "96:33:bb:bf:ff:ab"; // Bluetooth Adresse die zu Anwesenheitserkennung überwacht wird ET585
|
||||||
|
//String Adresse = "cf:d7:ab:1f:24:2c"; // Bluetooth Adresse die zu Anwesenheitserkennung überwacht wird Holy-IOT
|
||||||
|
const int RelaisPin = LED_BUILTIN; // Pin an dem Relais hängt
|
||||||
int Verzoegerung = 15; // Auschaltverzögerung wenn das Signal von BLE ibeacon fehlt
|
int Verzoegerung = 15; // Auschaltverzögerung wenn das Signal von BLE ibeacon fehlt
|
||||||
|
|
||||||
int VerzoegerungZaeler = 0;
|
int VerzoegerungZaeler = 0;
|
||||||
|
//long int ZZ = 0;
|
||||||
Ticker Tic;
|
Ticker Tic;
|
||||||
static BLEAddress *pServerAddress;
|
static BLEAddress *pServerAddress;
|
||||||
BLEScan* pBLEScan ;
|
BLEScan* pBLEScan ;
|
||||||
int scanTime = 30; //In seconds
|
int scanTime = 30; //In seconds
|
||||||
|
|
||||||
|
long int Feldstaerke;
|
||||||
|
|
||||||
|
|
||||||
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks
|
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks
|
||||||
{
|
{
|
||||||
void onResult(BLEAdvertisedDevice advertisedDevice) // passiert wenn BLE Device ( beacon ) gefunden wurde
|
void onResult(BLEAdvertisedDevice advertisedDevice) // passiert wenn BLE Device ( beacon ) gefunden wurde
|
||||||
{
|
{
|
||||||
|
//Serial.print(ZZ); Serial.print("\t");
|
||||||
Serial.print(advertisedDevice.getAddress().toString().c_str()); // ibeacon Adresse anzeigen
|
Serial.print(advertisedDevice.getAddress().toString().c_str()); // ibeacon Adresse anzeigen
|
||||||
|
/* if (advertisedDevice.haveName()) {
|
||||||
|
Serial.print(" Device name: ");
|
||||||
|
Serial.print(advertisedDevice.getName().c_str());
|
||||||
|
} */
|
||||||
if (advertisedDevice.getAddress().equals(*pServerAddress)) // ibeacon Adresse Vergleichen
|
if (advertisedDevice.getAddress().equals(*pServerAddress)) // ibeacon Adresse Vergleichen
|
||||||
{
|
{
|
||||||
Serial.print(" Ueberwachte Adresse"); // wenn überwache Adresse gefunden wurde
|
Serial.print(" Ueberwachte Adresse"); // wenn überwache Adresse gefunden wurde
|
||||||
|
@ -43,7 +53,7 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks
|
||||||
Serial.print(" dB ");
|
Serial.print(" dB ");
|
||||||
Serial.print(advertisedDevice.getTXPower());
|
Serial.print(advertisedDevice.getTXPower());
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
digitalWrite (RelaisPin, LOW); // Relais Einschalten
|
digitalWrite (RelaisPin, HIGH); // Relais Einschalten
|
||||||
VerzoegerungZaeler = 0; // Ausschaltverzögerung zurücksetzen
|
VerzoegerungZaeler = 0; // Ausschaltverzögerung zurücksetzen
|
||||||
advertisedDevice.getScan()->stop(); // Scanvorgang beenden
|
advertisedDevice.getScan()->stop(); // Scanvorgang beenden
|
||||||
} // Found our server
|
} // Found our server
|
||||||
|
@ -54,13 +64,14 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks
|
||||||
void SekundenTic() // Wird jede Sekunde ausgefüert
|
void SekundenTic() // Wird jede Sekunde ausgefüert
|
||||||
{
|
{
|
||||||
VerzoegerungZaeler++; // Sekundenzähler
|
VerzoegerungZaeler++; // Sekundenzähler
|
||||||
if (VerzoegerungZaeler >= Verzoegerung) digitalWrite (RelaisPin, HIGH); // Wenn Verzögerungszeit erreicht wurde Auschalten
|
//ZZ++;
|
||||||
|
if (VerzoegerungZaeler >= Verzoegerung) digitalWrite (RelaisPin, LOW); // Wenn Verzögerungszeit erreicht wurde Auschalten
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
pinMode (RelaisPin, OUTPUT);
|
pinMode (RelaisPin, OUTPUT);
|
||||||
digitalWrite (RelaisPin, HIGH);
|
digitalWrite (RelaisPin, LOW);
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
Serial.println("Starte BLE Scanner");
|
Serial.println("Starte BLE Scanner");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user