Use of "thingSpeakWrite" command from Matlab | General | 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
Use of "thingSpeakWrite" command from Matlab
No permission to create posts
May 15, 2017
6:54 am
Avatar
Hondo
New Member
Members
Forum Posts: 4
Member Since:
May 15, 2017
sp_UserOfflineSmall Offline

Dear all,

if I using the "thingsSpeakWrite" command, I always get the error message "Undefined variable "matlab" or class "matlab.net.URI"Yell
Do I need an additional package/toolbox?

May 15, 2017
4:49 pm
Avatar
Adarsh_Murthy

MathWorks
Members
Forum Posts: 62
Member Since:
August 25, 2015
sp_UserOfflineSmall Offline

Hi, 

Thanks for reporting this issue. ThingSpeakWrite does not require any additional packages or toolboxes other than ThingSpeak Support Toolbox.

To help us investigate this issue further, could you tell us what version of MATLAB you are using? Also, what OS are you using? 

 

-Adarsh

May 16, 2017
3:12 am
Avatar
Hondo
New Member
Members
Forum Posts: 4
Member Since:
May 15, 2017
sp_UserOfflineSmall Offline

Hi Adarsh,

thank for your fast reply.
The output of the command "ver" entered in the command window is as follows:

-----------------------------------------------------------------------------------------------------------------------------------------------------

MATLAB Version: 9.1.0.441655 (R2016b)
MATLAB License Number: 841745
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 14393)
Java Version: Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
----------------------------------------------------------------------------------------------------
MATLAB                                                Version 9.1         (R2016b)
Curve Fitting Toolbox                                 Version 3.5.4       (R2016b)
Image Processing Toolbox                              Version 9.5         (R2016b)
Instrument Control Toolbox                            Version 3.10        (R2016b)
MATLAB Compiler                                       Version 6.3         (R2016b)
MATLAB Compiler SDK                                   Version 6.3         (R2016b)
Signal Processing Toolbox                             Version 7.3         (R2016b)

--------------------------------------------------------------------------------------------------------------------------------------------------------

Many thanks in advance and best regards
-Hondo

May 16, 2017
5:17 pm
Avatar
Adarsh_Murthy

MathWorks
Members
Forum Posts: 62
Member Since:
August 25, 2015
sp_UserOfflineSmall Offline

Hi Hondo, 

I am not able to reproduce the error using the version of MATLAB and OS that you are using. I suspect it might have to do with the path being corrupted in your MATLAB session. To help us find the root cause of the error, could you run the following code snippet and tell us if you see any errors. Note that you need to provide a write API Key for your channel in the code below:

 

thingSpeakURL = 'https://api.thingspeak.com/';
thingSpeakWriteURL = [thingSpeakURL 'update'];
writeApiKey = 'your write API Key';
fieldName = 'field1';
fieldValue = 42;
response = webwrite(thingSpeakWriteURL,'api_key',writeApiKey,fieldName,fieldValue)

 

Thanks,

Adarsh

May 17, 2017
5:03 am
Avatar
Hondo
New Member
Members
Forum Posts: 4
Member Since:
May 15, 2017
sp_UserOfflineSmall Offline

Hi Adarsh,

unfortunately I got the following error message after running the code with my API Key:

Error using webwrite (line 123)
Undefined variable "matlab" or class "matlab.net.URI".

Best regards,
Hondo

May 17, 2017
3:29 pm
Avatar
Adarsh_Murthy

MathWorks
Members
Forum Posts: 62
Member Since:
August 25, 2015
sp_UserOfflineSmall Offline

Based on this error, it looks like MATLAB path has been corrupted. Could you run the following commands to restore MATLAB default path setup:

 

>> rehash toolbox

>> rehash toolboxcache

 

After running the above two commands try to run the code snippet that I shared with you to see if the issue is resolved.

 

Thanks,

Adarsh 

May 18, 2017
3:40 am
Avatar
Hondo
New Member
Members
Forum Posts: 4
Member Since:
May 15, 2017
sp_UserOfflineSmall Offline

Hi Adarsh,

after I have added the folder "C:\Program Files\MATLAB\R2016b\toolbox\matlab\external\interfaces\webservices" with all subfolders to the MATLAB default path,  the issue is resolved and I can write data to my channels Smile.

Many thanks for your support and best regards,
-Hondo

May 19, 2017
8:02 am
Avatar
Adarsh_Murthy

MathWorks
Members
Forum Posts: 62
Member Since:
August 25, 2015
sp_UserOfflineSmall Offline

Good to hear. Thanks for letting us know. 

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
17 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

frenk0, Jassonchulp, MatGame, Domnesich, saxenadj, concepcionoa3

Administrators: Hans: 387, lee: 457