Thingspeak with two devices

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
serpa
New user
Posts: 4
Joined: 27 Dec 2015, 14:45

Thingspeak with two devices

#1 Post by serpa » 27 Dec 2015, 16:47

Hi,
I have just recently switched to ESPeasy and I have upgraded my working hardware :
1 ESP8277 07 with 1 DHT22 (temp & humidity) , 1 DHT21 (temp & humidity), 1 SHARP GP2Y10 (dust sensor) and 1 DSM501A (PM1.0 and PM2.5 dust sensor).
Previously all the data where sent to a private channel on thingspeak server and everything worked fine.

Now, switching to ESPeasy, I find that , already with two sensors redaing, only the data from first are correctly uploaded.

Afters some testing, I found out that the way ESPeasy works is to open a connection with the server for each sensor.

In this way the second sensor data are send too soon to the thingspeak server, which discardes them (this is a limit set on the server).

Does anybody knows a way to avoid this: either inserting a 20 sec delay between different sensor updates, or doing all the updates with a single connection?

many thanks

Martinus

Re: Thingspeak with two devices

#2 Post by Martinus » 27 Dec 2015, 17:33

It's been a while since we build that controller code, but I can remember that we set a 15000 mSec delay in tools/advanced/Message Delay.
Could work in your case.

doxikus
Normal user
Posts: 57
Joined: 22 Sep 2015, 08:47

Re: Thingspeak with two devices

#3 Post by doxikus » 03 Feb 2016, 08:47

Hi,

First I have problem with delay, I just need to change time of delay. I have DHT22 sensor and how to read humidity!? On thingspeak I have only temp readings, one graph. Is it even possible to have readings for temperature and humidity on thingspeak!?

Thanks

frey
New user
Posts: 1
Joined: 23 Apr 2016, 07:23

Re: Thingspeak with two devices

#4 Post by frey » 23 Apr 2016, 07:30

I've been having problems with thingspeak too; sensors that report 2 fields work ok because that is sent in one message, but all subsequent messages are sent too quickly for thingspeak. To prove this, i added a 15sec delay to the end of the thingspeak publishing routine, and now all sensors are working. This is not however the solution. The way esp easy publishes values makes it very difficult to publish everything in one message. Looks like thingspeak is only good for publishing one sensor per esp.

Martinus

Re: Thingspeak with two devices

#5 Post by Martinus » 23 Apr 2016, 16:35

Using ThingSpeak, you have to use sensor delays that are larger than the combined number of tasks x 15 seconds.
I'd recommend tasks x 30 seconds.

I'm running a testlab setup with 3 tasks, with a sensor delay of 90 seconds.
Message delay set to 15000

Seems to run without issues, system load is between 10-20%

andy
Normal user
Posts: 65
Joined: 26 Jan 2016, 23:07

Re: Thingspeak with two devices

#6 Post by andy » 26 Apr 2016, 01:24

frey wrote:I've been having problems with thingspeak too; sensors that report 2 fields work ok because that is sent in one message, but all subsequent messages are sent too quickly for thingspeak. To prove this, i added a 15sec delay to the end of the thingspeak publishing routine, and now all sensors are working. This is not however the solution. The way esp easy publishes values makes it very difficult to publish everything in one message. Looks like thingspeak is only good for publishing one sensor per esp.
Sorry it took me so long to see this.

See http://www.esp8266.nu/forum/viewtopic.php?f=4&t=1175 for a full discussion of how to interface w/ ThinkSpeak, including how to show more than one reading for a sensor.

nightshark
Normal user
Posts: 25
Joined: 29 Apr 2016, 06:54

Re: Thingspeak with two devices

#7 Post by nightshark » 11 May 2016, 15:21

I am trying to use two sensors: DHT22 and a DS18B20. I have them working, however the values are sent at different times to Thingspeak. How do I get them to sync to stop all of the null entries in my data?

andy
Normal user
Posts: 65
Joined: 26 Jan 2016, 23:07

Re: Thingspeak with two devices

#8 Post by andy » 11 May 2016, 20:25

I don't believe you can. ThingSpeak requires a 15 second message delay, so that pretty much guarantees you cannot sync them up.

nightshark
Normal user
Posts: 25
Joined: 29 Apr 2016, 06:54

Re: Thingspeak with two devices

#9 Post by nightshark » 11 May 2016, 20:35

andy wrote:I don't believe you can. ThingSpeak requires a 15 second message delay, so that pretty much guarantees you cannot sync them up.
Right, but there isn't a way to make the firmware send all the data at once?

oasuria
New user
Posts: 1
Joined: 20 Feb 2017, 10:23

Re: Thingspeak with two devices

#10 Post by oasuria » 20 Feb 2017, 11:01

Hi Everyone,

Seems like this discussion topic is quite old, but the problem mentioned in this post still persists. If you don't mind I would like to breath life into it once again ;)

I came across ESPEasy and was quite amazed with the flexibility of controllers and plugins, particularly its support for Thingspeak. I have some experience with coding on ESP to transmit data to Thingspeak. But in my case, I used to transmit data in batches, i.e. collect data for all fields in one request and transmit it.

ESPEasy's Thingspeak controller seems to be lacking in this area. Though as mentioned above, setting message delay to 15000ms can solve this issue of transmitting values from multiple sensors, but I find it to be very inefficient.

I am currently working on a modified controller for thingspeak which will allow accumulation of values from all sensors before publishing it to thingspeak. Hopefully this can be accomplished with changes to the plugin file and will not require any changes to core firmware.

My basic strategy would be (modified):
1) Have a list of 8 empty variables (for 8 allowable fields on thingspeak), referred to as buffer
2) Every time a request is received to publish values to thingspeak,
a) The plugin will store (overwrites if already there) the values in the list according to the sensor's idx (only for values corresponding to 8 fields in Thingspeak)
b) And check if the 15s (minimum thingspeak write time) has elapsed
3) If the 15s time has elapsed then all values in the buffer are transmitted to the thingspeak server, and buffer is emptied.
4) If no data is available in buffer then publish request is not sent.

This update eliminates the problem with multiple sensors publishing in 15s time period, resulting in only one publish being successful and others ignored. With this update, any new sensor values received within 15s of last publish will be stored in buffer and will be sent when next time the plugin is called and 15s have elapsed.

Please feel free to provide your suggestions and feedback for this proposed solution.

Update:
Updated Thingspeak plugin pull request on ESPEasy Playground can be found at following link:
https://github.com/letscontrolit/ESPEas ... nd/pull/24

Alternatively, you can download Thingspeak Controller Plugin (_C004.ino) directly from my fork of the playgound project.
https://github.com/omair-suria/ESPEasyPluginPlayground

I have also attached the zip file containing this plugin file
_C004.zip
Updated Thingspeak Controller Plugin
(1.64 KiB) Downloaded 360 times
Download it and replace the original thingspeak plugin (_C004.ino) with this one, compile, upload and Enjoy!!

Post Reply

Who is online

Users browsing this forum: No registered users and 92 guests