George in Discussions
上次活动时间: 2023-1-14

Hi there, I am using the following code in order to try and access th location of my device (via MATLAB visualization): myChannel=*******; ReadAPIKey='xxxxxxxxxxxxx'; myData=thingSpeakRead(myChannel,'ReadKey', ReadAPIKey,'numpoints',100,'outputformat','timetable','location',1); myVector=(myData.Latitude).^2+(myData.Longitude).^2+myData.Altitude.^2; maxVector=max(myData.Latitude)^2+max(myData.Longitude)^2+max(myData.Altitude)^2; myVector=myVector/maxVector; myMap=geoscatter(myData.lat,myData.long,15,myVector,'filled'); geobasemap('satellite'); colormap jet; At the moment, I have only 100 entries. However, I am getting the error : "Error using . Unrecognized table variable name 'lat'. Error in Custom (no starter code) 2 (line 7) myMap=geoscatter(myData.lat,myData.long,15,myVector,'filled');". How do i fix this error? Or where would i predefine "lat"? I do not want to set "lat" as a constant value as my device will be moving around and I want to access the location of the device per message sent, wherever it may be. Please may anyone assist. Location of a moving device, via MATLAB visualization You might try channel 876466 to practice reading data from. Its one of my channels with position data in it. I'm sorrry I didnt clean up the code I shared above. I had it and I wanted to share quickly but I didnt test it. Use myData.Latitude and myData.Longitude and you shouldnt get an error, assuming there is location data in the channel. To make sure there is position data in the channel, you have to use the format for the write REST call that I gave in the other post. The parameters for &latitude=xx and &longtitude=yy have to be written to the channel at least once. Every time you read the channel, you will get the most recent n points that show where your device is. There are a lot of ways to handle the changing number of entries. For one, when you read you can use a set time format parameter, such as days= or minutes=. Then thingspeak will retrurn as many points (up to 8k) that are in that time range. There are alse begin and end parameters, and you can use datatime manipulation to set rolling dates with your code. When you read the data, if you need to know the number of points, MATLAB has lots of functions to help with that (size, and height, for example) Another thing you can do is to increment a channel field witht he number of points, then read that channel value to know how many points there are. Hi there, thank you for this helpful reply. I adjusted the variable names and it seemed to be accepted. Upon searching for information about a REST api call, it said that i must search that call in my web's search bar. Is this the correct way to go about doing this? If not, what else would i do? Regarding the ways to handle changing the number of entries, I am slightly unsure on where to use "days=" or "minutes=" within that MATLAB visualization code which you sent previously.Where would I incorporate this in my code? Also, my aim is to solely see the location of the last message which has been sent, including indications of previous locations (the history of other locations). Would this be the best way to do this? Or is there another code which would do this best? If so, please may you share this code as i have struggled to do this and would greatly appreciate some assistance on this problem. Thank you Hi there Chris, please may you let me know if it is possible to show the location history of the device (thus the location of each of the messages recived) on Thingspeak? If it is possible, please may you guide me on how to do this. Thank you Can you clarify what you mean becasue I feel that was the question I already answered above. My aim is to show the location of each message that has ever been sent to the ThingSpeak channel. Such as the image attached below (an example from a Things.io channel). For each message recieved from my device, I want there to be a map and a pin at the precise location at which the message was sent. I am unsure on how to get the code above to do this. I am also still unsure on how to get the number of messages (the 260 or the 100 number in my case) to increase as the incoming messages increases. Also, I am unsure on how to connect the REST api call to the code. I did some research on it and it said to search the REST api call in your browser's search bar. However, this did not work. Please may you assist. Is there another way I could communicate with you, perhaps on email? Thank you for taking the time to describe your goal carefully. You say "show the location of each message that has ever been sent." If your device did not send its location, it is not possible for ThingSpeak to show you the location. Our service does not get the device location from the server if the device did not send the info. Does your device post its location data when it sends data to ThingSpeak? Is your device aware of its location? Support via email is available for holders of commercial or academic licenses. My dvice is sending information from Sigfox to Tingspeak. My Sigfox Atlas is enabled which allows the location of the device to be seen on Sigfox. This was my initial issue, which was how to send the location of my device from Sigfox to Thingspeak. I have a callback enabled on Sigfox's end which sends the "computedLocation" to my field4 of Thingspeak but nothing appears on Thingspeak's end (my goal here is to have a map showing the "computedLocation" from Sigfox), and this is why I think that I am sending the location from Sigfox incorrecly. Do you know how i could send the location from Sigfox to Thingspeak or any other way in which i could do this? I cannot find any resources which do this. Thanks Thats perfect, thanks for the clarification. I see that some of the info was in your earlier posts, but I didnt quite piece it all together. Can you show what the computed location on field 4 looks like - or can you share your channel ID if it is public? Is the data "lattitude,Longitude" or something like that? It might be easier if your callback from sigfox wrote the data into the lattitude and longitude fields, but we can also extract them form field 4 fairly easily too. Once you show me the data format, I can help you use the code above to read the last points in your channel. If you ask thingspeak for more data than you have, it will return the most recent data up to 8000 points. From what you said the problem about getting an increasing number of locations wont be a problem until you hit 8000. Lets get the map working first and then we can deal with the other issue. Yes I do see how my previous messages could have been confusing, but i really do appreciate all of your help. So on Sigfox this is the location which is being recorded (which is correct and quite precise). Following this, I attempted to make a callback following this blog (which uses thethings.io rather than Thingspeak) : https://blog.thethings.io/computedlocation-sigfox-and-visualize-on-a-map-your-devices/ . From this, I generated the following callback on Sigfox: But I do now recognize how this method could be incorrect since I have not recieved any information to do with location on Thingspeak's end.When I show field 4's visualization, it is a blank graph. This is how i know that I am not recieving anything from Sigfox with the above callback. However, since the link above is the only source that I can find which is doing what I aim to do, I am at a loss. Sigfox does have different variables which can be sent through a DATA-ADVANCED callback, which can be seen here: https://support.sigfox.com/docs/data-advanced . However, when I try to enter variables into the "Body" section of the callback, such as "computedLocation.lat", it says that "computedLocation.lat" is undefined and does not let me save the callback. I have also tried to see why this is the case but cannot find the solution. Thus, computedLocation was the variable which i have been attempting to pass to Thingspeak, as i imagine that once it is sent correclty, I will have access to a map on Thingspeak which illustrates the device's location per message sent, similar to the map above. This is a basically a summary of the root to my issue. I know that you have not worked with Sigfox so I really do appreciate your advice and guidance to solve this issue. I made my channel public so that you can see. My channel ID is 1970146 Thanks Im glad you redacted your API key, but I cant quite see the format you used. Is here any other field information in the URL pattern? Looking at your channel, there seems to be data getting in, was that data a result from the callback above? In the POST body, you should consider using field1=(some data) field3=(other data) field4={computedlocation} or something similar. Otherwise ThingSpeak wont know where you want to put the data. For the sigfox callback, I would consider using the body for your variables (like field4=) as in the JSON example here https://www.mathworks.com/help/thingspeak/writedata.html But I think the {computedlocation} question will have to go to sigfox, I'm sorry. Hi there Chris, thank you for your response. So from what I know, you set the field information in the "URL pattern" section of the Sigfox callback. The callback which is above was simply an attempt to get the {computedLocation} to send, the information which is showing on my page is a result of the callback below: So I set the URL pattern as https://api.thingspeak.com/update?api_key= XXXXXXXXXXXXX&field1={customData#temp}&field2={customData#t}&field3={customData#h} which thus sends information to the fields directly. The {computedLocation} is not sent from the Arduino code so that is why I didn't include it in this URL pattern and tried to create a separate callback for it. If this is not the best way to access location, is Thingspeak able to access the location of the incoming messages indpendently? Further, if this issue is beyond Thingspeak, I will go forward by attempting to ask Sigfox. Thank you! ThingSpeak does not have a way to localize message source. ITs too bad the callback cant access {computed location} becasue that would be a nice thing to write to ThingSpeak without having to add a GPS to your device. Please let us know if you figure out how to get the data from sigfox. I looked the their doc briefly and it seemed liek it should work close to how you had it above. I see. I will let you know when I manage to find a solution, thank you for all of your time and for your help, it was extremely helpful and is greatly appreciated! location dht11 arduino sigfox temperature humidity latitude longitude
George in Discussions
上次活动时间: 2022-12-18

Hi there, I am attempting to obtain a location history (thus the location of each of the previous messages recived) and the current location of my device on Thingspeak. I have not found any examples of how to do this on Thingspeak. Please may someone guide me or advise me on how to do this. Thank you Location history and current location mkr1200 arduino dht11 location sigfox
George in Discussions
上次活动时间: 2022-12-10

Hi there, I am trying to reach out to anyone who has successfully completed the project of building a weather station using an Arduino MKRFOX1200 board, a dht11 sensor across the Sigfox and Thingspeak networks. I’ve been attempting to build the weather station over the SigFox and things.io network for over a year now but I was unsuccessful. I then found this tutorial on how to build this using Thingspeak: https://create.arduino.cc/projecthub/masteruan/arduino-mkr-fox-1200-sigfox-meteo-station-423609 . I have now been attempting to build it using this network but am still unsuccessful. My SigFox and arduino is working. I made the arduino code convert temperature to Celsius (rather than Kelvin which is what the tutorial does). However, I am unable to access the location of the device on Thingspeak (my SigFox atlas is activated) and I am getting humidity values of approximately -30k. Please may someone assist me or give me a detailed approach on how to fix these issues. My goal is to have my thingspeak like this: https://thingspeak.com/channels/227248. I have followed the tutorial and projecthub but I cannot figure out why I am obtaining a confusing humidity reading. Please please may someone help. Thank you so much for your time. Weather station using dht11 sensor, Thingspeak and Sigfox This sounds like a hardware problem more than a ThingSpeak problem. You could try the projecthub if they have a forum or perhaps Arduino, though that is a stretch again since the problem seems to be with the sensor. I recomend drastic simplification. Write a program to read the sensor from your Arduino and output it to the serial monitor. Once you have that working, add another layer of complexity one at a time. Hi there, that makes sense, I will do that, thank you. However, I also wanted to know if you knew how to sned the location of the device per reading from Sigfox to Thingspeak (my Sigfox Atlas is enabled). I have found sources to do this with thethings.io but i am unsure on how to do it using thingspeak. When i try to do the "channel location" option on thingspeak, it gives me a default poaition og Lat.=0 and Long.=0. However, on my "device" tab on Sigfox, i can see a pretty accurate computed location of where my device is. How do I send this to Thingspeak? I am unsure on how to create a callback for this. Please may you assist if you can. Thank you The channel location is the base location of the device, such as your business or home. The device location parameters are in the channel feed data. See the Write data documentation for the parameters. https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=10&lat=40.2&long=50.1&elevation=200 Here is code to create a map from that data. You can create a MATLAB visualization to run this code and add it to your channel. Note the change from the word alititude to elevation. I modified this code from a different application, so if you get errors please let me know so I can fix it. myChannel=999999999999999; ReadAPIKey='xxxxxxxxxxxxxxxx'; myData=thingSpeakRead(myChannel,'ReadKey', ReadAPIKey,'numpoints',260,'outputformat','timetable','location',1); myVector=(myData.Latitude).^2+(myData.Longitude).^2+myData.Altitude.^2; maxVector=max(myData.Latitude)^2+max(myData.Longitude)^2+max(myData.Altitude)^2; myVector=myVector/maxVector; myMap=geoscatter(myData.lat,myData.long,15,myVector,'filled'); geobasemap('satellite'); colormap jet; %ax=gca; %ax.ZoomLevel=15; %probably dont need this since scale is set above Thank you very much for this helpful response. Will this line of code (https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=10&lat=40.2&long=50.1&elevation=200) be the Sigfox callback? Also, when running the MATLAB visualization code, i get the following error: "Channel ID must be a positive integer." . However, I do not see where my Channel ID is being used (nor where it could be a negative or not an integer). How could i ammend this? Or where is it reading my channel ID? Sorry, I've never used Sigfox, I probably should check it out. If you find out, please let us know. Regarding the error the channel ID is the first line in the code. The channel ID must exist. myChannel=999999999999999; Channel 999999999999999 does not exist. Change it to your channel ID. Also be sure to change the Read API key. So where would the line: "https://api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxx&field1=10&lat=40.2&long=50.1&elevation=200" be used? As previously I would have assumed it to be a SigFox callback And I see, thank you. I got this error: "Warning: 'Unable to read 260 points as requested. Only 68 points available in the channel. Error using . Unrecognized table variable name 'lat'." Where could I change the number of points? Would it affect the output? Also, where can i define the variable "lat"? sigfox thingspeak mkrfox1200 dht11 location arduino humidity weather station
George Popovici in MATLAB Answers
上次活动时间: 2020-7-14

Hello, Could you please help in explaining what is the difference between location data along the 8 available fields and location data on channel settings? Shouldn't be it be the same data? Below is an example: I set the location data: POST /update.json HTTP/1.1 Host: api.thingspeak.com Content-Type: application/x-www-form-urlencoded Cache-Control: no-cache Postman-Token: XX api_key=XX&lat=45.01&lon=27.01&1=44.444&elevation=10.1 I get the data from channel fields: { "channel": { "id": 1094740, "name": "Caravan_ESP32", "latitude": "44.412", "longitude": "26.123", "field1": "Humidity", "field2": "Temperature", "field7": "boot_count", "field8": "h_thres", "created_at": "2020-07-06T13:59:32Z", "updated_at": "2020-07-10T06:11:42Z", "last_entry_id": 11298 }, "feeds": [ { "created_at": "2020-07-10T05:51:33Z", "entry_id": 11298, "field1": "44.444", "latitude": "45.01", "longitude": "27.01", "elevation": "10.1" } ] } I get the data from channel settings: { "id": 1094740, "name": "Caravan_ESP32", "description": "", "latitude": "44.412", "longitude": "26.123", "created_at": "2020-07-06T13:59:32Z", "elevation": "", "last_entry_id": 11298, "public_flag": false, "url": "", "ranking": 30, "metadata": "", "license_id": 0, "github_url": null, "tags": [], "api_keys": [ { "api_key": "XX", "write_flag": true }, { "api_key": "XX", "write_flag": false } ] } As you can see above, location data is different. When I write location data as above, I would like to see it updated in the channel location. Is this possible? Thanks, George
James Agada in MATLAB Answers
上次活动时间: 2019-12-3

I have a channel in Thingspeak that will be receiving GPS coordinates of vehicles. How can I show a live track of the vehicles on a map? At any point clicking on the vehicle on the map will bring up additional information and allow for other actions.
Yacine Hammouche in MATLAB Answers
上次活动时间: 2019-5-10

Hello, First of all, sorry for my english, im a french student and my english is far from being perfect. Im trying to transmit location data from an ARDUINO ESP8266 device that has wifi. I stock the lat ant longitude data in field 3 and field 4 after transmetting them. Now, I would like to use matlab to read those data, stocking them into 2 variables, then use thigspeakwrite, to write those variables into location data. I did this code below, it says that is it ok, but the latitude and longitude fields dont change. % Template MATLAB code for reading data from a private channel, analyzing % the data and storing the analyzed data in another channel. % Prior to running this MATLAB code template, assign the channel ID to read % data from to the 'readChannelID' variable. Since this is a private % channel, also assign the read API Key to the 'readAPIKey' variable. You % can find the read API Key in the right side pane of this page. % To store the analyzed data, you will need to write it to a channel other % than the one you are reading data from. Assign this channel ID to the % 'writeChannelID' variable. Also assign the write API Key to the % 'writeAPIKey' variable below. You can find the write API Key in the right % side pane of this page. % TODO - Replace the [] with channel ID to read data from: readChannelID = [123456]; % TODO - Enter the Read API Key between the '' below: readAPIKey = 'AAABBB'; % TODO - Replace the [] with channel ID to write data to: writeChannelID = [123456]; % TODO - Enter the Write API Key between the '' below: writeAPIKey = 'XXXYYY'; %% Read Data %% a= thingSpeakRead(readChannelID,'Fields',[3],'ReadKey', readAPIKey); b= thingSpeakRead(readChannelID,'Fields',[4],'ReadKey', readAPIKey); %% Analyze Data %% % Add code in this section to analyze data and store the result in the % analyzedData variable. %analyzedData = data; %% Write Data %% thingSpeakWrite(readChannelID,'Location',[a,b,3500],'WriteKey','XXXYYY')

关于 ThingSpeak

The community for students, researchers, and engineers looking to use MATLAB, Simulink, and ThingSpeak for Internet of Things applications. You can find the latest ThingSpeak news, tutorials to jump-start your next IoT project, and a forum to engage in a discussion on your latest cloud-based project. You can see answers to problems other users have solved and share how you solved a problem.