2

I'm trying my first IoT project whereby I want to:

  • have an electret microphone capture audio
  • have an ESP8266 NodeMCU 12-E board submit captured audio to a remote server
  • have a remote server receive the audio data using an MQTT server
  • publish the audio data as a .WAV file on the server

I saw someone online demonstrate something similar in this YouTube video

https://www.youtube.com/watch?v=rU_Pw9Jb_PM

The author shared the project on github here

https://github.com/hjltu/esp8266-wifi-microphone

When I study the code, I think what I see is the author taking the value of analogRead(A) and appending it to some kind of string as a payload, which is then published to an MQTT server.

I see that the author expects the MQTT server or some other software to process the ESP8266 microphone audio data and output it as a .RAW file. This RAW file is eventually converted to a .WAV file with the help of ffmpeg.

My question is this: What command allows MQTT server to generate the .RAW file? Or is this done by an entirely different software? And it appears to me that for a single recording/audio file, the my_record() of esp8266-wifi-mic.ino file will send multiple payloads to the MQTT server. So how does the MQTT server know which published transmission belongs to which RAW file?

  • There no such thing as a MQTT server, it's a MQTT broker. Brokers don't do any processing of data, messages are received by another MQTT client that subscribed to the topic that messages are published on – hardillb Jan 27 at 7:36
4

You are correct about the microphone input, void my_record() samples the microphone output level 1000 times, appending each reading to a string variable and publishes the resulting string to an MQTT broker.

This process repeats 11 times every time my_record() is called.

note: You are sort of misunderstanding about the .RAW file. It is a raw file, meaning that it is unprocessed and unformatted .... just a stream of bytes. Using the term .RAW implies a file name extension.

What command allows MQTT server to generate the .RAW file?

The MQTT broker (server) does not generate the raw file, the file is published to the MQTT broker by an outside source, the ESP8266 in this instance.

So how does the MQTT server know which published transmission belongs to which RAW file?

It does not know. All it does is to relay messages. It is up to the publisher to send to the correct topic and it is up to the subscriber to watch the data at the correct topic.

The messages could arrive to the subscriber out of sequence, so a sequence number needs to be included with the message if a correct data sequence is desired.

Have a look at these for a visual demo of MQTT messages.

https://shiftr.io/shiftr-io/demo ... you can only subscribe to this one

https://shiftr.io/try or https://shiftr.io/shiftr-io/try ... you can publish to this one (and subscribe)

You can get your own account and watch your own messages being sent and received without the clutter of other messages.

  • Oh....I see. So that means I need to create another client application to read subscription data from MQTT server, and save content to a .raw file? – John Jan 26 at 23:58
  • 1
    exactly correct ..... the MQTT server is just a long pipe for your data – jsotola Jan 27 at 0:04
  • data can arrive out of sequence though ..... updated answer – jsotola Jan 27 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.