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.

Double acoustic stopwatch and speed of sound
I always had a trouble to find a partner with a phyphoxed smartphone to reproduce the speed of sound experiment ( ). And even if you have it you should register the time measured by two smartphones and calculate all... So it would be nice to control the experiment by one smartphone and calculate the seed of sound automatically. I saw the recent forum thread "Device for experimental physics teachers" ( ) using the Arduino nano sense 33 BLE which has a microphone (unlike the SensorTag of Texas Instruments). Perfect to realize the project! Just ask for this particular Christmas gift Angel .

Instead of a second smartphone the Arduino board can be used. Just to adopt the acoustic stopwatch to it and transmit the measurements by Bluetooth to my smartphone which will do the rest. I have modified correspondingly the phyphox stopwatch in the smartphone. Here are the results. Maybe the programs are not yet perfect but they works. One may remove control communication of the Arduino via serial port to make it completely autonomous. Also a version with 3 claps is possible to realize bidirectional measurements reducing difference of these 2 stopwatches. Arduino sound threshold may be defined by the smartphone as well...

Happy New Year 2021!

The programs for the smartphone and the Arduino nano sense 33 BLE... The extension ".txt" of the latter should be changed to ".ino".

Attached Files Thumbnail(s)

.phyphox   acoustic_stop_mIv3.phyphox (Size: 11.02 KB / Downloads: 492)
.txt   timer_dec30b.txt (Size: 3.4 KB / Downloads: 462)
Hello Mikhail!

Great to see our project inspired you! I was working on the same Speed of sound experiment 2 weeks ago but I didn't finish before going on vacation. It seems like you did it for me! I am going to test your experiment in the next days and probably try to make the Nano board autonomous.

Best regards,
Hello Gautier.

My last version for you. I had a problem to send the threshold value to Arduino from smartphone, but it works now. I do not understand "PhyphoxBLE::configHandler=&receivedData;" and I add to the reinitialization simply "receivedData();"  (timer_dec30d.ino).

Now the experiment works so: 2 claps (1 over the Arduino, one over the smartphone, or vice versa) to measure the sound speed; 30 seconds the Arduino builtin led blinks and then remains in on state (the time you enjoy the results); 2 claps to return both watches to the initial state (the builtin led is off). No need to touch neither the Arduino nor the smartphone.

I think that it would be nice to control the Arduino (nano 33 ble sense) by light of different colors ( ..

I would be happy to see your version of the sound speed experiment.

with Brest regards

Attached Files
.txt   timer_dec30d.ino.txt (Size: 4.42 KB / Downloads: 426)
.phyphox   acoustic_stop_mIv4.phyphox (Size: 11.47 KB / Downloads: 479)
Hello Mikhail,

To be honest, I don't really understand the "PhyphoxBLE::configHandler=&receivedData;" part but it has always worked fine for me so I keep using it.
My version of this experiment was not finished and I believe I am not going to finish it since yours is doing a good job! I did not read your code in details but I think mine worked in a quite similar way.
I tried your program and it worked well, however I have a few remarks:
- the Arduino threshold is originally set to 4444, but I had to lower it to around 100 to make sure my claps were detected. Did it work for you with such a high threshold?
- in my opinion, resetting the experiment with 2 other claps and after 30 seconds is not very practical, especially when the experiment did not work. For instance, the phone heard the claps but the board missed one and you now have to wait 30 seconds until you can reset it. In addition, I did not manage to reset the experiment with the "bin" button of Phyphox, so I had to leave the experiment and open it again every time.
- I am probably going to try to modify your program at the end of the week, so it does not need to be connected to a computer to work. I believe this would be better in a classroom where it is not always practical to have computers everywhere.
- to avoid having to connect your phone to the board twice at the beginning of the experiment, you can follow these instructions:

Anyway, congratulations for your work! I am going to check your other topic about controlling with colors.

Best regards,
Hey everyone,

very cool projects! Just want to give a short explanation to the "configHandler" topic.

In your experiment the user can set a treshold with the edit field and send it to the arduino. The way you designed the .phyphox file, the treshold is transfered every analysis cycle. To actually use the last transfered treshold in your arduino sketch you have 2 options:

A) call: PhyphoxBLE:read(myFloat) to update the float variable myFloat with the newest treshold. The problem with this method is, that you dont have a strict time relation between new data has been transfered and is actually used in your sketch. You also have to call this function as often as possible to get the transfered data as soon as possible.

B) Instead of calling the read function many times you can write a function which is executed every time a new value is transfered to the arduino. Let say you want to blink your onboard led everytime you get data and update your float variable:

void example_function(){
digitalWrite(LED_BUILTIN, HIGH);
[size=small] digitalWrite(LED_BUILTIN, LOW);[/size]
[size=small] [color=#000000][size=small][font=Tahoma, Verdana, Arial, sans-serif]PhyphoxBLE[/font][/size][/color][color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]:read(myFloat);[/font][/size][/color][/size]

This function will do the variable update & blink job. Next step is to pass this function to the phyphox library so it gets executed after new data received.

  PhyphoxBLE::configHandler=&example_function; (this should be done in the setup block)

With this method you dont have to call the read-function as often as possible. This is especially useful if you receive new data very rarely. Hope this helps a bit.

Hi Dominik,

thank you for the explanations. Somehow "PhyphoxBLE::configHandler = &receivedData;" did not work correctly with the double stopwatch and I added direct reading.. In order to test the communication I have prepared a simplified example attached here. I have included to the communication function led blinking and printing of the transferred parameter. The function is called all the time (and led is blinking without interruptions) even if the value to be transferred is not changing in phyphox. Instead it is transferred every phyphox cycle...

For the stopwatch using of the configHandler may introduce some distortions of the Arduino part... And probably it did.. So probably it would be better to read the value when the time count is finished.

Bonjour Gautier.

Some answers to your comments:
- original set to 4444.4 is historical, I wanted to see from where the parameter is coming. The good Arduino threshold value for me is about 200 when I can move from Arduino to the phone without noise.
- when the Arduino and the phone are desynchronized the phone can be put to the original state by the "RESET" button. At the same time I did not want to touch the Arduino, particularly the Arduino reset button which brakes the Bluetooth communication. Two claps is coming from my modification "Contactless acoustic stopwatch" (attached here) when I produced a video with the stopwatch and did not want to appear in it.
- thank you for the given info how to make the program better.


Attached Files
.txt   PtoA1.ino.txt (Size: 1.36 KB / Downloads: 412)
.phyphox   PtoA1.phyphox (Size: 881 bytes / Downloads: 444)
.phyphox   acoustic_stop_mIv2.phyphox (Size: 7.9 KB / Downloads: 1,302)
Hello everyone.

Here is the last version taking into account the comments above and the best result Smile . In order to make the Arduino autonomous it is sufficient to eliminate the serial printing used now for control of the Arduino parameters.

With Brest wishes

Attached Files Thumbnail(s)

.phyphox   acoustic_stop_mIv4(double).phyphox (Size: 11.5 KB / Downloads: 454)
.txt   timer_dec30d.ino.txt (Size: 4.51 KB / Downloads: 413)
Dear creators of PhyphoxBLE,

we have decided to use the double acoustic stopwatch for our presentation of waves during the Fête de la Science this year. So it has been modified a little: All indication was assembled to one page and Arduino was equipped with a screen to see directly its measurements and parameters. Also I attempted to add a second parameter to be sent from smartphone to Arduino (the minimum time delay), but it did not work...

So the actual problem is that only second parameter sent pass correctly, the firs one coming as zero (parameters are float). This does not depend on input parameters "offset" and "length" of Bluetooth output. Could you help? Huh

The double acoustic stopwatch is functioning so: At the initial state of Arduino its RGB led is green. On the first clap the smartphone and Arduino start measuring, the Arduino RGB led is blue. After second clap the time measurement are stopped and indicated, the time measured by Arduino is sent via Bluetooth to smartphone and the sound speed is calculated. The Arduino RGB led is becoming red at this moment. After red is switched off after some seconds both smartphone and Arduino can be returned to original state by two more claps and the Arduino parameters (threshold and time delay) are sent via Bluetooth from smartphone to Arduino on the second clap. If Arduino and smartphone are desynchronized the "RESET" button on smartphone can be used. Current indications via Serial connection will be removed in the working version. Cool


With Brest regards.

Attached Files
.txt   timer_display3c.ino.txt (Size: 7.37 KB / Downloads: 399)
.phyphox   acoustic_stop_mIv4c(double).phyphox (Size: 11.78 KB / Downloads: 373)
AFAICT, “offset” is not implemented for the “output” block. The elders of phyphox (BLE) are on it…
So, actually it is not possible to send more than one value from smartphone to Arduino?

Forum Jump: