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.

Multiple Sonsors (integrated and BT) via MQTT
#1
Hey Folks,

i really like your App, since i have several old smartphones lying around here that can be used as sensors.
For different applications/projects my demand is the following:
- Collecting various data with an ESP32 or Arduino and sending it to phyphox-app via BT
- Collecting various data from smartphone sensors
- Sending BT and smartphone sensor data via MQTT/Wi-Fi to an external server
- no data logging/saving in smartphone wanted since the logging and visualisation will be done on server

Now i'm facing following issues that i'd really appreciate your assistance:
- How can i can send more than one value from ESP32? i tried it with following sketch:
     
Code:
#include <phyphoxBle.h>

void setup() {
    PhyphoxBLE::start();                //Start the BLE server
}

void loop() {
    float randomNumber = random(0,100); //Generate random number in the range 0 to 100
    float sense = millis();
    PhyphoxBLE::write(randomNumber, sense);    //Send value to phyphox
    delay(1);                          //Shortly pause before repeating
}

but i only see the value 'randomNumber' in the app, not 'sense'

- from starting a new experiment in the app, i can only choose "Bluetooth experiment" or "simple experiment",
how can i create an experiment with both BT-data and integrated sensor data?
- how can i use the MQTT-functionality? unfortunately i haven't found anything about that topic yet. (i'm using app version 1.1.7)
- how can i read the sensor data, without logging them?

Best regards from way up north in Germany
Jan
Reply
#2
Hey Jan,

let me start with the bluetooth topic:

With the "new bluetooth experiment" option in phyphox you will get the phyphox-configuration (xml file) which is store on your esp32/arduino. By default its a simple experiment which expects just a single float value. If you would like to customize this experiment to display more data (or change units and so on) you have different options:

A) Create your custom epxeriment directy within the Arduino IDE. Therefore you might want to check the phyphoxBLE example "createExperiment".

But keep in mind that this library feature does not support all features you might now from other phyphox experiments. This leads me to another option

B) Use the p web editor: https://phyphox.org/editor/

With the web editor you can create "easily" your own experiment-configuration (at least using the smartphone sensors ). For bluetooth communication things get a litte bit more complicated, because you need some bluetooth low energy specific information. I think a good way for beginners to start is to use the experiment which is created in "createExperiment". You can get your customized "createExperiment" the following way:
  • customize the experiment/sketch to your personal needs
  • flash the experiment to the ESP32/Arduino and open it with phyphox (new bluetooth experiment)
  • press on the 3 dots in top right corner -> save experiment -> share it by mail or any messenger you can use on your pc. 
  • go to phyphox.org/editor and press "load experiment" (bottom left)
Now you can further customize the experiment with the online editor or check how the bluetooth part is done. 


I have to say here aswell: The online editor has much more features than the arduino library but it is also limited. To use all available features you have to create the xml/phyphox file by your own. To get an idea how the the actually .phyphox file looks like press on the "xml" tab in the online editor.
Feel free to mix these 3 techniques to create your own experiment!

Also you might want to check out the phyphox wiki to get more information about bluetooth, analysis modules and so on.

https://phyphox.org/wiki/index.php/Analysis_modules
https://phyphox.org/wiki/index.php/Bluetooth_Low_Energy

The MQTT support is quite new, so there are not many examples available right now. Also the web editor does not support this feature right now. But you can get some information in the wiki. There is also an example to send acceleration data via MQTT

https://phyphox.org/wiki/index.php/Network_Connections

I know Sebastian is using an ESP32 with a CO2 sensor and send these values via MQTT (ESP32 has wifi on board!), maybe he can share his sketch to get an idea how it works. 

Hope this solves your questions! Otherwise feel free to ask for a more detailed explanation =)

Cheers
Dominik
Reply
#3
Hey Dominik,
thx a lot for your extensive answer! I will play around with it and come back with (hopefully) positive results, as soon as i find some time to do so.
I know that the ESP32 has WiFi onboard and i have a few projects with ESP32 and ESP8266 working with mqtt, sending data to IOBroker. I really like the easy way to build visualisation UI`s and log data with IOBroker, thats why i was waiting for MQTT functionality in Phyphox and was glad to see that it's integrated now.
Cheers Jan
Reply


Forum Jump: