Fetching Sensor Data from ThingSpeak with Specific Date and

The code fetches sensor data from specific fields within a defined time range and formats the data as a timetable for further analysis.
0 Downloads
Updated 4 Sep 2024

View License

  1. 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.
  1. 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.
  1. 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.
  1. 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 Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0