Skip to content

i2s get data from internal ADC #1227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wizz777 opened this issue Mar 17, 2018 · 7 comments
Closed

i2s get data from internal ADC #1227

wizz777 opened this issue Mar 17, 2018 · 7 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@wizz777
Copy link

wizz777 commented Mar 17, 2018

----------------------------- Remove above -----------------------------

Hardware:

Board: ESP32 Dev Module
Core Installation/update date: 11/jul/2017
IDE name: Arduino IDE
Flash Frequency: 80Mhz
Upload Speed: 115200

Description:

Try to get data from internal ADC from i2c
but in RX data only zero
mic- MAX9812
Pin36 -> Mic OUT
GDN -> Mic GRND
3V -> Mic VCC

Sketch:

#include "driver/i2s.h"
#include "driver/adc.h"

int i2s_num = 0;
i2s_config_t i2s_config;

char* buf1= (char*) malloc(32768*2);

void example_disp_buf(uint8_t* buf, int length)
{

Serial.print("======\n");
for (int i = 0; i < length; i++) {
    Serial.printf("%02x ", buf[i]);
    if ((i + 1) % 8 == 0) {
        Serial.print("\n");
    }
}
Serial.print("======\n");

}

void setup() {
Serial.begin(115200);

//config i2s
i2s_config.mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_RX | I2S_MODE_ADC_BUILT_IN);
i2s_config.sample_rate = 48000;
i2s_config.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT;
i2s_config.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT;
i2s_config.communication_format = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB);
i2s_config.dma_buf_count = 2;
i2s_config.dma_buf_len = 512;
i2s_config.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1;

//install and start i2s driver
if(i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL)==ESP_OK) Serial.println("1 driver OK");
if ( i2s_set_pin(I2S_NUM_0, NULL)==ESP_OK) Serial.println("2 pin OK");
if (i2s_set_adc_mode(ADC_UNIT_1, ADC1_CHANNEL_0)==ESP_OK) Serial.println("3 mode OK");
if (i2s_start(I2S_NUM_0)==ESP_OK) Serial.println("5 i2s OK");
}

void loop() {
int i= i2s_read_bytes(I2S_NUM_0, buf1, 32768*2, portMAX_DELAY);

Serial.println(i);

example_disp_buf((uint8_t*) buf1, 164);
delay(550);


### Debug Messages:
Out in Serial
1 driver OK
2 pin OK
3 mode OK
5 i2s OK
65536
======
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 ======
65536
======
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 
00 00 00 00 ======
65536

@hongthiet1994
Copy link
Contributor

Did you slove this problem?

@wizz777
Copy link
Author

wizz777 commented Sep 28, 2018

No

@hongthiet1994
Copy link
Contributor

No

Do you have skype account, can we discuss?

@Matheus-Garbelini
Copy link

Any progress?

@lbernstone
Copy link
Contributor

The IDF example includes i2c_adc_enable(), which I'm guessing is the missing #4 in your list.

@stale
Copy link

stale bot commented Aug 1, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Aug 1, 2019
@stale
Copy link

stale bot commented Aug 15, 2019

This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Aug 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

4 participants