Page 1 of 1

I2S to WIFI

Posted: Mon Oct 08, 2018 9:50 am
by alongoldman
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 ?

Re: I2S to WIFI

Posted: Thu Oct 11, 2018 7:57 am
by q515949148
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.

Re: I2S to WIFI

Posted: Thu Oct 11, 2018 3:53 pm
by fly135
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

Re: I2S to WIFI

Posted: Sun Oct 14, 2018 2:44 pm
by alongoldman
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.