2019物联网开发者大会 12.06 北京北辰洲际酒店→ 报名参会 ←
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » Arduino Uno 连接JY-61陀螺仪模块 串口读取数据

共3条 1/1 1 跳转至

Arduino Uno 连接JY-61陀螺仪模块 串口读取数据

菜鸟
2019-08-07 16:23:42    评分

最近偶然得到一块维特智能的JY-61的陀螺仪模块,

其功能是,直接输出MPU6050经卡尔曼滤波等算法得出的角度,角加速度数据

省下很多功夫,但我对其算法更感兴趣


自己焊接的底板,手艺还有待提升

本示例演示的是串口方式读取数据,还有IIC连接,以后有机会再分享

实验效果


BOM

Arduino Uno  *1

JY-61    *1(含邮票底板)

跳线若干


接线方式

Arduino UNO    ---      JY-61

5V                     <--->     VCC

GND                <--->      GND

0(RX)               <--->      TX


程序

需要用到JY901的库,找到JY901.ZIP


http://pan.baidu.com/s/1i50UmxB


把库文件夹存放在Arduino 安装目录的libraries库文件夹


程序&库打包下载:https://u16460183.ctfile.com/fs/16460183-296053314


文件夹说明:


JY901 —— JY901陀螺仪库


LS_JY901 —— 主程序



#include <Wire.h>

#include <JY901.h>

/*

Test on Uno R3.

JY901   UnoR3

TX <---> 0(Rx)

*/

void setup() 

{

  Serial.begin(115200);

}

 

void loop() 

{

  //print received data. Data was received in serialEvent;

  Serial.print("Time:20");Serial.print(JY901.stcTime.ucYear);Serial.print("-");Serial.print(JY901.stcTime.ucMonth);Serial.print("-");Serial.print(JY901.stcTime.ucDay);

  Serial.print(" ");Serial.print(JY901.stcTime.ucHour);Serial.print(":");Serial.print(JY901.stcTime.ucMinute);Serial.print(":");Serial.println((float)JY901.stcTime.ucSecond+(float)JY901.stcTime.usMiliSecond/1000);

               

  Serial.print("Acc:");Serial.print((float)JY901.stcAcc.a[0]/32768*16);Serial.print(" ");Serial.print((float)JY901.stcAcc.a[1]/32768*16);Serial.print(" ");Serial.println((float)JY901.stcAcc.a[2]/32768*16);

  

  Serial.print("Gyro:");Serial.print((float)JY901.stcGyro.w[0]/32768*2000);Serial.print(" ");Serial.print((float)JY901.stcGyro.w[1]/32768*2000);Serial.print(" ");Serial.println((float)JY901.stcGyro.w[2]/32768*2000);

  

  Serial.print("Angle:");Serial.print((float)JY901.stcAngle.Angle[0]/32768*180);Serial.print(" ");Serial.print((float)JY901.stcAngle.Angle[1]/32768*180);Serial.print(" ");Serial.println((float)JY901.stcAngle.Angle[2]/32768*180);

  

  Serial.print("Mag:");Serial.print(JY901.stcMag.h[0]);Serial.print(" ");Serial.print(JY901.stcMag.h[1]);Serial.print(" ");Serial.println(JY901.stcMag.h[2]);

  

  Serial.print("Pressure:");Serial.print(JY901.stcPress.lPressure);Serial.print(" ");Serial.println((float)JY901.stcPress.lAltitude/100);

  

  Serial.print("DStatus:");Serial.print(JY901.stcDStatus.sDStatus[0]);Serial.print(" ");Serial.print(JY901.stcDStatus.sDStatus[1]);Serial.print(" ");Serial.print(JY901.stcDStatus.sDStatus[2]);Serial.print(" ");Serial.println(JY901.stcDStatus.sDStatus[3]);

  

  Serial.print("Longitude:");Serial.print(JY901.stcLonLat.lLon/10000000);Serial.print("Deg");Serial.print((double)(JY901.stcLonLat.lLon % 10000000)/1e5);Serial.print("m Lattitude:");

  Serial.print(JY901.stcLonLat.lLat/10000000);Serial.print("Deg");Serial.print((double)(JY901.stcLonLat.lLat % 10000000)/1e5);Serial.println("m");

  

  Serial.print("GPSHeight:");Serial.print((float)JY901.stcGPSV.sGPSHeight/10);Serial.print("m GPSYaw:");Serial.print((float)JY901.stcGPSV.sGPSYaw/10);Serial.print("Deg GPSV:");Serial.print((float)JY901.stcGPSV.lGPSVelocity/1000);Serial.println("km/h");

  

  Serial.println("");

  delay(500);

}

 

/*

  SerialEvent occurs whenever a new data comes in the

 hardware serial RX.  This routine is run between each

 time loop() runs, so using delay inside loop can delay

 response.  Multiple bytes of data may be available.

 */

void serialEvent() 

{

  while (Serial.available()) 

  {

    JY901.CopeSerialData(Serial.read()); //Call JY901 data cope function

  }

}





关键词: Arduino     JY-61     串口     陀螺     模块    

菜鸟
2019-08-07 21:21:20    评分
2楼

有点杂乱


助工
2019-08-08 14:09:32    评分
3楼

还行


共3条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]