Espruino Wifi and SPW2430(microphone) #1776
Replies: 19 comments
-
Posted at 2018-08-13 by @gfwilliams What you're doing sounds fine - and you've got the microphone powered from 3.3v as well? It sounds like the microphone won't output the complete 3.3v voltage range, but that's not a big deal - sound will just be maybe half as loud as it could be (and you can fix that in software afterwards by just multiplying the array up). The Waveform class is definitely what you want - PWM is only for output. The following code:
Should record something... Could you try running it while there is some sound for the microphone to record, and then see if any nonzero values get printed out? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-13 by jruroede @gfwilliams Thanks for the quick response! We are getting a nonzero range in the IDE, the bias from the DC pin on microphone is reading an output of 0.75v(according the hardware doc it should read 0.67v on 3.3v) I have it connected to the USBV of the espruino(could this be the problem?) it is being supplied 4.88v. Say we take this output and write it to a .raw file on an SD card(already setup with e.connectSDcard and correct pinout). How will I then get it to output the voice recording through the small two wire headphone also connected to the Espruino Wifi, Is this were I would utilize PWM?(the hardware speaker was checked for functionality using the buzzer from the making sounds and music tutorial provided by espruino and functions properly) Hardware Link: https://www.adafruit.com/product/2716 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-14 by jruroede Update: We are using PWM to output to the speaker attached to the espruino wifi, We are trying to play files we know work that we externally put on the attached SD card, we are only receiving fluctuating frequency. We have tried changing sample rate in the waveform class as well as the frequency of the analogWrite and w.startOutput functions cant find to get one to work but it does have an effect on the audio being output through the speaker. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-14 by @gfwilliams Ok - so you think recording may be working now, but it's the playback that isn't? Yes, on the WiFi you'd use PWM for output (it's only the original espruino board that has a DAC inside it). Where is your speaker wired? Try this on your WiFi. I have the speaker wired between GND and B3, and it seems to work fine - it plays a 'ding' noise (which is uploaded in the base64 code).
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-21 by jruroede I tested it and I hear no sound through the headphone. when I take a meter to it and send your code to the espruino I receive 1.59V for a short duration, which should indicate at least the signal is going through. Im using pin A7 but tried it with B3, both give me the 1.59V when code is deployed. I will try with a few different speakers I shouldn't need an amp to power a single small two wire earphone speaker right? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-22 by jruroede Update: tried new headphone its much louder than the last one and your code worked. Though still having similar problems as before with playing a voice recording. The code we are using is posted below.
Where "X-File.raw" is a file I made in audacity using the guide lines provided in the waveform documentation and is in the proper format of .raw(header-less) unsigned 8-bit PCM with a 8000hz playback speed. As I play the file I can accurately make out each spoken word in the sentence however it is very fuzzy to the point where you can barely make out the words and a single high pitch tone can be heard overtop of that audio. Can you recommend anything that can possibly fix this? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-22 by @gfwilliams Glad something is happening now! Try |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-22 by jruroede That worked perfectly! still getting a small amount of feedback that isn't a huge deal. Any recommendations to clean up the audio signal slightly more? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-23 by @gfwilliams What do you mean by feedback? You could add some external hardware to try and clean up the signal a bit by removing the high frequency element (just a resistor and a capacitor). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-23 by jruroede Its slight noise, I think the hardware recommendation will fix it. Is there anyway to get volume control without adding more hardware such as a digital potentiometer? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-23 by jruroede Okay, so after trouble shooting that im now back to my original question, regarding using SPW2430(microphone). The code you had given me works to give me non zero values from the IDE.
How can I record for X amount of time then save it as a .raw file to an SD connected to the espruino? this is my current code but its not functioning correctly.
IDE error code:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-24 by @gfwilliams
Just multiply the values in the buffer?
You're getting an error for the line The other option is you've previously saved code to Espruino, and it's not getting reset properly before upload so when you upload the new code it's causing errors |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-28 by jruroede It wasn't reset properly. This is the code im currently using for the voice recording using the SPW2430(microphone)
would the Hardware drive the values for var i? meaning if my mic can record from 100Hz to 10kHz do i put i=100,i<10000? with the code above the IDE writes
I still cannot get proper voice playback so I thought maybe my sample rate needed to go up but, when I change the sample rate to 1024 in waveform and and Uint16array the IDE gives me an error code.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-29 by @gfwilliams Ok, I think there are a few things here...
Something like this should work:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-29 by jruroede Thank you for clearing all that up! I really appreciate the fast response too, thank you for that. This is the first time im really trying to code something, im still very new to this. I had accidentally put analogWrite but I had meant to put analogRead, I thought I needed it because the signal is coming from the DC pin on mic into ADC of the espruino. When I run code you posted I get
I tried playing the new file changing proper parameters and Im getting static. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-30 by @gfwilliams Ahh, ok - try changing |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-30 by jruroede That did the trick! I play around with some of the values to try and up the quality, but I think im going to need external hardware for that. Thank you so much! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-28 by jruroede Do you have any suggestions on how to trouble shoot the audio for 16 bits? I keep trying to get sound at 16 bits but it's giving me back static, do you need to specify 16 bits in the playback code as well? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-10-01 by @gfwilliams Hi - I'll answer your email in a bit, but in answer to this: yes, you need the same number of bits for playback and record. If you record at 16 bits, but then play back at 8, basically what you're doing is playing back the high byte, then the low byte, and so on - so it'll be half-speed, and badly garbled :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-08-10 by jruroede
I have a problem with the SPW2430(microphone) only returning feedback to the Espruino Wifi. I have the DC pin of the SPW2430 attached to B0 of the Espruino Wifi and the correct GND pin. Ive utilized all links provided by espruino and arduino for audio recording using this hardware and its seems it should work. In the code i am using the waveform class, should i be using PWM? The intent is to record audio from the SPW2430 onto the espruino and output it to a small headphone attached to the correct pins on the espruino. The headphone was tested and works but im still having trouble with the audio recording. Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions