Recommended Interconnection Methods for Phyphox and External Sensors

Recommended Interconnection Methods for Phyphox and External Sensors

——Also answering a question from a certain student at a university

Since I started using microcontrollers to expand the external sensor technology of Phyphox about one or two years ago, I have experienced the process of connecting Phyphox with ESP32, Arduino UNO + Bluetooth BLE, Arduino Nano BLE/Sensor, as well as STC51, C8051F, MSP430 and any microcontroller through Bluetooth BLE to communicate data with Phyphox. The narrative here clearly emphasizes one point: Phyphox must connect with anything other than a mobile phone through Bluetooth BLE.

Most users of Phyphox lack a technical background in microcontrollers and encounter various difficulties in practical work, even under the relatively low technical threshold of Arduino UNO. People need technology that is as user-friendly as possible and with minimal learning costs. This is the biggest problem faced by Phyphox in expanding external sensors to build a low-cost sensor experimental environment.

Thus, we can understand the technical distinctions in the interconnection methods of Phyphox and external sensors: one is the previously mentioned “user-friendly + minimal”, and the other is complex and flexible applications. The former has a larger promotion space, while the latter has greater potential for technical research. The former is the interconnection method suggested below, which is not recommended by Phyphox officially, but is currently the most practically meaningful.

The following will explain through the challenges of the ESP32 board and support libraries, the convenience of Arduino Bluetooth debugging, and the general program template on the Phyphox side, without involving specific codes and experiments. (To explain the background: Recently, many people have asked me to solve the ESP32 and Phyphox interconnection problem. Firstly, I indeed do not have time to respond; secondly, my level is really limited; and thirdly, some problems that were solved for a few individuals cannot be referenced by others with similar issues, so I organized my rough experiences into rough notes for reference. In fact, I noticed some domestic and international Phyphox technical websites, which cover a wide range of topics and deep research levels, and I truly have not found a place worth studying more than my public account (boastingRecommended Interconnection Methods for Phyphox and External Sensors) If there are technical problems with Phyphox that cannot be solved, then even going to the official Phyphox forum, the possibility of resolution is not very high (still boastingRecommended Interconnection Methods for Phyphox and External Sensors) So I still suggest spending some time learning (researching the notes in my public account, really can boast a lotRecommended Interconnection Methods for Phyphox and External Sensors)

1. Challenges with the ESP32 Board and Support Libraries

There are many development environments for ESP32, all of which can be used under Arduino IDE. The relatively older and outdated Arduino was already a huge and ubiquitous ecosystem formed before the emergence of ESP32. Many people have migrated from Arduino to ESP32 and naturally use Arduino IDE—ESP32’s Micro Python is also widely used, but compared to the C++-like language of Arduino IDE, it still seems to be at a disadvantage.

The bad news is that installing ESP32 board support under Arduino IDE is not an easy task. This board support library requires downloading about 200M to 300M of files and needs a JSON-specified download script. Due to network reasons, downloads can be extremely slow or even fail. Some kind-hearted individuals have created one-click installation packages or copied scripts, but still, many problems arise; there are also users of ESP32 & Phyphox under Linux systems like Ubuntu and Deepin, facing a myriad of various issues.

Many problems cannot be immediately resolved even when facing the screen directly, let alone just providing some hints of error messages.

My summary is that out of dozens, nearly a hundred issues, the vast majority are simply due to errors in installing the ESP32 support library, such as missing files, incorrect paths, mixed versions, multiple installations, etc. In addition, there are some issues that arise when burning programs under Arduino IDE, such as incorrect settings for ESP32 board type, serial port location, etc.—the ESP32 standard boards and modified boards from various companies are extremely fragmented compared to Arduino UNO, and the standards are indeed not unified enough.

Given the above situation, for users entering this field for the first time, I recommend staying away from ESP32. By staying away from ESP32, one also stays away from the official Phyphox product PhyphoxBLE support library, and even further away from the installation difficulties of the ESP32 board support library.

2. Convenience of Arduino Bluetooth Debugging

Recommended Interconnection Methods for Phyphox and External Sensors

One type of Arduino UNO development board (image sourced from Baidu)

Unless there is a special pursuit of novelty, the original and various imitation versions of Arduino UNO are relatively unified. Most importantly, once the Arduino IDE is installed, it supports the Arduino UNO development board by default, without any settings or adjustments required. When developing experimental programs, it is no different from developing and writing any usual Arduino UNO program. When needing to print data to the serial port, one still simply uses

Serial.println("demo");

function command.

As mentioned earlier, the bridge for Phyphox to connect with ESP32 is Bluetooth BLE. Bluetooth modules that support BLE standards, such as HC-08, JDY-24M, etc., can be used.

Recommended Interconnection Methods for Phyphox and External Sensors

One type of HC-08 Bluetooth BLE module (image sourced from Baidu)

Once all the normal functionalities required by the sensors have been debugged under Arduino, we can now use our own Bluetooth BLE to communicate with Phyphox. This is why it is possible to detach from ESP32 and the recommendation to no longer use ESP32. The key processing in the program:

  1. Comment out all Serial.print or println string commands; Phyphox does not receive them anyway.
  2. Convert all data to be transmitted to Phyphox into strings and concatenate them into one string, separated by “#”, and print it out using Serial.println(); for example:
……
double T, P;
……
Serial.println(String(T) + "#" + String(P));
……
  1. Observe in the Arduino IDE’s serial monitor to see if it is correct. If correct, close the serial monitor.
  2. Connect Bluetooth BLE to Arduino UNO. Done.

Clearly, all the practices here are purely knowledge of Arduino, and the learning cost to allow external sensor data to enter Phyphox is almost zero.

Wiring. Taking BMP180 and JDY-24M Bluetooth BLE as examples, here is the wiring introduction. BMP180 is a commonly used pressure sensor that can measure both pressure and temperature, and JDY-24M Bluetooth supports the BLE standard. It seems that after the chip shortage began, this Bluetooth module suddenly entered people’s sight. Compared to HC-08, JDY-24M seems to be less stable. The following connections have only been tested on the Arduino UNO side, and the ESP32 side has not been tested. Using ESP32 in the manner described in this article, it is best to avoid doing so, because if the ESP32 support library is installed correctly, there is really no need to add another Bluetooth BLE on top of it; the ESP32’s WIFI/BLE is the main selling point of this chip. Additionally, ESP32 has three sets of serial ports, and IO1, IO3 are just the set that is commonly used in Arduino syntax.

Recommended Interconnection Methods for Phyphox and External Sensors

3. General Program Template on the Phyphox Side

The program on the Phyphox side can be modified using the Phyphox online editor template, which is far more flexible than using PhyphoxBLE to create experiments under Arduino IDE.

The template’s functionality needs to accomplish the following tasks:

  1. Search for Bluetooth BLE through Phyphox and connect normally;
  2. Transmit our “#” separated string to Phyphox and split it again;
  3. Write the program in the Phyphox Web Editor and download it into Phyphox.

Using the BMP180 as an example again, the key code in the Phyphox template does not need to be changed:

……
    <input>
        <bluetooth editor:uuid="97" editor:posx="109.88330078125" editor:posy="163.433349609375"    mode="notification" rate="1" subscribeOnStart="false">
            <output char="0000FFE1-0000-1000-8000-00805F9B34FB" conversion="formattedString" separator="#" index="0">Output 1</output>
            <output char="0000FFE1-0000-1000-8000-00805F9B34FB" conversion="formattedString" separator="#" index="1">Output 2</output>
        </bluetooth>
    </input>
……

According to this template, import the .phyphox program into the editor and modify it according to the actual experimental needs. This is the only small investment in learning for this interconnection method.

All done, the wiring is not complicated, and it’s still readable:

Recommended Interconnection Methods for Phyphox and External Sensors

Additionally:

Phyphox interconnecting external sensors, the official PhyphoxBLE supports not only ESP32 but also Arduino Nano BLE/Sensor, although the latter is expensive and still requires installing board support libraries, which does not reduce the difficulty for beginners. Besides, it is also possible to achieve interconnection between external sensors and Phyphox through MQTT, which is currently being studied at an extremely slow pace.

——With a dream in mind, enjoying experiments and entertaining myself is a miracle——

Recommended Interconnection Methods for Phyphox and External Sensors

Places worth learning for experimental teaching:

Leave a Comment