TDK CH101 integration with ESP32

Hello,

I have been trying to read out the CH101 ultrasonic sensor with the ESP32 board for over a month now.
Unfortunately, I have not yet found a solution.
The I2C connection has already been established.
Does anyone know the CH101 sensor from TDK and can help me?

Thank you in advance.

Best regards
nimo1012

nimo1012:
The I2C connection has already been established.

Are you sure? How did you make sure of that?
Post your code.

Nothing here GitHub - sparkfunX/Qwiic_Chirp_101_Ultrasonic_Rangefinder: Qwiic breakout for the MOD_CH101 ultrasonic time-of-flight module was of help?

What does the sensor address show after running the I2C scanner program?

Hello,

I used an I2C scanner program to make sure, that the I2C connection has been established.
As result I recieved two I2C addresses: 0x45 and 0x29
Like descriped in the documentation, 0x45 is the programming address and 0x29 is the application address.

Best regards
nimo1012

Hey togehter,

I’ve been working in the last couple of weeks on getting the TDK CH101 ultrasonic sensor to communicate with the ESP32.
I’m using the Qwiic board from SparkFun. I took the HelloChirp example and wrote my own board support package. Now I got it to the point where everything compiles, the board gets initialized correctly according to the description, and the ESP flashes the whole firmware to the CH101 via I2C successfully. Or at least it says so. Because one part of the initialization process is to give the CH101 a new I2C address, but when it later checks if the address is reachable, it gets a not-acknowledged back.

I already tried the following:
• With and without pull-up resistors for SDA and SCL
• Different pins for SDA and SCL
• Reducing the clock frequency to 10kHz to give enough time for clock stretching
• Different level converter board and different sensor
• With and without debug messages

Does anybody have an idea where the problem lies? I assume it’s somewhere in I2C_write, I2C_mem_write, I2C_read, I2C_mem_read.
Attached you find the board support functions. Here you can download the whole project: Google Drive

I’m pretty confused because it says that everything gets flashed successfully but the sensor is then not reachable.
This is the output I get: (next post)

Chbsp_espressif_esp32.cpp (50.5 KB)

Log:

