Updating Thingspeak channel - multiple devices at same time

26 visualizaciones (últimos 30 días)
Ben Alimansky
Ben Alimansky el 17 de Sept. de 2020
Comentada: Ben Alimansky el 17 de Sept. de 2020
Hi! I have been using Thingspeak successfully for several years and really love the integration with Matlab for machine learning. I have an interesting issue I'm hoping someone can help me with.
My initial use of Thingspeak was with one ESP32 device updating a Thingspeak channel. Now that I'm having success with this device, I want to expand my product to work with multiple devices. Because I will have several devices that are all sending information to Thingspeak, I want them update the same channel but distinguish the data by an ID number that is associated with each respective device. However I'm running into a conflict. It appears that Thingspeak may be rejecting updates from different devices due to too many requests (my updates across different hardware are colliding with each other). Is there any way to fix this? Do I need a different license that would allow for concurrent updates to the same channel?
Alternatively, should I dynamically create a channel for each device? I considered that idea but it seems a bit more complicated (I would then have to create and remove channels when devices come online/offline) - but I'm open to whatever solution is going to be the most practical.
Thanks!
Ben

Respuestas (1)

Vinod
Vinod el 17 de Sept. de 2020
A ThingSpeak channel can be updated at most once a second with a paid license, or once every 15 seconds with a free license. If you have multiple devices updating the same channel, and their clocks are not exactly synchronized and updates staggerred to prevent one device trying to update a channel before the appropriate time has elapsed since the last update by another device, you will run into collisions like you are reporting. Even if your devices could synchronize their clock, it is likely that you cannot control exactly the time it takes for the HTTP request to make it to ThingSpeak servers, and it is quite possible that you will run into the issue of colliding updates.
My recommendation is to set up a single channel per device and use the channel tags linked to a serial number of the device to disambiguate. That way, when a device powers up, it uses the channels API to determine if a channel exists for it (search by tag) and if not, the device dynamically creates the channel. On subsequent disconnects and reconnects, it finds and updates the channel it had set up on initial connect. This is what I do with my dozen or so ESP32 devices.
I know for a fact that this approach scales to many 1000's of devices.
  1 comentario
Ben Alimansky
Ben Alimansky el 17 de Sept. de 2020
Vinod - thank you! I followed your explanation and think this is an excellent idea. I appreciate the quick response here as well.

Iniciar sesión para comentar.

Comunidades de usuarios

Más respuestas en  ThingSpeak Community

Categorías

Más información sobre Read Data from Channel en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by