WT901

Helli,

I would like to use a WT901 sensor board as a compass and inclinometer.
The board works itself if I connect it to it's PC application.

But I have problem with the arduino code provided by the manufacturer.
I downloaded to an arduino uno and then to a nano board but it does not write any serial data.

/*
This code is used for connecting arduino to serial mpu6050 module, and test in arduino uno R3 board.
connect map:
arduino   mpu6050 module
VCC    5v/3.3v
TX     RX<-0
TX     TX->1
GND    GND
note: 
because arduino download and mpu6050 are using the same serial port, you need to un-connect 6050 module when you want to download program to arduino.
 Created 14 Nov 2013
 by Zhaowen
 
 serial mpu6050 module can be found in the link below:
 http://item.taobao.com/item.htm?id=19785706431
 */

unsigned char Re_buf[11],counter=0;
unsigned char sign=0;
float a[3],w[3],angle[3],T;
void setup() {
  // initialize serial:
  Serial.begin(115200);
}

void loop() {
  if(sign)
  {  
     sign=0;
     if(Re_buf[0]==0x55)      //检查帧头
     {  
  switch(Re_buf [1])
  {
  case 0x51:
    a[0] = (short(Re_buf [3]<<8| Re_buf [2]))/32768.0*16;
    a[1] = (short(Re_buf [5]<<8| Re_buf [4]))/32768.0*16;
    a[2] = (short(Re_buf [7]<<8| Re_buf [6]))/32768.0*16;
    T = (short(Re_buf [9]<<8| Re_buf [8]))/340.0+36.25;
    break;
  case 0x52:
    w[0] = (short(Re_buf [3]<<8| Re_buf [2]))/32768.0*2000;
    w[1] = (short(Re_buf [5]<<8| Re_buf [4]))/32768.0*2000;
    w[2] = (short(Re_buf [7]<<8| Re_buf [6]))/32768.0*2000;
    T = (short(Re_buf [9]<<8| Re_buf [8]))/340.0+36.25;
    break;
  case 0x53:
          angle[0] = (short(Re_buf [3]<<8| Re_buf [2]))/32768.0*180;
    angle[1] = (short(Re_buf [5]<<8| Re_buf [4]))/32768.0*180;
    angle[2] = (short(Re_buf [7]<<8| Re_buf [6]))/32768.0*180;
    T = (short(Re_buf [9]<<8| Re_buf [8]))/340.0+36.25;
                Serial.print("a:");
                Serial.print(a[0]);Serial.print(" ");
                Serial.print(a[1]);Serial.print(" ");
                Serial.print(a[2]);Serial.print(" ");
                Serial.print("w:");
                Serial.print(w[0]);Serial.print(" ");
                Serial.print(w[1]);Serial.print(" ");
                Serial.print(a[2]);Serial.print(" ");
                Serial.print("angle:");
                Serial.print(angle[0]);Serial.print(" ");
                Serial.print(angle[1]);Serial.print(" ");
                Serial.print(angle[2]);Serial.print(" ");
                Serial.print("T:");
                Serial.println(T);
                break;
  } 
    }
  } 
}

void serialEvent() {
  while (Serial.available()) {
    
    //char inChar = (char)Serial.read(); Serial.print(inChar); //Output Original Data, use this code 
  
    Re_buf[counter]=(unsigned char)Serial.read();
    if(counter==0&&Re_buf[0]!=0x55) return;      //第0号数据不是帧头              
    counter++;       
    if(counter==11)             //接收到11个数据
    {    
       counter=0;               //重新赋值,准备下一帧数据的接收 
       sign=1;
    }
      
  }
}

The adatasheet can be found here:
https://drive.google.com/file/d/1sW7J7t_lliwtaLG1zajVMYruAreQnNxg/view

What is wrong with the code?

The WT901 module has 3.3V only input/output pins (data sheet here). You need 5V to 3.3V level converters for the serial connection, or use a 3.3V Arduino.

If you connected it directly to a 5V Arduino, the module may have been destroyed .

jremington:
The WT901 module has 3.3V only input/output pins (data sheet here). You need 5V to 3.3V level converters for the serial connection, or use a 3.3V Arduino.

If you connected it directly to a 5V Arduino, the module may have been destroyed .

According to the datasheet the input voltage is 3.3-5 V (see page 5)

If I connect it to my PC with this adapter:
https://www.aliexpress.com/item/32873159970.html?spm=a2g0s.9042311.0.0.27424c4didgJrW

It works without any problem.

That is the power supply voltage, not the I/O voltage. The module has a 5V to 3.3V regulator.

Edit:

Your CH340G USB to TTL adapter is most likely using 3.3V I/O, but the documentation is not clear on the point. If the sensor has survived, these 3.3V Pro Minis are perfect for the interface task.

I got a new code from the manufacturer.
Somebody might also need it.

It seems to be working.

Instructions for connecting sensor to Arduino.pdf (907 KB)

1 Like

Sample code

901-Arduino.zip (122 KB)

1 Like