accelerometer data from Raspberry to Thingspeak not displaying properly

조회 수: 3 (최근 30일)
Claire McV
Claire McV 2019년 12월 18일
댓글: Vinod 2019년 12월 24일
Hello
I am hoping someone can help please. I have connected my raspberry pi 3 to a Thingspeak channel and set up two fields to be read and displayed, 'Temperature' and 'Accelerometer'. The temperator information is displayed as a field chart but the accelerometer is not. I know the raspberry pi is reading it as the values are printing and when I use 'export recent data' I can see the information there. Am I missing something in getting accelerometer information to display as a field? I am importing with 2 fields but I checked with another field (pressure) and it worked so I know the code for two fields is right.
Any help greatly appreciated.

답변 (3개)

Vinod
Vinod 2019년 12월 19일
Are you sure your data in the field 2 is numeric? When you export the data, does it show as numeric or text?
If the data in the field is non-numeric, you will have to use MATLAB to parse the data and plot it.

Claire McV
Claire McV 2019년 12월 19일
Yes, it is numeric, here's a sample of the exported data: {"created_at":"2019-12-19T10:50:29Z","entry_id":376,"field2":"{'y': 0.06191210821270943, 'x': 0.020850349217653275, 'z': 0.9745436906814575}"},{"created_at":"2019-12-19T10:50:44Z","entry_id":377,"field2":"{'y': -0.0016885813092812896, 'x': 0.021820131689310074, 'z': 0.9686949253082275}"}]}
  댓글 수: 1
Vinod
Vinod 2019년 12월 19일
Looks like the data sent to thingspeak is not numeric, but a JSON object.
"field2" is being set to (literally) "{'y': 0.06191210821270943, 'x': 0.020850349217653275, 'z': 0.9745436906814575}"
You can do one of two things:
1) Use MATLAB to unpack the XYZ values that are encoded as JSON, unpack the data and plot it
2) Modify the code on the device to send 'x', 'y' and 'z' values to 3 different fields on the channel and use built in plotting.

댓글을 달려면 로그인하십시오.


Claire McV
Claire McV 2019년 12월 20일
Thank you so much, and sorry for the confusion. I am a complete novice at this, which option would be the easiest and most straightforward, in your opinion? Any tips would be much appreciated.
Many thanks
Claire
  댓글 수: 1
Vinod
Vinod 2019년 12월 24일
I'd say since you already have the data coming in, using MATLAB to extract the data would be the easiest way to do what you need. Check out the thingSpeakRead function and the jsondecode functions in MATLAB that you can use in your MATLAB visualization app on ThingSpeak.

댓글을 달려면 로그인하십시오.

커뮤니티

더 많은 답변 보기:  ThingSpeak 커뮤니티

카테고리

Help CenterFile Exchange에서 Run on Target Hardware에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by