This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

ESP32 No data
#1
Hello, I am using the ESP 32 code  and the QRP shown at the phypox site https://phyphox.org/wiki/index.php?title...ed_sensors
Here is the code below. I had to change the name from  MyESP32 to Arduino so the app can find it.
After clicking on the + and Add experiment from QR code , the experiment analogReadTutorial opens, I then pick my device.
When I click on run, not data appears.
Any ideas what is happening?

Thanks,Dan

//#############################################################################
//In this sketch a BLE server with one service and one characeristic is created.
//The analog input (pin 36) is readout periodically.
//#############################################################################

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#include <esp_system.h>

//uuid's can be generated on https://www.uuidgenerator.net/
#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "59f51a40-8852-4abe-a50f-2d45e6bd51ac"
BLECharacteristic *aCharacteristic;

uint8_t analogValue;

void setup() {
 Serial.begin(9600);

 //BLE server is being initialized
 //create one BLEService and one Characteristic
 BLEDevice::init("MyESP32");
 BLEServer *aServer = BLEDevice::createServer();
 
 //uuid for the BLE service is set
 BLEService *aService = aServer->createService(SERVICE_UUID);
 
 //uuid for the BLE characteristic is set
 //the characteristics properties are defined
 aCharacteristic = aService->createCharacteristic(
                     CHARACTERISTIC_UUID,
                     BLECharacteristic:TongueROPERTY_READ   |
                     BLECharacteristic:TongueROPERTY_WRITE  |
                     BLECharacteristic:TongueROPERTY_NOTIFY
                   );

 //BLE server is being started
 aService->start();
 BLEAdvertising *aAdvertising = aServer->getAdvertising();
 aAdvertising->start();

}

void loop() {

 //analog Input 36 is read out and saved into the 8bit unsigned int "analogValue"
 analogValue = analogRead(36);
 //the measured value is written to the characteristic
 aCharacteristic->setValue(&analogValue,1);
 aCharacteristic->notify();
 delay(100);

}
Reply
#2
Hey,

thank you for reporting this bug. I checked the example and realized that there was no "Descriptor" at the BLE Server. If you are not familiar with Bluetooth Low Energy and you are in interested in the background:

To receive the newest data from a microcontroller phyphox wants to get a notification (at least in this example). This notification service needs to be requested by the smartphone (or any other BLE device you are using) . This request is stored in the so called descriptor. If you want notifications  - the value in the descriptor is 1 if not its 0.

I just changed a few things in the example:
- added the missing descriptor
- calculated voltage with the analog-digital converter value and used a "new" feature of the esp32 library to send a float value much more comfortable

Propably this problem occurs due to the the much older Bluetooth library I used when this example was created. However, we are also currently working on a library (for the new bluetooth-capable Arduino Nano Series & ESP32) to make the data transfer much more comfortable & user friendly!


You can find the updated version in our wiki:
https://phyphox.org/wiki/index.php?title...ed_sensors
Reply
#3
(02-11-2020, 05:12 PM)Dominik Dorsel Wrote: Thank you Dominik, the new code works great!

thank you for reporting this bug. I checked the example and realized that there was no "Descriptor" at the BLE Server. If you are not familiar with Bluetooth Low Energy and you are in interested in the background:

To receive the newest data from a microcontroller phyphox wants to get a notification (at least in this example). This notification service needs to be requested by the smartphone (or any other BLE device you are using) . This request is stored in the so called descriptor. If you want notifications  - the value in the descriptor is 1 if not its 0.

I just changed a few things in the example:
- added the missing descriptor
- calculated voltage with the analog-digital converter value and used a "new" feature of the esp32 library to send a float value much more comfortable

Propably this problem occurs due to the the much older Bluetooth library I used when this example was created. However, we are also currently working on a library (for the new bluetooth-capable Arduino Nano Series & ESP32) to make the data transfer much more comfortable & user friendly!


You can find the updated version in our wiki:
https://phyphox.org/wiki/index.php?title...ed_sensors
Reply


Forum Jump: