Chat freely about anything...

User avatar
By matkar
#20168 Hi,
I'm getting to know the ESP8266 module. I'm considering to use it in a project of mine. Firstly I tought I can use official AT command set but that prooved to be a dead end due to high latency when sending data. I followed the recomendation from one of you and now I'm learning about compiling ESP projects in Arduino environment. I have successfully installed all the necessary and I'm able to compile some ino examples found on this forum. There is a lot of information to chew and I'm sure I haven't seen the worst yet.
I've started this topic to ask the more experienced if my requirements even fit ESP8266 capabilities. Hopefully you can confirm this is doable or else I have to search for other hardware solution.
Here are my requirements:
1. AP mode
2. I need to establish up to 4 UDP connections with Android stations.
3. Most of the time the UDP data packets which will be 80 bytes long will flow from ESP AP to Android stations.
4. Broadcast messages can't be used since Android doesn't handle them well. I'm stuck with unicast meaning I have to send four times the same data to different addresses (I haven't looked into multicasting yet, don't know if it is possible to use multicast on both sides and if it will make some savings in terms of sent packets).
5. THE MOST HARSH REQUIREMENT: I need to send a least 25 packets per second to each station. That gives me 10ms time for sent packet in case four stations are connected to ESP.

With official AT command firmware I couldn't send more than five packets per second to single station. I hope this is only the limitation of that particular firmware and that the ESP radio is capable of sending and receiving UDP packets much faster.

So please let me know if I'm realistic about my expectations.

Furthermore is Arduino a suitable tool or perhaps is the LUA more optimized for this job?

Regards,
Mat
User avatar
By matkar
#21059 I've found this example: https://github.com/esp8266/Arduino/issues/74
where multicast is used to send data in STA mode. I have also seen this description: https://github.com/sandeepmistry/esp8266-Arduino where it states: Also note that multicast doesn't work on softAP interface. meaning multicast unfortunately can't be used in AP mode.
I have modified the example a little and made some tests to see how it behaves when a higher quantity of packets has to be sent from the ESP to multicast address. I used HAME MPR-A1 as a router and USB based EDUP EP-MS6528 as a station on my PC - basically it is low end equipment. Data portion of packets was 80 bytes long. I was sending data in one direction only.
I have added a counter to see if any packets have been lost. Here are the results:
delay: 10ms - theoretical throughput: 100 packets/s - nr. received packets: cca 97/s - max lost packets: cca 3
delay: 5ms - theoretical throughput: 200 packets/s - nr. received packets: cca 187/s - average lost packets: cca 4
delay: 4ms - theoretical throughput: 250 packets/s - nr. received packets: cca 220/s - average lost packets: cca 15

I have counted the lost packets by checking the counter value in consecutive packets. the other missing packets to reach theoretical throughput can probably be attributed to non interrupt driven delay loop.
At 10ms it looses packets very rarely . Most of the time all the packets get through. No matter the delay, missing packets tend to stick together like YYYYYYYYNYYYNYYNNYYYYNYYNYYYYYYYYYYYYY indicating some anomaly happens occasionally.
It seems the number of lost packets starts to increase considerably around the 5ms interval but I can't say if the cause is the ESP module or other equipment used in the test.

Anyway I'm more than pleased with the results. It's a big step forward form the stock AT firmware I have been trying to use previously.
Does anybody know if multicast in soft AP mode is going to be supported in the future?

Regards,
Mat
User avatar
By matkar
#21087 I did some additional tests. I got rid of the EDUP wifi station and connected the PC to HAME router over a cable. Now I don't have problems sending packets even with 2ms delay. I don't loose any of them - all get through.
But with 1ms interval the problem repeats. I only receive around 522 packets and they are locally not consecutive. For one period packets are consecutive (with a little more than 1ms interval), then every second packet is received, then again it starts to receive all packets. This probably means the source of trouble is not ESP module but again the router.

I'm not going to test this any further since the throughput is much higher than I needed in the first place.
Since in softAP mode multicast is not supported I will use unicast and send separate packets to four stations. I have to test the throughput in AP unicast mode yet to see if it can also achieve 2ms delay between packets. This would mean every fourth station can be updated every 8ms which is more than I need.

Nevertheless I hope multicast will be supported in softAP mode in the future.

Regards,
Mat