Sending timestamps to a channel | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





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

sp_Feed sp_TopicIcon
Sending timestamps to a channel
No permission to create posts
January 10, 2019
4:26 am
Avatar
cYnd

Silver
Members
Forum Posts: 5
Member Since:
November 12, 2018
sp_UserOfflineSmall Offline

Hi,

i want to send a timestamp to a field of my channel so i log when dawn happens everyday and see when it's dark outside.
However, i first sent a normal time (e.g. 16:37) with my raspberry pi and some python code. Unfortunalety i saw just 16 in the view of my channel. Retrieving data via GET returned the correct value.
Is there a way to send a timestamp to thingspeak and display it correctly? I also thought about sending it as float (e.g. 16.37) but this is also not a good solution since the data representation is wrong when the dawn jumps from e.g. 15:59 to 16:00.

January 10, 2019
2:00 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 727
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

Have a look at the write data page, in the "created-at" parameter.
https://www.mathworks.com/help/thingspeak/writedata.html
The format we use expect is ISO8601. Let us know if that works for you.

January 11, 2019
1:53 am
Avatar
cYnd

Silver
Members
Forum Posts: 5
Member Since:
November 12, 2018
sp_UserOfflineSmall Offline

Hi cstapels,

i could use the created-at field but what should i send as payload to Thingspeak? And even with that i had no vizualisation out of the box for that data then.

January 11, 2019
4:34 am
Avatar
rw950431

Top
Members
Forum Posts: 279
Member Since:
January 30, 2014
sp_UserOfflineSmall Offline

You could send a 1 when the sun rises and 0 when it sets..

But you can obtain the sunrise/sunset times without even looking outside from https://sunrise-sunset.org/api

January 11, 2019
8:28 am
Avatar
cYnd

Silver
Members
Forum Posts: 5
Member Since:
November 12, 2018
sp_UserOfflineSmall Offline

Sending 0 and 1 still gives me the problem that the vizualistion is not correct and i don't see a usefull diagram.
I also don't want to calculate the sunrise/sunset and measure the true lux value since i want to indicate if it's too dark to e.g. play outside (lux < 5).

Guess i need to stick to my workaround and sending 16.58 instead of 16:58 to Thinspeak and accept the fact that the chart isn't detailed.

January 14, 2019
12:30 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 727
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

If you use the created at parameter and send any value at all as the payload, you will see a single point on the x axis with that value. If you are trying to see a plot of values where the sunrise time is on the y-axis, you can convert to a float as follows:
timeFloat=hour+minutes/60. that will avoid this problem:
" I also thought about sending it as float (e.g. 16.37) but this is also not a good solution since the data representation is wrong when the dawn jumps from e.g. 15:59 to 16:00."

You can also plot datetime on the y -axis of a MATLAB plot. If you want to try this, use a MATLAB visualization to read the data and use plot. MATLAB will realize you are plotting datetime values.

Here is the code I used to check that was true.

data=datetime('yesterday'):hours(1):datetime('now')
moreData=1:37;
plot(moreData,data);

Just make sure your times are formatted for ISO8601.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
25 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

faaramin, swarnak32, SaiHarish.M, vikas, abhisheksharma, khoshghadam

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457