Serial 6-axis accelerometer wont change sampling frequency

userHead 991cw 2025-07-11 02:49:45 880 Views4 Replies

I have been using this code from the website but any tinme i try to change the sampling frequency it does not change. It is always stuck at 10Hz. I have tried send it the raw code but it still wont work. I have set it up exactly like the guide says to. Is there something obvious that I am missing from my code below.
/*!
* @file getData.ino
* @brief Set the frequency of data output by the sensor, read the acceleration, 
* @n angular velocity, and angle of X, Y, and Z axes.
* @n Experimental phenomenon: when the sensor starts, it outputs data at the set 
* @n frequency and the data will be displayed on serial monitor.
* @copyright Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
* @license The MIT License (MIT)
* @author [huyujie]([email protected])
* @version V1.0
* @date 2023-07-12
* @url https://github.com/DFRobot/DFRobot_WT61PC
*/
#include <DFRobot_WT61PC.h>


#if (defined(ARDUINO_AVR_UNO) || defined(ESP8266))   // Using a soft serial port
#include <SoftwareSerial.h>
SoftwareSerial softSerial(/*rx =*/10, /*tx =*/11);
#define FPSerial softSerial
#else
#define FPSerial Serial1
#endif

DFRobot_WT61PC sensor(&FPSerial);

void setup()
{
 //Use Serial as debugging serial port 
 Serial.begin(115200);

#if (defined ESP32)
 FPSerial.begin(9600, SERIAL_8N1, /*rx =*/D3, /*tx =*/D2);
#else
 FPSerial.begin(9600);
#endif


void loop()
{
 if (sensor.available()) {
   Serial.print("Acc\t"); Serial.print(sensor.Acc.X); Serial.print("\t");
   Serial.print(sensor.Acc.Y); Serial.print("\t"); Serial.println(sensor.Acc.Z); //acceleration information of X,Y,Z
   Serial.print("Gyro\t"); Serial.print(sensor.Gyro.X); Serial.print("\t");
   Serial.print(sensor.Gyro.Y); Serial.print("\t"); Serial.println(sensor.Gyro.Z); //angular velocity information of X,Y,Z
   Serial.print("Angle\t"); Serial.print(sensor.Angle.X); Serial.print("\t");
   Serial.print(sensor.Angle.Y); Serial.print("\t"); Serial.println(sensor.Angle.Z); //angle information of X, Y, Z 
   Serial.println();
 }
}

 

2026-01-06 19:08:41

I'M Rosley Rodrigues Are you aware that you could be scammed while trying to invest into crypto? If you know this then you will have to do a thorough search before investing your funds into any platform. Crypto Recovery Scam: Desperation has been the major key used by scammers to get into victims, CRYPTO RECOVERY is real but not legal. What is real and not legal has procedures and one can likely fall into imposter hands and end up being scammed, so many reviews about crypto recovery have been posted by scammers who derive joy in seeing their fellow humans in tears. I will solemnly advise everyone to stop searching for crypto recovery agent in a wrong way, they are now so many search words on the internet being used by both real and fake, so therefor a new methods was introduced to connect with a real recovery agent which i myself writing this article has experience it magnificent excellent recovery work well done by SMITH WHITE HACK SERVICE crypto recovery/other’s General hack service. SMITH WHITE HACK SERVICE and his team are a great set of hackers team with verified profiles and they have been helpful in resolving scam issues simply with their technology tools and p2p forum union with crypto block, makes it much easier for them to carry out crypto scam funds recovery. My total scammed funds was $4.875,000 canadian dollar’s and I received $3.255 USD, converting that to Canadian dollar’s was greatly profitable and I had no regret for clearing out all the scammer wallet funds with the help of.
( [email protected] )
 

userHeadPic Rosley
2025-12-29 08:03:18

Has this been resolved? I recently purchased the SEN0386 6-axis. I think I am having the same issue. It appears to stuck at 10Hz output frequency. I am using the example code from dfrobot. The reason I think it is stuck at 10Hz is because my loop time is very close to .100 seconds. The line of code that is causing the .100s delay is:

 

if (sensor.available()) {

 

Please advise,

Thanks

userHeadPic Johnsinski.69
2025-07-11 18:58:25

Add a call to sensor.setOutputFreq(<desired_frequency>) in your setup() function. For example, to set it to 100 Hz, do this:

void setup()
{
 // Debug serial
 Serial.begin(115200);

#if (defined ESP32)
 FPSerial.begin(9600, SERIAL_8N1, /*rx =*/D3, /*tx =*/D2);
#else
 FPSerial.begin(9600);
#endif

 // Wait for sensor to initialize
 delay(1000);

 // Initialize sensor
 sensor.begin();

 // Set data output frequency (possible values: 0x01 (1Hz), 0x02 (2Hz), ..., 0x63 (100Hz))
 sensor.setOutputFreq(100);  // Set to 100 Hz, change as needed
}
 

userHeadPic ahsrab.rifat
2025-07-11 03:02:41

Here is the command i use for changing the frequency. i put it at the end of the void setup(). Here is the line: sensor.modifyFrequency(FREQUENCY_100HZ)

userHeadPic 991cw