4 Mayıs 2026 Pazartesi

Esp32 code example

 #include <BLEDevice.h>

#include <BLEServer.h>

#include <BLEUtils.h>

#include <BLE2902.h>

#include <ArduinoJson.h>


// --- BLE UUID Definitions ---

// Using the same UUID for both Read and Write for simplicity and stability.

#define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"

#define CHARACTERISTIC_UUID "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"


// Global Variables

BLECharacteristic *pCharacteristic;

bool deviceConnected = false;

unsigned long lastMillis = 0; 


// Hardware Pin Definitions

const int LED_PIN = 8; // Standard On/Off LED

const int PWM_PIN = 7; // Dimmer/Speed control pin (ESP32-C3 GPIO 7)


// PWM Configuration (v3.0+ SDK Compatible)

const int freq = 5000; // Frequency in Hz

const int resolution = 8; // 8-bit resolution (Values 0-255)


// Callback class to handle BLE Connection events

class MyServerCallbacks: public BLEServerCallbacks {

    void onConnect(BLEServer* pServer) {

      deviceConnected = true;

      Serial.println(">>> Device Connected");

    };

    void onDisconnect(BLEServer* pServer) {

      deviceConnected = false;

      Serial.println(">>> Device Disconnected");

      // Restart advertising so other devices can find the ESP32

      pServer->getAdvertising()->start();

    }

};


// Callback class to handle Data received from the Mobile App

class MyCallbacks: public BLECharacteristicCallbacks {

    void onWrite(BLECharacteristic *pCharacteristic) {

      String value = String(pCharacteristic->getValue().c_str());

      

      if (value.length() > 0) {

        Serial.print("Command Received: ");

        Serial.println(value);

        

        // Scenario 1: Simple On/Off (Standard Switch)

        if (value == "A") {

            digitalWrite(LED_PIN, HIGH);

            Serial.println("LED State: ON");

        }

        else if (value == "B") {

            digitalWrite(LED_PIN, LOW);

            Serial.println("LED State: OFF");

        }

        

        // Scenario 2: PWM Control (Format "tag:value", e.g., "ldr1:5")

        else if (value.indexOf(':') != -1) {

          int colonIndex = value.indexOf(':');

          String tag = value.substring(0, colonIndex);

          int val = value.substring(colonIndex + 1).toInt(); 


          // Check if the tag matches our assigned tag

          if (tag == "ldr1") {

            // Map 0-9 input to 0-255 for the 8-bit PWM resolution

            int brightness = map(val, 0, 9, 0, 255);

            ledcWrite(PWM_PIN, brightness); 

            Serial.printf("PWM Intensity set to: %d\n", brightness);

          }

        }

      }

    }

};


void setup() {

  Serial.begin(115200);

  pinMode(LED_PIN, OUTPUT);


  // --- PWM INITIALIZATION (ESP32 Core v3.0+) ---

  // In the new SDK, ledcAttach replaces ledcSetup and ledcAttachPin

  ledcAttach(PWM_PIN, freq, resolution); 


  // Initialize BLE Device

  BLEDevice::init("ESP32-C3-FIIX");

  BLEServer *pServer = BLEDevice::createServer();

  pServer->setCallbacks(new MyServerCallbacks());


  // Create BLE Service

  BLEService *pService = pServer->createService(SERVICE_UUID);


  // Create Characteristic with Read, Write, and Notify properties

  pCharacteristic = pService->createCharacteristic(

                        CHARACTERISTIC_UUID,

                        BLECharacteristic::PROPERTY_READ |

                        BLECharacteristic::PROPERTY_WRITE |

                        BLECharacteristic::PROPERTY_NOTIFY |

                        BLECharacteristic::PROPERTY_WRITE_NR // Supports fast writing

                      );


  pCharacteristic->setCallbacks(new MyCallbacks());

  pCharacteristic->addDescriptor(new BLE2902()); // Required for Notifications


  // Start the Service and begin Advertising

  pService->start();

  pServer->getAdvertising()->start();

  Serial.println("BLE Ready (v3.0 SDK Environment)...");

}


void loop() {

  // Only send data if a smartphone is connected

  if (deviceConnected) {

    // Send sensor data every 2 seconds

    if (millis() - lastMillis > 2000) {

      

      // Simulate random sensor readings

      int sensorValue1 = random(100, 1024);

      int sensorValue2 = random(100, 1024);

      int sensorValue3 = random(100, 1024);

      int sensorValue4 = random(100, 1024);


      // Create a JSON Document

      StaticJsonDocument<128> doc;

      doc["ldr1"] = sensorValue1; 

      doc["ldr2"] = sensorValue2; 

      doc["ldr3"] = sensorValue3; 

      doc["ldr4"] = sensorValue4; 


      // Serialize JSON to a string buffer

      char buffer[128];

      serializeJson(doc, buffer);

      

      // Send the JSON string via BLE Notification

      pCharacteristic->setValue(buffer);

      pCharacteristic->notify(); 

      

      Serial.print("JSON Sent to App: ");

      Serial.println(buffer);

      

      lastMillis = millis();

    }

  }

}

Privacy Policy for ble control

 Last Updated: May 2, 2026

reddapp ("we," "our," or "us") operates the ble control mobile application (the "Service"). This page informs you of our policies regarding the collection, use, and disclosure of personal data when you use our Service and the choices you have associated with that data.

