0

My project requires collecting data samples from an MPU6050 (i2c communication) at 1 KHz for 1 second, when the value exceeds a certain threshold. The data required are 3 axes acceleration data and the time in ms, totaling 8 bytes. So a sample would be ~8KB.

I am using ESP8266 NodeMCU with 4MB flash and 26MHz crystal.

Is the ESP8266 able to collect the data at 1 KHz through I2C to the memory?

If yes, which platform would be optimal (Arduino, Esplorer-lua, etc.)?

To be specific, which of these platforms would give more optimized machine code?

JRE
  • 67,678
  • 8
  • 104
  • 179
Padin
  • 1
  • 1KHz I2C with an 8K memory buffer should be no problem for even the slowest of those chips. – Ron Beyer Aug 19 '20 at 21:18
  • @RonBeyer - I think he means collect 8 bytes of data, 1000 times a second. That is 80,000 bits per second of payload. Add in the overhead of I2C it would be at least 200 kbps. It may work with a 400kHz i2c depending on how the data can be blocked together. – Kevin White Aug 20 '20 at 01:46

1 Answers1

1

The limiting factor here is the i2c transmission rate, not the CPU of the ESP8266.

As Kevin points out, there is overhead in i2c transmission. The i2c master (CPU) has to set a register, then send a read request, before clocking out the 6 bytes of acceleration data (3 axes x 16 bits per axis) from the i2c slave (sensor). So your estimate of 8kB/sec is about right.

Standard i2c at 100kHz can handle about 10kB/sec. That's cutting it too close. If the sensor-to-CPU PCB leads are short, you can use 400kHz i2c. It's just a configuration setting in the CPU firmware. The sensor has a 1kB FIFO buffer that will help if the CPU gets busy with some other task and can't maintain a 1000/sample/sec reading rate.

The ESP8266 should have enough computing power to request and store the sensor data to RAM, but it may get interrupted by other tasks for the radio, clocks, calculations, etc. You'll have to carefully write the software to prioritize collection of the sensor data stream, and put off any noncritical tasks while the data is coming in. Good luck!

Mark Leavitt
  • 5,073
  • 1
  • 8
  • 15
  • Could you suggest a platform that would give most optimised code for esp8266? – Padin Aug 20 '20 at 04:26
  • @Padin Your question already links to some suggestions. Please be aware that suggestions as such are commonly off-topic on StackExchange sites. – the busybee Aug 20 '20 at 09:43