How to extract value from a string: thingspeak.getFieldValue(3));
古いコメントを表示
Hi,
I built, with a NodeMCU ESP8266, a receiver of the data transmitted by a weather station connected to ThingSpeak, based on the project by Daniel Eichhorn (http://blog.squix.ch).
From the string "display-> drawString (40 + x, 15 + y, thingspeak.getFieldValue (3) + "m/s");" of the sketch I get the value of the wind speed expressed in m/s, while I would need the value expressed in Km/h. I can't find a solution to "extract" the numeric value from the string <thingspeak.getFieldValue (3)> to then multiply it by 3.6, and get the value in Km/h.
Could anyone suggest me a solution?
Thank you.
Giuseppe
4 件のコメント
Christopher Stapels
2020 年 4 月 15 日
create a variable before that line.
float myFieldValue = thingspeak.getFieldValue (3) ;
myConvertedValue = myfieldValue * conversionFactor;
then
display-> drawString (40 + x, 15 + y, String(myConvertedValue) + "m/s");
Peppino Lanni
2020 年 4 月 15 日
Christopher Stapels
2020 年 4 月 17 日
Is the error on this line?
float myFieldValue = thingspeak.getFieldValue (3);
?
It is probably becasue getFieldValue(3) returns a string. So read it into a string and then use the .toFloat function to turn it into a float. Then convert it, then trun it back to a string to display.
Peppino Lanni
2020 年 4 月 18 日
回答 (0 件)
コミュニティ
その他の回答 ThingSpeak コミュニティ
カテゴリ
ヘルプ センター および File Exchange で ThingSpeak についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!