Updating Thingspeak channel - multiple devices at same time

조회 수: 21 (최근 30일)
Ben Alimansky
Ben Alimansky 2020년 9월 17일
댓글: Ben Alimansky 2020년 9월 17일
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

답변 (1개)

Vinod
Vinod 2020년 9월 17일
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
Ben Alimansky
Ben Alimansky 2020년 9월 17일
Vinod - thank you! I followed your explanation and think this is an excellent idea. I appreciate the quick response here as well.

댓글을 달려면 로그인하십시오.

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

Help CenterFile Exchange에서 Read Data from Channel에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by