andy neo in Discussions
最後のアクティビティ: 2022 年 8 月 31 日

Hi, I managed to get Thingspeak JSON data from my channel. However, I would like to know if theres any way to convert Thingspeak's JSON string data to decimal. I would really appreciate it if anyone could tell me how to convert it to decimal. Currently, this is my JSON: { "created_at": "2020-10-08T09:24:00.0000000Z", "entry_id": 1, "field1": "0", "field2": "12", "field3": "1", "field4": "1", "field5": "1", "field6": "1" } May I know if it is as simple as deleting the ""? For eg, { "created_at": "2020-10-08T09:24:00.0000000Z", "entry_id": 1, "field1": 0, "field2": 12, "field3": 1, "field4": 1, "field5": 1, "field6": 1 } Changing Thingspeak JSON string data to JSON decimal data Are you reading the JSON data with a device, or with MATLAB, or with some other code? MATLAB can definitely convert the JSON for you. On a device, you might consider using a JSON library, or reading a single field. When you read a single field, the number is returned as test, which might be easier for you to convert. Hi. I am sending sensor data from my hardware to Thingspeak. After getting the values in Thingspeak, I then write "https://api.thingspeak.com/channels/ChannelNumber/feeds/1.json" to get the JSON data in Thingspeak. The resulting result is: { "created_at": "2020-10-08T09:24:00.0000000Z", "entry_id": 1, "field1": "0", "field2": "12", "field3": "1", "field4": "1", "field5": "1", "field6": "1" } Hence, I was wondering if it is possible to change the strings for all of the fields to either decimal or integer. I sincerely apologize if I am asking a simple question but I just cant seem to figure out other than deleting the "", as the result of entry_id is an integer not a string. Hello I am facing the same problem. Sent data was 4.94, read data was 4.00. No idea why??? Sent data was 4.94 {"created_at":"2022-08-28T23:38:23-04:00","entry_id":1269,"field4":"4.94"}]} Read data was 4.00 Code: long PHTS = ThingSpeak.readLongField(counterChannelNumber, FieldNumber4, myCounterReadAPIKey); int statusCode = ThingSpeak.getLastReadStatus(); if (statusCode == 200) { Serial.print("ThingSpeak pH: "); Serial.println(PHTS); } How to display 4.94 (actual data) when reading the data. Thanks ThingSpeak.readFloatField json string to decimal

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.

モデレーター