Fetching Sensor Data from ThingSpeak with Specific Date and
Version 1.0.0 (4.15 KB) by
Kunal Khandelwal
The code fetches sensor data from specific fields within a defined time range and formats the data as a timetable for further analysis.
- Time Initialization:
- The script first defines the start and stop times using datetime and dateshift functions.
- datetimeStart marks the beginning of the current hour.
- datetimeStop is set to 30 minutes after datetimeStart, effectively creating a 30-minute window.
- Initial Data Fetching:
- The first thingSpeakRead call retrieves the last three data points from fields 1 and 2 of the specified ThingSpeak channel (2635364).
- The retrieved data is formatted as a timetable and stored in the variable data.
- Data Fetching with Date Range:
- The script then refines the data retrieval by specifying a DateRange between datetimeStart and datetimeStop.
- It reads data only from field 2 of the channel within this 30-minute window, formatting it as a timetable.
- Key Parameters:
- Channel ID: 2635364
- ReadKey: ''
- Fields: Specifies which fields of the ThingSpeak channel to read from.
- NumPoints: Limits the number of data points retrieved (3 in the initial call).
- OutputFormat: Specifies that the output should be in the form of a timetable.
This code is useful for scenarios where you need to monitor and analyze specific time-bound sensor data from a ThingSpeak channel.
Cite As
Kunal Khandelwal (2024). Fetching Sensor Data from ThingSpeak with Specific Date and (https://www.mathworks.com/matlabcentral/fileexchange/172199-fetching-sensor-data-from-thingspeak-with-specific-date-and), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2024a
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0 |