You can chat about native SDK questions and issues here.

User avatar
By Pail Roy
#86441 Hello

I'm using ESP8266_RTOS_SDK to read data from ads1115 ADC using GPIO0/2 as I2C pins on esp8266 esp-01.My software gets data at 100 samples/sec and sends it through an UDP socket in a continuous loop, with no datagram losses ( but some ocassional crashes :? ).
My ADC is configured in continuous mode and II'd like to reach at least 275 samples/sec, but no matter how i configure faster ADC sanpling speed I receive 100 sps. As esp8266 is using bit banging for I2C, do you think it could reach that 275 (even 800) sample rate? Should I tweak something inside core_esp8266_wiring_shift.c file or similar internal code? What could restrict speed here? (There are no long lines,or capacitors in my wiring )
User avatar
By eriksl
#86482 The I2C code from Espressif is very inefficient. Most I2C devices can use a 400 kHz bus without a problem, but the Espressif code won't even reach 100 kHz. My implementation can reach 450 kHz (on 160 MHz processor). I am thinking of a "Chuck Norris" mode that leaves out all asserts and assumes everything is going as it should (same quality level as the Espressif code) and that would probably reach the 1 MHz bus speed. It may need that the bit patterns for SDA and SCL be prepared and output simultanuously. Interesting project I think.
User avatar
By Pail Roy
#86490 Thanks for your responses.
I'm able to reach 400 SPS by not sending any UDP datagram...which is of course useless and does not cover the full 800sps capacity of ADS1115. So it seems quite possible I2C implementation is not,at least, fast enough to reach full adc sample rate.
But it seems also IP stack implementation is not very fast. I'm thinking of storing N adc samples in a buffer, then sending all N samples at once in an unique sendto( ) call,and hope this balances sendto( ) delay for some N...

Also, this uses a RTOS in the end...My loop does both I2C and UDP send in same iteration. Perhaps I should introduce two tasks in synch, and hope that I2C waits are programmed (in Expressif code) in such a way the UDP task can work while the I2C one is waiting...Do you think this is feasible with the RTOS SDK?
Then,maybe playing with task priorities could also have some benefit. Do you have any pointer about what I2C code part or tasks could I tweak?

The curious think is I started this in the NONOS bare metal, and then I saw how easy was I2C in SDK that i left that and started with RTOS... :lol:

Thank you very much.