CH101 sensor not giving different distance values

Hi All,
I am working with ch101 sensor along with arduino uno which is giving only one value i.e.,2562.0 as distance irrespective of object at different positions but my concern is to get different positional values of ch101 sensor.
I would request everyone to support me and modify the code to get different values for the below code:
#include <Wire.h>

#define Chirp_ADDR 0x45 // or I used 0x45
//there was not any mention of register address in chirp's data sheet. so I just used 0
#define Chirp_REG_TMEP 0
#define ANSWERSIZE 2 // I used 2 byte arbitrarily

int rstPin = 13;
int progPin = 12;
int intPin = 11;

void setup()
{
Wire.begin();
Serial.begin(115200);
// Serial.println("\nI2C Scanner");
pinMode(rstPin, OUTPUT);
pinMode(progPin, OUTPUT);
pinMode(intPin, INPUT_PULLUP);
//-----------------------------
digitalWrite(rstPin, LOW); //rset the device
delay(200);
digitalWrite(rstPin, HIGH);
//-------------------------
digitalWrite(progPin, LOW); //don't know the what value for progPin?

}

void loop() {

float distance = GetDistance();
Serial.print("distance : ");
Serial.print(distance, 2);
Serial.println();
delay(1000);

}

float GetDistance()
{
Wire.beginTransmission(Chirp_ADDR);
Wire.write(Chirp_REG_TMEP);
Wire.endTransmission();

Wire.requestFrom(Chirp_ADDR, ANSWERSIZE);
byte firstByte = Wire.read();
byte secondByte = Wire.read();
int sumByte = ((int)firstByte << 8) | (int)secondByte;
float distanceValue = (float) sumByte;
return distanceValue;
}
Thanks and regards,
Imran Pathan.

  • What ch101 module are you using?
  • What arduino board are you using?
  • Are both voltage level compatible?

The sensor itself works with 1.8V supply voltage, is the module board you are using providing the necessary voltage level translation ( and are you powering the module at the right voltage )?

P.S.
Start by testing the example in the tdk library

Please edit your post, select all code and click the <CODE/> button; next save your post. This will apply cocde tags around your code which makes the code easier to read and easier to copy; it also makes sure that the forum software displays it correctly.

Iam using ch101 ultrasonic sensor module and Arduino Uno and mega boards which are voltage compatible.

i have tried to test the example in the tdk library but the code size is not compatible with arduino uno and mega boards and throwing an error as data size exceeds the memory size.

The mega compiles correctly the RawData example on the mega:

Sketch uses 24318 bytes (9%) of program storage space. Maximum is 253952 bytes.
Global variables use 3312 bytes (40%) of dynamic memory, leaving 4880 bytes for local variables. Maximum is 8192 bytes.

For the connection follow the instructions on the example and on the github site.

Also which module are you using?
I understand is a ch101, but which board ( the adafruit one which is not available any more ) have you a link to the board?

Iam using TDK-invensense CH101 sensor with our own customized board.