chbsp_board_init
Device 0: found
Initializing sensor(s)... chbsp_i2c_get_info
starting group... chbsp_group_pin_init
// 5 times starting here:
chbsp_reset_assert
chbsp_program_enable
chbsp_delay_ms: 1ms
chbsp_reset_release
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x85, data[1]: 0xFC, data[2]: 0xFF -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x87, data[1]: 0x3, data[2]: 0x0 -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC4, data[1]: 0xB -> Succesfull
chbsp_i2c_write this many bytes: 4 to adress: 0x45, data[0]: 0x3, data[1]: 0x40, data[2]: 0xFC, data[3]: 0xFF -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC2, data[1]: 0x40 -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC2, data[1]: 0x11 -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x85, data[1]: 0x20, data[2]: 0x1 -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x86, data[1]: 0x80, data[2]: 0x5A -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC4, data[1]: 0x3 -> Succesfull
chbsp_program_disable
chbsp_program_enable
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC2, data[1]: 0x40 -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC2, data[1]: 0x11 -> Succesfull
chbsp_i2c_write this many bytes: 1 to adress: 0x45, data[0]: 0x0 -> Succesfull
chbsp_i2c_read this many bytes: 2 from address: 0x45 | Response: received 2 bytes:  data[0]: 0xA data[1]: 0x2
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x85, data[1]: 0x48, data[2]: 0x7 -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x87, data[1]: 0xF, data[2]: 0x0 -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC4, data[1]: 0xB -> Succesfull
chbsp_i2c_write this many bytes: 16 to adress: 0x45, data[0]: 0x6, data[1]: 0x0, data[2]: 0x0, data[3]: 0x0, data[4]: 0x0, data[5]: 0xFA, data[6]: 0x0, data[7]: 0x0, data[8]: 0x64, data[9]: 0x0, data[10]: 0x0, data[11]: 0xC, 
data[12]: 0x0, data[13]: 0x0, data[14]: 0x1, data[15]: 0x0 -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x85, data[1]: 0x0, data[2]: 0xF8 -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x87, data[1]: 0xFF, data[2]: 0x7 -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC4, data[1]: 0xB -> Succesfull
chbsp_i2c_write this many bytes: 2048 to adress: 0x45, data[0]: 0xA, data[1]: 0x12, data[2]: 0x9, data[3]: 0x12, data[4]: 0x8, data[5]: 0x12, data[6]: 0x7, data[7]: 0x12, data[8]: 0x6, data[9]: 0x12, data[10]: 0x5, data[11]: 
0x12, data[12]: 0x4, data[13]: 0x12, data[14]: 0x31, data[15]: 0x80, data[16]: 0x10, data[17]: 0x0, data[18]: 0x81, data[19]: 0x4D, data[20]: 0x2, data[21]: 0x0, data[22]: 0xC2, data[23]: 0x43, data[24]: 0x3E, data[25]: 0x7, 
data[26]: 0x6, data[27]: 0x43, data[28]: 0x4, data[29]: 0x43, data[30]: 0x81, data[31]: 0x43, data[32]: 0x8, data[33]: 0x0, data[34]: 0xA, data[35]: 0x43, data[36]: 0xC, data[37]: 0x93, data[38]: 0xB0, data[39]: 0x24, data[40]: 0x81, data[41]: 0x4C, data[42]: 0xA, data[43]: 0x0, data[44]: 0x7, data[45]: 0x43, data[46]: 0x8, data[47]: 0x47, data[48]: 0x35, data[49]: 0x40, data[50]: 0xDC, data[51]: 0x5, data[52]: 0xC, data[53]: 0x43, data[54]: 0x1F, data[55]: 0x41, data[56]: 0x2, data[57]: 0x0, data[58]: 0x4F, data[59]: 0x93, data[60]: 0x16, data[61]: 0x20, data[62]: 0x38, data[63]: 0x90, data[64]: 0x2C, data[65]: 0x0, data[66]: 0x1C, data[67]: 0x2C, data[68]: 0xF2, data[69]: 0x90, data[70]: 0x20, data[71]: 0x0, data[72]: 0x1, data[73]: 0x2, data[74]: 0x18, data[75]: 0x24, data[76]: 0xF, data[77]: 0x48, data[78]: 0xF, data[79]: 0x5C, data[80]: 0xF, data[81]: 0x5F, data[82]: 0x3E, data[83]: 0x40, data[84]: 0x1C, data[85]: 0x2, data[86]: 0xE, data[87]: 0x5F, data[88]: 0x2B, data[89]: 0x4E, data[90]: 0x3D, data[91]: 0x40, data[92]: 0xCC, data[93]: 0x6, data[94]: 0xD, data[95]: 0x5F, data[96]: 0xAE, data[97]: 0x8D, data[98]: 0x0, data[99]: 0x0, data[100]: 0x8D, data[101]: 0x4B -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC2, data[1]: 0x40 -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC2, data[1]: 0x11 -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x85, data[1]: 0xC5, data[2]: 0x1 -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x86, data[1]: 0x2D, data[2]: 0x2D -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC4, data[1]: 0xB -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x85, data[1]: 0xA6, data[2]: 0x1 -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x86, data[1]: 0x0, data[2]: 0x2 -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC4, data[1]: 0x3 -> Succesfull
chbsp_delay_ms: 5ms
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x85, data[1]: 0xA6, data[2]: 0x1 -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x86, data[1]: 0x0, data[2]: 0x6 -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC4, data[1]: 0x3 -> Succesfull
chbsp_delay_ms: 5ms
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x85, data[1]: 0xA6, data[2]: 0x1 -> Succesfull
chbsp_i2c_write this many bytes: 3 to adress: 0x45, data[0]: 0x86, data[1]: 0x0, data[2]: 0x0 -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC4, data[1]: 0x3 -> Succesfull
chbsp_i2c_write this many bytes: 2 to adress: 0x45, data[0]: 0xC2, data[1]: 0x2 -> Succesfull
chbsp_program_disable
chbsp_timestamp_ms
chbsp_i2c_mem_read this many bytes: 1 from adress: 0x2D, at mem adress: 0x14 transmission -> succesfull | Response: received 0 data: did not receive enough bytes.
chbsp_delay_ms: 10ms
chbsp_timestamp_ms
chbsp_i2c_mem_read this many bytes: 1 from adress: 0x2D, at mem adress: 0x14 transmission -> succesfull | Response: received 0 data: did not receive enough bytes.
chbsp_delay_ms: 10ms
chbsp_timestamp_ms
chbsp_i2c_mem_read this many bytes: 1 from adress: 0x2D, at mem adress: 0x14 transmission -> succesfull | Response: received 0 data: did not receive enough bytes.
chbsp_delay_ms: 10ms
chbsp_timestamp_ms
chbsp_i2c_mem_read this many bytes: 1 from adress: 0x2D, at mem adress: 0x14 transmission -> succesfull | Response: received 0 data: did not receive enough bytes.
chbsp_delay_ms: 10ms
chbsp_timestamp_ms
chbsp_i2c_mem_read this many bytes: 1 from adress: 0x2D, at mem adress: 0x14 transmission -> succesfull | Response: received 0 data: did not receive enough bytes.
chbsp_delay_ms: 10ms
chbsp_timestamp_ms
// Until here
FAILED: 1

// Extra I2C Scanner for checking reachable addresses
I2C scanner. Scanning ...
Found address: 41 (0x29)
Found 1 device(s).
// ------------------------

Sensor  Type       Freq                  RTC Cal                Firmware
0       CH101    0 Hz                   0@100ms                 gpr_open_gpr-101_v40a

Configuring sensor(s)...
Setting config...
chbsp_i2c_mem_write this many bytes: 2 to adress: 0x2D, at mem adress: 0x01, data[0]: 0x1, data[1]: 0x2 -> received NACK on transmit of address.
chbsp_i2c_mem_read this many bytes: 2 from adress: 0x2D, at mem adress: 0x16 transmission -> succesfull | Response: received 0 data: did not receive enough bytes.
chbsp_i2c_mem_write this many bytes: 2 to adress: 0x2D, at mem adress: 0x07, data[0]: 0x1, data[1]: 0x0 -> received NACK on transmit of address.
Device 0: Error during ch_set_config()

Starting measurements

Hello,
Has anyone figured out how to get the readings from the sensor successfully ?

Last week I bought the CH101 sensor and I have been trying to get it to work with an ESP32 with no results ever since. Also I couldn't find any helpful documentation besides the programming guide provided by the manufacturer.

I tried the .cpp file but looks like ch_dev_t and ch_group_t structs have functions that need to be ported. Have you done this already? The Google drive link is not working. So I am not able to see the rest of your code or try it out.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.