Do two Pi's clash with each other when sending to ThingSpeak? | Raspberry Pi | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Register Lost password?
sp_Feed sp_TopicIcon
Do two Pi's clash with each other when sending to ThingSpeak?
Avatar
HyFy
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
1
January 18, 2017 - 9:37 am
sp_Permalink sp_Print

Hi

I'm having a problem with one or other of two Pi's clashing with each other trying to send data to 5 fields on the same channels on ThingSpeak. The loser crashes.

I have two Pi's. One is back home in England and that has been happily sending temperature data every 10 minutes from three Ds18b20's in different parts of my home for weeks if not months. See Channel 62333; Fields 1 thro' 3.

The second Pi is here with me in Spain and I've been trying the same thing with two more DS18b20s; again every 10 minutes to Fields 4 and 5. when this starts up it runs OK until the times of the two Pi's sending information become close; at which point one or other fails in the posting and eventually one crashes.

Has anyone got an idea as to how to avoid this without spending "big money" on separate Channels?

Thanks

HyFy

Avatar
rw950431

Forum Posts: 250
sp_UserOfflineSmall Offline
2
January 18, 2017 - 6:49 pm
sp_Permalink sp_Print sp_EditHistory

The updates are probably failing due to the 15 second rule- you cant update the same channel more often than 15s. Why this causes them to crash is impossible to say without knowing more about the code you are using- the only difference in response is that you get 0 instead of a positive number if your update fails. This shouldnt cause anything to crash.

I would have thought that your internet-connected Pi's should be able to run an NTP client that keeps their time in sync so as to avoid the timing conflict, given you have 10 minutes between updates.

As a worst case you could modify your program to re-try after 15 seconds if it gets the 0 return code.

Avatar
HyFy
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
3
January 19, 2017 - 4:49 am
sp_Permalink sp_Print

Thanks for that "rw950431". 

I'll review my coding but at the moment I can't think that the "0" response on it's own is causing the crash. The terminal display just gives "Connection Failed" or "200OK" and then tries again 10 minutes later.  It seems that after a succession of failures it just gives up the ghost.

I'm a bit stuck with what I can try here (basking in the hail, snow, gales and floods of southern Spain) as I don't want to try anything that will crash the one at home which I can't re-start from here.

I'm not sure about the "try again in 15 seconds option" as that may keep the two pi's in conflict for longer.  I'll put something on paper and see what it does.

Thanks for your suggestions.

HyFy

Avatar
rw950431

Forum Posts: 250
sp_UserOfflineSmall Offline
4
January 19, 2017 - 7:01 pm
sp_Permalink sp_Print

HyFy said

I'm not sure about the "try again in 15 seconds option" as that may keep the two pi's in conflict for longer.  I'll put something on paper and see what it does.
 

HyFy  

If you check the return code and ensure that only the failed one retries this wont be a problem since the first one will suceed and not retry.

Maybe you have a memory leak in your code thats only triggered by the error condition?  It seems odd though since every request still returns the same "200 OK" status even if the channel rejects the update.   Could it be that the error condition doesnt properly close the connection so eventually you run out of available sockets? ("netstat --inet" is helpful here along with "ulimit -n" to get the max)

When you say "crashes" what exactly do you mean?  The process sending the data exits or the whole RPi somehow locks up?

One option is to modify your local copy to push the data somewhere else temporarily (I often use https://requestb.in/ for such purposes) and see if that makes the problem go away.

Avatar
HyFy
New Member
Forum Posts: 3
sp_UserOfflineSmall Offline
5
January 21, 2017 - 9:07 am
sp_Permalink sp_Print

rw950431 said

Maybe you have a memory leak in your code thats only triggered by the error condition?  It seems odd though since every request still returns the same "200 OK" status even if the channel rejects the update.   Could it be that the error condition doesnt properly close the connection so eventually you run out of available sockets? ("netstat --inet" is helpful here along with "ulimit -n" to get the max)

When you say "crashes" what exactly do you mean?  The process sending the data exits or the whole RPi somehow locks up?

I'll have a second go at this. The gremlins got into my last reply and dropped it where everYell.

In my original I mentioned that I either get "Connection Failed" or "200 OK" depending on whether there had been a conflict  or not. If the were a series (sometimes even only one) of the former the sending Pi locked up and if it was at a distance, I could not restart it.

But you have given me plenty to read up on and try out once I have access to both Pi's.

I will let you know what the results are....

...and if this rain in Spain (which is not on the plain) doesn't ease up I will be home and trying things sooner rather than later!!

Thanks again

HyFy

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online: alexparrado
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 250

Vinod: 142

piajola: 73

vespapierre: 63

Adarsh_Murthy: 59

cstapels: 54

Newest Members:

chrissaxon

getty

l3inbin

ossan

gbalychik

wul

Forum Stats:

Groups: 4

Forums: 17

Topics: 1242

Posts: 4315

 

Member Stats:

Guest Posters: 1

Members: 5546

Moderators: 0

Admins: 2

Administrators: Hans, lee