수행기록퀘스트3

Pico W - Thingspeak 클라우드 연결 및 BNO055 9축 센서 데이터 업로드
2022. 9. 11 (일) 13:24 최종수정 2022. 9. 11 (일) 13:26 nexp 조회 488 좋아요 1 스크랩 2 댓글 0

Pico W - Thingspeak 클라우드 연결 및 BNO055 9축 센서 데이터 업로드

 

지난번 설정한 클라우드 접속

https://thingspeak.com/channels/1843421/private_show

 

 

사용할 센서(BNO055)의 X, Y, Z 축 센서 데이터 필드 생성

Channel ID 확인

 

 

API 키확인

 

 

 

 

ThingsSpeak 관련 라이브러리 설치

 

 

센서(BNO055) 관련 라이브러리 설치

 

코드 작성

초기화 코드

	//ThingSpeak Channel ID설정
	unsigned long myChannelNumber = 1843421;
	
	//ThingSpeak APIKey 설정
	const char * myWriteAPIKey = "53ANQ*****";



	// Initialize ThingSpeak
	ThingSpeak.begin(client);  

 

데이터 전송 코드

	sensors_event_t event;
	bno.getEvent(&event);
  
	Serial.print(F("Orientation: "));
	Serial.print((float)event.orientation.x);
	Serial.print(F(" "));
	Serial.print((float)event.orientation.y);
	Serial.print(F(" "));
	Serial.print((float)event.orientation.z);
	Serial.println(F(""));
  
	if(filed==1)data=event.orientation.x;
	else if(filed==2)data=event.orientation.y;
	else if(filed==3)
	{
		data=event.orientation.z;
		filed=1;
	}
	
	//ThingSpeak로 데이터 전송
	int x = ThingSpeak.writeField(myChannelNumber, filed, data, myWriteAPIKey);
	
	filed++;

 

 

테스트 결과

로그인 후
참가 상태를 확인할 수 있습니다.