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
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:lolin32]
|
||||
[env]
|
||||
platform = espressif32
|
||||
board = lolin32
|
||||
board = wemos_d1_mini32
|
||||
framework = arduino
|
||||
upload_port = /dev/ttyUSB0
|
||||
monitor_port = /dev/ttyUSB0
|
||||
monitor_speed = 115200
|
||||
lib_deps =
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
27
src/main.cpp
27
src/main.cpp
|
@ -14,23 +14,33 @@
|
|||
#include <BLEAddress.h>
|
||||
#include <Ticker.h>
|
||||
#include <PubSubClient.h>
|
||||
|
||||
String Adresse = "CF:D7:AB:1F:24:2C"; // Bluetooth Adresse die zu Anwesenheitserkennung überwacht wird
|
||||
const int RelaisPin = 22; // Pin an dem Relais hängt
|
||||
|
||||
//cf:d7:ab:1f:24:2c
|
||||
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 VerzoegerungZaeler = 0;
|
||||
//long int ZZ = 0;
|
||||
Ticker Tic;
|
||||
static BLEAddress *pServerAddress;
|
||||
BLEScan* pBLEScan ;
|
||||
int scanTime = 30; //In seconds
|
||||
|
||||
|
||||
|
||||
long int Feldstaerke;
|
||||
|
||||
|
||||
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks
|
||||
{
|
||||
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
|
||||
/* if (advertisedDevice.haveName()) {
|
||||
Serial.print(" Device name: ");
|
||||
Serial.print(advertisedDevice.getName().c_str());
|
||||
} */
|
||||
if (advertisedDevice.getAddress().equals(*pServerAddress)) // ibeacon Adresse Vergleichen
|
||||
{
|
||||
Serial.print(" Ueberwachte Adresse"); // wenn überwache Adresse gefunden wurde
|
||||
|
@ -43,7 +53,7 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks
|
|||
Serial.print(" dB ");
|
||||
Serial.print(advertisedDevice.getTXPower());
|
||||
Serial.print(" ");
|
||||
digitalWrite (RelaisPin, LOW); // Relais Einschalten
|
||||
digitalWrite (RelaisPin, HIGH); // Relais Einschalten
|
||||
VerzoegerungZaeler = 0; // Ausschaltverzögerung zurücksetzen
|
||||
advertisedDevice.getScan()->stop(); // Scanvorgang beenden
|
||||
} // Found our server
|
||||
|
@ -54,13 +64,14 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks
|
|||
void SekundenTic() // Wird jede Sekunde ausgefüert
|
||||
{
|
||||
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()
|
||||
{
|
||||
pinMode (RelaisPin, OUTPUT);
|
||||
digitalWrite (RelaisPin, HIGH);
|
||||
digitalWrite (RelaisPin, LOW);
|
||||
Serial.begin(115200);
|
||||
Serial.println("");
|
||||
Serial.println("Starte BLE Scanner");
|
||||
|
|
Loading…
Reference in New Issue
Block a user