Hello everyone,
I am pretty new at this, and I could really use your help. I have hooked up a 4 wire(Tx, Rx, Gnd, Vcc), IMU unit to my teensy 3.5, and using the IMU's library and Serial1 I try to stream the data onto the serial monitor. The problem is that when I start serial monitor, all i see is zeros, but as soon as I send anything in the serial monitor it starts showing me the values and its very responsive from there on. I don't know why this happens. I did also try this on an arduino Mega with it's hardware serial port and it did the same thing. But when I wired it to the shared serial port, this was not an issue. I have attached the code and the library below as well as the link to the IMU unit on amazon. The code below is a slightly simplified version of the example in the library. Thanks in advance!
This is a Chinese made IMU, model: WTGAHRS2
Link: https://www.amazon.ca/gp/product/B072ZZ83JZ/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1
I am pretty new at this, and I could really use your help. I have hooked up a 4 wire(Tx, Rx, Gnd, Vcc), IMU unit to my teensy 3.5, and using the IMU's library and Serial1 I try to stream the data onto the serial monitor. The problem is that when I start serial monitor, all i see is zeros, but as soon as I send anything in the serial monitor it starts showing me the values and its very responsive from there on. I don't know why this happens. I did also try this on an arduino Mega with it's hardware serial port and it did the same thing. But when I wired it to the shared serial port, this was not an issue. I have attached the code and the library below as well as the link to the IMU unit on amazon. The code below is a slightly simplified version of the example in the library. Thanks in advance!
This is a Chinese made IMU, model: WTGAHRS2
Link: https://www.amazon.ca/gp/product/B072ZZ83JZ/ref=ppx_yo_dt_b_asin_title_o01_s00?ie=UTF8&psc=1
Code:
#include <JY901.h>
void serialEvent() {
while (Serial1.available())
{
JY901.CopeSerialData(Serial1.read()); //Call JY901 data cope function
}
};
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
}
void loop()
{
//print received data. Data was received in serialEvent;
Serial.print((float)JY901.stcGyro.w[0]/32768*2000);
Serial.print(",");
Serial.print((float)JY901.stcGyro.w[1]/32768*2000);
Serial.print(",");
Serial.print((float)JY901.stcGyro.w[2]/32768*2000);
Serial.print(",");
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);
// delay(100);
}
/*
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.
*/