{"id":3077,"date":"2022-08-08T09:28:58","date_gmt":"2022-08-08T13:28:58","guid":{"rendered":"https:\/\/blogs.mathworks.com\/iot\/?p=3077"},"modified":"2025-12-08T15:41:47","modified_gmt":"2025-12-08T20:41:47","slug":"post-images-to-thingspeak-channels-from-your-iot-devices","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/iot\/2022\/08\/08\/post-images-to-thingspeak-channels-from-your-iot-devices\/","title":{"rendered":"New Feature: ThingSpeak Now Supports Images"},"content":{"rendered":"
Many users have asked, and it’s finally here: Your devices can upload images to ThingSpeak!<\/strong><\/p>\n With this new feature, you can create a cloud-based tracking or monitoring system for your important assets by taking photos and uploading them to ThingSpeak image channels. Users with a paid ThingSpeak license can create image channels<\/a> and then embed the output from the image channel onto a channel view using the image widget<\/a>.<\/p>\n To help you get started, the ThingSpeak documentation includes two examples for uploading images to ThingSpeak: ESP32-CAM camera module<\/a> and Raspberry Pi-connected camera<\/a>.<\/p>\n Here is some MATLAB code that will write to an image channel from your computer. This code will help you get an image into ThingSpeak without needing an IoT device. Save an image to your system and name it “myImage.jpg”.<\/p>\n If everything worked, you should expect a StatusLine<\/em> of\u00a0 ‘HTTP\/1.1 202 Accepted’ in the response. If you want to see this image on a channel view, follow the steps in the documentation<\/a>.<\/p>\n In both cases, you will get a status code that you can check using the status endpoint<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":" Many users have asked, and it’s finally here: Your devices can upload images to ThingSpeak!
<\/a>
Many ThingSpeak channels represent a particular IoT project. Previously, to show an image in the channel view you had to go to some lengths – including copying from third-party location<\/a> using MATLAB visualizations<\/a> or using an existing photo<\/a> on the web. The ThingSpeak images feature uses your MATLAB Drive space<\/a> to store images, so they will be available for your channels whenever you need them.<\/p>\n% Import these libraries to use the HTTP interface.\u00a0
% They are in base MATLAB, no extra license is required.
import matlab.net.http.*
import matlab.net.http.field.*
import matlab.net.http.io.*
% Edit this section for your files. Timestamps are optional.
channelId = 'X1X1X1X1X1';
channelApiKey = HeaderField('thingspeak-image-channel-api-key', 'ZZZZZZZZZZZZZZZZ');
filename = 'myImage.jpg';
clientTimestamp = '2022-01-29T15:06:35.642Z'; % Optional Timestamp
provider = FileProvider(['.\/', filename]);
req = RequestMessage(RequestMethod.POST, [channelApiKey], provider);
url = ['https:\/\/data.thingspeak.com\/channels\/', channelId, '\/images\/', ...
filename, '\/', clientTimestamp ];
response = req.send(url)<\/pre>\n
<\/a>
Be careful when saving a regular stream of images, they can fill up your drive space fast. Here is MATLAB code to delete a date range of images.<\/p>\n
import matlab.net.http.*
import matlab.net.http.field.*
import matlab.net.http.io.*
% Edit this section with your information.
channelId = 'x1x1x1x1x1';
channelApiKey = HeaderField('thingspeak-image-channel-api-key' ...
, 'xxxxxxxxxxxxxxxx');
endDate = datetime('now');
startDate = endDate - days(3);
fmt = 'yyyy-mm-ddThh:MM:ssZ';
startDate = datestr(startDate,fmt);
endDate = datestr(endDate,fmt);
pathRange = sprintf('\/images?timestamp=ingest&start=%sZ&end=%s',...
startDate,endDate);
req = RequestMessage(RequestMethod.DELETE, [channelApiKey]);
url = ['https:\/\/data.thingspeak.com\/channels\/', channelId, ...
pathRange];
response = req.send(url)<\/pre>\n
<\/div>\n
\nWith this new feature, you can create a cloud-based tracking or monitoring system for your important… read more >><\/a><\/p>\n","protected":false},"author":175,"featured_media":3089,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22,4],"tags":[296,299],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/3077"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/users\/175"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/comments?post=3077"}],"version-history":[{"count":15,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/3077\/revisions"}],"predecessor-version":[{"id":3561,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/3077\/revisions\/3561"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/media\/3089"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/media?parent=3077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/categories?post=3077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/tags?post=3077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}