I2S to WIFI

alongoldman
Posts: 5
Joined: Fri May 18, 2018 5:26 am

I2S to WIFI

Postby alongoldman » Mon Oct 08, 2018 9:50 am

I'm using I2S to extract data from ADC at 32bit 128KHz 2CH.
I'm trying to send the raw data over a WiFi socket to a .NET C# Winform application that just collects the data in an array
I'm experiencing occasional data loss, but I'm not even sure which side is at fault (PC or ESP).

What is the recommended I2S buffer size ?
What is the recommended number of bytes to send to the socket at each write command ?
Can you please issue any other advice ?

q515949148
Posts: 17
Joined: Wed Jul 25, 2018 8:11 am

Re: I2S to WIFI

Postby q515949148 » Thu Oct 11, 2018 7:57 am

Q:What is the recommended I2S buffer size ?
A:I think the larger the better.

Q:What is the recommended number of bytes to send to the socket at each write command ?
A: Maybe 1450? or use 1024 directly? I think it depends on your code.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: I2S to WIFI

Postby fly135 » Thu Oct 11, 2018 3:53 pm

Along with 1024 buffer sizes I recommend using queues to move data between an I2S reading task and an IP sending task. Also you failed to mention the type of socket. It should be TCP. My experience with the ESP32 is that you can expect a lot of lost packets in a congested wifi environment. So if you use datagram sockets then you will lose data.

John A

alongoldman
Posts: 5
Joined: Fri May 18, 2018 5:26 am

Re: I2S to WIFI

Postby alongoldman » Sun Oct 14, 2018 2:44 pm

i2s_read(ADC_I2S_NUM,(char*) &i2s_read_buff[0],i2s_read_len,&bytes_read,portMAX_DELAY);
EventBits_t uxBits=xEventGroupGetBits(xHMEventGroup);
if( ( uxBits & BIT_xHMEventGroup_sendRaw2Socket ) == BIT_xHMEventGroup_sendRaw2Socket ){
if(xQueuePeek(xQueueSocket, &s, 100 ))
{
bytes_sent = write(s , (char*) &i2s_read_buff[0] , bytes_read);
}
else {
xEventGroupClearBits(xHMEventGroup,BIT_xHMEventGroup_sendRaw2Socket);
}
}
}
free(i2s_read_buff);
vTaskDelete(NULL);
}

Separating it to read & write tasks is a good idea, i'll try it but I can't send the whole data via queue.
I'm using TCP socket.

Who is online

Users browsing this forum: Baidu [Spider] and 135 guests