Streamline Your IoT Projects: ESP32-S3 Bluetooth to Android Data Exchange

  Рет қаралды 901

BMonster Laboratory

BMonster Laboratory

Күн бұрын

Пікірлер: 7
@BMonsterLaboratory
@BMonsterLaboratory 5 ай бұрын
You will also want to install CH34SER.EXE if you don't have it. It is part of the Freenove tutorial download. Once you open the file, click the CH343 folder and download from there....I knew I was missing something! This is a nice and easy project to get familiar with the board. The goal is to use the camera and integrate the camera into various projects.....stay tuned 👍
@hemersonallan
@hemersonallan 7 күн бұрын
Awesome tutorial ! Greetings from Brazil !!
@BMonsterLaboratory
@BMonsterLaboratory 7 күн бұрын
Thanks! I appreciate your comment. Hello Brazil! 👋
@sedrik2000
@sedrik2000 2 ай бұрын
Great video! I really appriciate that you walked-thru the code and explained it, many videos doesn't. Would love to see you make a video about the s3 and it's wifi features
@BMonsterLaboratory
@BMonsterLaboratory 2 ай бұрын
Thank you! I'm definitely not done with the s3. 👍
@BMonsterLaboratory
@BMonsterLaboratory 5 ай бұрын
Here is the sketch I used in the video for temperature and humidity monitoring. It is not in the tutorial. /* BLE Environmental Monitor: An Arduino sketch for ESP32S3 that reads temperature and humidity using a DHT11 sensor and transmits the data via BLE to the LightBlue app for real-time monitoring on a smartphone. */ #include "BLEDevice.h" #include "BLEServer.h" #include "BLEUtils.h" #include "BLE2902.h" #include #define DHT_PIN 15 // GPIO pin connected to the DHT11 sensor #define DHT_TYPE DHT11 // DHT11 sensor type // UUIDs for BLE services and characteristics #define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E" #define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E" DHT dht(DHT_PIN, DHT_TYPE); BLECharacteristic *pCharacteristicTX; bool deviceConnected = false; BLEServer *pServer; class MyServerCallbacks : public BLEServerCallbacks { void onConnect(BLEServer* pServer) { deviceConnected = true; Serial.println("Device connected"); }; void onDisconnect(BLEServer* pServer) { deviceConnected = false; Serial.println("Device disconnected"); // Start advertising again to allow auto-reconnection pServer->getAdvertising()->start(); } }; class MyCallbacks : public BLECharacteristicCallbacks { void onWrite(BLECharacteristic *pCharacteristic) { std::string rxValue = pCharacteristic->getValue(); if (!rxValue.empty()) { String command = String(rxValue.c_str()); command.trim(); command.toUpperCase(); Serial.println("Command received: " + command); if (command == "ON") { // Handle other commands if needed } else if (command == "TEMP") { // Read temperature and humidity float humidity = dht.readHumidity(); float temperatureC = dht.readTemperature(); float temperatureF = (temperatureC * 9 / 5) + 32; // Convert Celsius to Fahrenheit // Check if any reads failed if (isnan(humidity) || isnan(temperatureF)) { Serial.println("Failed to read from DHT sensor!"); return; } // Prepare and send the data over BLE char tempHumidValue[40]; sprintf(tempHumidValue, "T: %.1fF, H: %.1f%%", temperatureF, humidity); pCharacteristicTX->setValue(tempHumidValue); pCharacteristicTX->notify(); Serial.print("Sent to app: "); Serial.println(tempHumidValue); } } } }; void setupBLE(String BLEName) { BLEDevice::init(BLEName.c_str()); pServer = BLEDevice::createServer(); pServer->setCallbacks(new MyServerCallbacks()); BLEService *pService = pServer->createService(SERVICE_UUID); pCharacteristicTX = pService->createCharacteristic( CHARACTERISTIC_UUID_TX, BLECharacteristic::PROPERTY_NOTIFY ); pCharacteristicTX->addDescriptor(new BLE2902()); pService->start(); // Start advertising pServer->getAdvertising()->start(); Serial.println("BLE advertising started. Waiting for a client connection..."); } void setup() { Serial.begin(115200); dht.begin(); // Initialize the DHT sensor setupBLE("ESP32S3_Env_Monitor"); // Setup BLE with a specific device name for the environment monitoring } void loop() { delay(5000); // Wait for 5 seconds between readings // Read temperature and humidity float humidity = dht.readHumidity(); float temperatureC = dht.readTemperature(); float temperatureF = (temperatureC * 9 / 5) + 32; // Convert Celsius to Fahrenheit // Check if any reads failed and exit early (to try again). if (isnan(humidity) || isnan(temperatureF)) { Serial.println("Failed to read from DHT sensor!"); return; } // Prepare and send the data over BLE char tempHumidValue[40]; sprintf(tempHumidValue, "T: %.1fF, H: %.1f%%", temperatureF, humidity); pCharacteristicTX->setValue(tempHumidValue); pCharacteristicTX->notify(); Serial.print("Sent to app: "); Serial.println(tempHumidValue); }
@BMonsterLaboratory
@BMonsterLaboratory 5 ай бұрын
Here is the sketch for the Bluetooth LED control. You'll find it in the tutorial under Sketch_13.2 /********************************************************************** Filename : BLE_USART Description : Esp32 communicates with the phone by BLE and sends incoming data via a serial port Auther : www.freenove.com Modification: 2022/10/26 **********************************************************************/ #include "BLEDevice.h" #include "BLEServer.h" #include "BLEUtils.h" #include "BLE2902.h" #include "String.h" BLECharacteristic *pCharacteristic; bool deviceConnected = false; uint8_t txValue = 0; long lastMsg = 0; char rxload[20]; #define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E" #define CHARACTERISTIC_UUID_RX "6E400002-B5A3-F393-E0A9-E50E24DCCA9E" #define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E" #define LED 2 class MyServerCallbacks : public BLEServerCallbacks { void onConnect(BLEServer *pServer) { deviceConnected = true; }; void onDisconnect(BLEServer *pServer) { deviceConnected = false; } }; class MyCallbacks : public BLECharacteristicCallbacks { void onWrite(BLECharacteristic *pCharacteristic) { std::string rxValue = pCharacteristic->getValue(); if (rxValue.length() > 0) { for (int i = 0; i < 20; i++) { rxload[i] = 0; } for (int i = 0; i < rxValue.length(); i++) { rxload[i] = (char)rxValue[i]; } } } }; void setupBLE(String BLEName) { const char *ble_name = BLEName.c_str(); BLEDevice::init(ble_name); BLEServer *pServer = BLEDevice::createServer(); pServer->setCallbacks(new MyServerCallbacks()); BLEService *pService = pServer->createService(SERVICE_UUID); pCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_TX, BLECharacteristic::PROPERTY_NOTIFY); pCharacteristic->addDescriptor(new BLE2902()); BLECharacteristic *pCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_RX, BLECharacteristic::PROPERTY_WRITE); pCharacteristic->setCallbacks(new MyCallbacks()); pService->start(); pServer->getAdvertising()->start(); Serial.println("Waiting a client connection to notify..."); } void setup() { pinMode(LED, OUTPUT); setupBLE("ESP32test"); Serial.begin(115200); Serial.println(" The device started, now you can pair it with Bluetooth!"); } void loop() { long now = millis(); if (now - lastMsg > 100) { if (deviceConnected && strlen(rxload) > 0) { if (strncmp(rxload, "led_on", 6) == 0) { digitalWrite(LED, HIGH); } if (strncmp(rxload, "led_off", 7) == 0) { digitalWrite(LED, LOW); } Serial.println(rxload); memset(rxload,0,sizeof(rxload)); } lastMsg = now; } }
ESPNOW for beginners! #ESP32 #ESP8266
35:09
Programming Electronics Academy
Рет қаралды 148 М.
I tried the 3 Cheapest Arduino Alternatives! (That you Suggested)
13:21
Mom had to stand up for the whole family!❤️😍😁
00:39
Крутой фокус + секрет! #shorts
00:10
Роман Magic
Рет қаралды 40 МЛН
Когда отец одевает ребёнка @JaySharon
00:16
История одного вокалиста
Рет қаралды 13 МЛН
啊?就这么水灵灵的穿上了?
00:18
一航1
Рет қаралды 51 МЛН
Forget WiFi! This Wireless Method is WAY Better?
12:14
GreatScott!
Рет қаралды 637 М.
How to Build an ESP32 Motion-Activated Camera 📷 Capture Every Move!
6:58
M5Stack Cardputer: ESP32-S3 Pocket Computer
17:06
ExplainingComputers
Рет қаралды 92 М.
Try these 16 Brilliant ESP32 projects!!!
11:18
ToP Projects Compilation
Рет қаралды 590 М.
ESP32-S3 - Which Pins Are Safe To Use?
5:58
atomic14
Рет қаралды 17 М.
This isn't a normal mini PC... and I love it.
14:17
Hardware Haven
Рет қаралды 413 М.
How to do Object Detection using ESP32-CAM and Edge Impulse YOLO Model
16:50
Best ESP32 board with AMOLED display - LilyGo T4 S3
13:35
Volos Projects
Рет қаралды 243 М.
12 Useful & Interesting ESP32 Projects for Beginners!
9:41
ToP Projects Compilation
Рет қаралды 630 М.
Mom had to stand up for the whole family!❤️😍😁
00:39