CH-201 work with arduino?

By avatarrafaelgmailcom , 28 October 2020

I recently purchased a few CH-201 sensors in hopes of getting it to work with a prototype I am developing. My prototype currently uses an arduino to power it. My question is if there is any way I can the arduino and CH-201 chip to communicate.

Thanks!

rachelgleesond…

5 years 1 month ago

Hello!

It's definitely possible. I have it working with my Arduino Nano. Of course, you'll have to make sure you're wiring it up correctly and using a 3.3-1.8V regulator and I2C Logic Level converter.

You need to modify the existing hello chirp software to run on your Arduino chipset. For example, with the Arduino Nano 33 BLE, you'll need to know how to set up the timer registers for the Nordic chipset. Luckily, Arduino simplifies a lot of the register reading/writing processes, so you can trim A LOT of the C code.

One other thing, the Uno doesn't have enough on board memory to run the Hello Chirp firmware. That's why I upgraded to the Nano 33 BLE.

Good luck!

phpbb Post ID
38846

xyoxayahoode

5 years ago

Hello!

I'm currently trying to get an ESP32 or Arduino to communicate with the CH-101. I'm at the point where I got the Hello Chirp example to compile in Visual Studio Code with PlatformIO. But now I'm pretty helpless because I can't figure out what to change to get it to work with the ESP/Arduino. Where do I specify the Pins, Timers, etc?

I was also thinking of starting from scratch and communicate over I2C and directly access the registers. But I can't find anything about the register addresses in any datasheet?

Is there any chance that you share your working code with me? I would really appreciate it. By now, you're the only one who says they got it working with an Arduino as there are no tutorials at all.

Lukas

phpbb Post ID
38857

jerrydashbikede

5 years ago

Hey!

So I'm in the same pickle as the person above. I'm using an ESP32 and CH201. I understand that I have to modify "chirp_bsp" to suit my ESP32 but have no idea where to start. Any help on how to do this/get the CH201 working with Arduino would be greatly appreciated.

Thanks in advance,
Jerry

phpbb Post ID
38861

xyoxayahoode

4 years 11 months ago

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.
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 (I shortended it, because the part in the middle gets tried 5 times):

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

phpbb Post ID
38925

fedimaknivacan…

4 years ago

Hello,
I stayed the past 2 weeks checking how to connect CH101 to esp32 using arduino ide, could you please share your progress if it is possible? Thank you in advance for your cooperation

phpbb Post ID
39356

yassineahaggac…

4 years ago

Hi everyone,

@Lukas if you are kind enough to share your work on github I can join in the development and not start from scratch.
I'd actually like to us the CH-101 with ESP32 but for the sake of progress, I ended up designing a small ARM based board to quickly deploy the library.
In case you are willing to start a repo, I would happily pitch in and start development with you.

Let me know
Bests

phpbb Post ID
39412

vitorpaixaorum…

3 years 4 months ago

Hello!

@Lukas and @shirogeek , have you solved the problem?
Could you share the solution?

Thank you in advance.

phpbb Post ID
39580

madhavlohargmailcom

3 years 4 months ago

Hello!

I’m in the same condition of where to start development for interfacing CH201 with STM32xx Arduino.
I tried to get CH201's detailed documents for developing interface but nothing is available.

Can any one please share process/steps to develop Arduino application for CH201.

Thanks in advance,

-Madhav

phpbb Post ID
39594
phpbb Topic ID
38702