How to push data to ThingSpeak while reading sensor data in the background

Hi all,

I am currently developing a safety device using an MPU6050 to work out the tilt of the device using a sequential Kalman filter. However, I also want to push some data to a ThingSpeak channel at a fixed time interval. The problem begins with the time taken for the Thingspeak.writeFields function to send the data as it halts the reading of the sensor and thus the computation of the angle which is supposed to trigger an alarm if it exceeds a safe angle. So for clarity I want to be able to read sensor data constantly as it will need to trigger an alarm and I also want to push data at a fixed time interval to thingspeak without halting the reading of the sensor and the triggering of an alarm. Is there anyway this can be achieved on an Electron board? Thankyou in advance.

Welcome to the community :+1:

To answer your question it would be good to know how you are talking to ThingSpeak and also what your intended sensor reading interval is and what the maximum acceptable delay for that would be.

Are you using any motion detection or interrupt features of the MPU6050 library?

Welcome @Rowie,
For me personally, I much prefer using a Webhook verses the ThingSpeak Library.
I suggest using the " No Acknowledge" Flag w/ your scheduled Particle Publish for routine data.
This method is the most bandwidth friendly I’ve found using ThingSpeak w/ Particle Cellular Devices.
Your Alarm Condition would Not use that flag, and may block computation for a short period of time (depending on your architecture).