1. Information Collection and Use

We collect several different types of information for various purposes to provide and improve our Service to you.

Personal Data: While using our Service, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you ("Personal Data").

Usage Data: The app may collect information such as your device's IP address, device name, operating system version, and the time/date of your use.

Bluetooth & Local Files: This application requires access to your device’s Bluetooth to communicate with BLE devices (e.g., ESP32, BLE modules) and may require local storage access for saving your configurations.

Advertising ID: This "free" version of the app uses your device's advertising identifier to show personalized ads.

2. Third-Party Service Providers

The app uses third-party services that may collect information used to identify you. These include analytics, stability, and advertising services:

Google Play Services

AdMob: Used for displaying advertisements. AdMob may use the Advertising ID from your device to serve relevant ads. Google’s Privacy & Terms

Google Analytics for Firebase

Firebase Crashlytics

3. Advertising

We use third-party service providers to show advertisements to you to help support and maintain our Service.

AdMob by Google: Google, as a third-party vendor, uses cookies and advertising identifiers to serve ads on our Service. You may opt-out of personalized advertising by visiting your device's "Ads" settings.

4. Data Safety & Disclosure

We do not sell or share your personal data with third parties for marketing purposes. Data is only used to:

Facilitate the core functionality of the Bluetooth controller.

Show relevant advertisements via AdMob.

Analyze app performance and fix crashes.

5. Data Retention and Deletion

We retain your personal data only for as long as is necessary for the purposes set out in this Privacy Policy.

User Rights: You have the right to request the deletion of any data collected. Since we do not use a centralized user account system for this app, most data is stored locally on your device. You can clear this data by uninstalling the app or clearing the app cache. For any further data inquiries, contact us at rukosw@gmail.com.

6. Security

The security of your data is important to us, but remember that no method of transmission over the Internet is 100% secure. We strive to use commercially acceptable means to protect your Personal Data.

7. Children's Privacy

Our Service does not address anyone under the age of 13. We do not knowingly collect personally identifiable information from children under 13. If we discover that a child under 13 has provided us with personal information, we immediately delete this from our servers.

8. DIY Disclaimer

This is a "Do-It-Yourself" (DIY) application. The user assumes all responsibility for any hardware issues or accidents that may occur during the use of this software with real electronic components (relays, ESP32, BLE devices, etc.).

9. Changes to This Privacy Policy

We may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page.

10. Contact Us

If you have any questions about this Privacy Policy, please contact us:

By email: rukosw@gmail.com

2 Mayıs 2026 Cumartesi

Privacy Policy for esp relay wifi controller free

 Last Updated: May 2, 2026

reddapp ("we," "our," or "us") operates the esp relay wifi controller free mobile application (the "Service"). This page informs you of our policies regarding the collection, use, and disclosure of personal data when you use our Service and the choices you have associated with that data.

1. Information Collection and Use

We collect several different types of information for various purposes to provide and improve our Service to you.

Personal Data: While using our Service, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you ("Personal Data").

Usage Data: The app may collect information such as your device's IP address, device name, operating system version, and the time/date of your use.

Local Network & Files: This application requires access to your local network (Wi-Fi) to communicate with ESP8266/ESP32 devices and may require local storage access for saving your configurations.

Advertising ID: This "free" version of the app uses your device's advertising identifier to show personalized ads.

2. Third-Party Service Providers

The app uses third-party services that may collect information used to identify you. These include analytics, stability, and advertising services:

Google Play Services

AdMob: Used for displaying advertisements. AdMob may use the Advertising ID from your device to serve relevant ads. Google’s Privacy & Terms

Google Analytics for Firebase

Firebase Crashlytics

3. Advertising

We use third-party service providers to show advertisements to you to help support and maintain our Service.

AdMob by Google: Google, as a third-party vendor, uses cookies and advertising identifiers to serve ads on our Service. You may opt-out of personalized advertising by visiting your device's "Ads" settings.

4. Data Safety & Disclosure

We do not sell or share your personal data with third parties for marketing purposes. Data is only used to:

Facilitate the core functionality of the Wi-Fi controller.

Show relevant advertisements via AdMob.

Analyze app performance and fix crashes.

5. Data Retention and Deletion

We retain your personal data only for as long as is necessary for the purposes set out in this Privacy Policy.

User Rights: You have the right to request the deletion of any data collected. Since we do not use a centralized user account system for this app, most data is stored locally on your device. You can clear this data by uninstalling the app or clearing the app cache. For any further data inquiries, contact us at rukosw@gmail.com.

6. Security

The security of your data is important to us, but remember that no method of transmission over the Internet is 100% secure. We strive to use commercially acceptable means to protect your Personal Data.

7. Children's Privacy

Our Service does not address anyone under the age of 13. We do not knowingly collect personally identifiable information from children under 13. If we discover that a child under 13 has provided us with personal information, we immediately delete this from our servers.

8. DIY Disclaimer

This is a "Do-It-Yourself" (DIY) application. The user assumes all responsibility for any hardware issues or accidents that may occur during the use of this software with real electronic components (relays, ESP8266, etc.).

9. Changes to This Privacy Policy

We may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page.

10. Contact Us

If you have any questions about this Privacy Policy, please contact us:

By email: rukosw@gmail.com