miketeachman / micropython-esp32-i2s-examples

Usage and examples for I2S support on the ESP32 microcontroller
MIT License
152 stars 29 forks source link

Recording does not work.Outputs "T" #3

Closed asturkoglu closed 5 years ago

asturkoglu commented 5 years ago

Hi, Thanks for your i2s examples. When I try read-mono-mic-write-internal-flash example it outputs exec(open('./read-mono-mic-write-internal-flash.py').read(),globals()) T and does nothing till I stop program (and sd part remains empty). I've ESP32 DevKit and SPH0645 MEMS. What is wrong with my setup (or why I'm false)? If you help me, I'll be glad.

Edit: I've tried with different board. (ESP32 Lite CH340) This time I faced with an error about I2S. I guess "T" stands for Traceback, the main error was cannot import name I2S

miketeachman commented 5 years ago

Hi, I'll try to help. But, I need to better understand what you are trying to do. Some questions:

  1. where do you see the output? exec(open('./read-mono-mic-write-internal-flash.py').read(),globals()) T? e.g. in the REPL?
  2. How did you run the example? e.g. copy the file to main.py? or run it with the REPL using ctrl-E and ctrl-D?

For the problem with the ESP32 Lite

  1. From the REPL, can you run from machine import I2S with no errors?

Note:

asturkoglu commented 5 years ago

First of all about your note; I tried also SPH0645 example (write it to SD) and got same result. Thanks for your interest.

I'm using yPyCraft V1.1, so wrote the example to the flash then run it (it's under the device section) In REPL I wrote from machine import I2S, output is same ImportError: cannot import name I2S. However I saw this example in different ESP32 board, normally with my ESP, I only saw ... T part, but I assume Micropython Terminal did not give me full output. T does not mean anything, it should continue with Traceback error ................ cannot import name I2S

It's about the missing libraries, I'm also searching how to install libraries etc, I've lib folder under my device, but empty. I should figure out how to use upip I guess

miketeachman commented 5 years ago

All I can think right now is somehow your ESP32 build does not include the required I2S commit. Note that none of the MicroPython official releases include the I2S pull request I submitted

Here the commit that adds the I2S feature to the ESP32: https://github.com/miketeachman/micropython/commit/6b023290f6dbccfdb427857120cd12c292e622f2

I suggest to check your ESP32 build to make sure this commit is included.

asturkoglu commented 5 years ago

@miketeachman do you have a recommended build and step-by-step instructions for this? I couldn't install the lib I think. I also try it with 8mb psram version and I guess they need different firmwares.

miketeachman commented 5 years ago

@xastx I would make an ESP32 build using the newest commits, following the instructions here: https://github.com/micropython/micropython/tree/master/ports/esp32

After you get the ESP32 build running, add the I2S commit files and re-build.

I have not tried the 8MB version - only the 4MB and the base versions.

asturkoglu commented 5 years ago

@miketeachman since I'm unfamiliar with the environment, I failed. First I completed first 4 steps in this link https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html#introduction Then I stucked at make SDKCONFIG=sdkconfig.myboard part in your instructions link. I do not know what should I do. Shame on me :/

miketeachman commented 5 years ago

Getting a working build is often difficult. I would place a bet that NO-ONE gets a MicroPython build running without some problem(s) along the way. If you have the interest to keep trying, I suggest asking for some help on the MicroPython forum, in the ESP32 discussion topic. https://forum.micropython.org/viewforum.php?f=18 Most of the people who follow this ESP32 topic have figured out how to make a build and would help you to get your build running.

asturkoglu commented 5 years ago

@miketeachman do you know how can I solve this error? I have pyparsing, checked via import pyparsing

ast@lenovo:~/esp/micropython/ports/esp32$ make
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build/esp32.common.ld
Traceback (most recent call last):
  File "/home/ast/esp/esp-idf/tools/ldgen/ldgen.py", line 22, in <module>
    from fragments import FragmentFileModel
  File "/home/ast/esp/esp-idf/tools/ldgen/fragments.py", line 20, in <module>
    from sdkconfig import SDKConfig
  File "/home/ast/esp/esp-idf/tools/ldgen/sdkconfig.py", line 18, in <module>
    from pyparsing import Word, printables, Combine, Literal, hexnums, quotedString, Optional, nums, removeQuotes, oneOf, Group, infixNotation, opAssoc
ModuleNotFoundError: No module named 'pyparsing'
Makefile:788: recipe for target 'build/esp32.common.ld' failed
make: *** [build/esp32.common.ld] Error 1
miketeachman commented 5 years ago

It is really difficult to help ...but, here is a guess. You might have two or more Python installations on your machine (e.g. Python 2.7 and Python 3.6). The MicroPython build is using a Python installation (e.g. Python 2.7) that does not have the pyparsing package installed...but when you run Python at the prompt, you run a different python version (e.g. Python 3.6) that has pyparsing installed.

asturkoglu commented 5 years ago

Thank you, I finally succeeded! Since 6 months past, your commit lines are little bit different from up-to-date Makefile lines, but ok. Previously, I was working on Pi, now I switched to Linux laptop. Works fine. I might open another issue to improve recording quality (samplerate etc.) Now I'm trying it with different ratios.