# I2C does not send read datagram when Wire.requestFrom(...) is called

**URL:** https://forum.amebaiot.com/t/i2c-does-not-send-read-datagram-when-wire-requestfrom-is-called/3585
**Category:** Peripherals
**Tags:** rtl8735b, evb-amb82
**Created:** [December 1, 2024, 3:49pm UTC](https://forum.amebaiot.com/t/i2c-does-not-send-read-datagram-when-wire-requestfrom-is-called/3585 "2024-12-01T15:49:35Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![electry](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/electry/32/2361_2.png) [@electry](https://forum.amebaiot.com/u/electry)
#### Post date: [December 1, 2024, 3:49pm UTC](https://forum.amebaiot.com/t/i2c-does-not-send-read-datagram-when-wire-requestfrom-is-called/3585/1 "2024-12-01T15:49:35Z")

</div>

Hi,

I have an issue with Arduino SDK I2C library and its reading capability. If I call the Wire.requestFrom(…) function correctly, it is executed without error, but the message datagram requesting byte/bytes does not appear on logic analyzer. The calling of the write function works as expected and logic analyser shows nice write-flagged datagram too. Details are described in GitHub issue below. After I created the issue, I tested it on older Arduino SDKs, but It was the same or it does not work at all on the oldest one.

I created issue on the github, without any reaction. Other issues there are mostly without reaction too and automatically closed because of no activity. This is bug I most probably can’t fix myself without knowledge of the hardware registers and their function. Sadly, I have no I2C device with read write capability to create small usable sample. But It should be easily replicable on other device too. I did not done anything special.

> <https://github.com/Ameba-AIoT/ameba-arduino-pro2/issues/282#issue-2692437101>
>
> \### Boards
> 
> AMB82-mini
> 
> \### External Hardware
> 
> Saleae Logic8 attached to p…in 12, pin 13 (I2C).
> 
> \### Hardware Configuration
> 
> satel-vl53l7cx modified to bypass onboard regulator, so SB1 short and SB2 open, then AVDD=IOVDD (sensor pin - AMB82-mini pin):
> \- SDA - pin 12
> \- SCL - pin 13
> \- GND - GND
> \- IOVDD - VDD33
> 
> (Note: fully functional and tested with a few STM32 boards, ESP32, and similar)
> 
> \### Version
> 
> v4.0.8
> 
> \### IDE Name
> 
> Arduino IDE 2.3.3
> 
> \### Operating System
> 
> WIndows 10, Windows 11, Ubuntu 22.04
> 
> \### Auto Flash Mode
> 
> Disable
> 
> \### Erase All Flash Memory (16MB)
> 
> Disable
> 
> \### Standard Lib
> 
> Arduino\_STD\_PRINTF
> 
> \### Upload Speed
> 
> 2000000
> 
> \### Description
> 
> When I checked If sensor initializes properly, I found, that I2C Write is OK but I2C Read writes only the address but never start read. The read part is totally missing. I do not have other I2C readable sensors that have simple code. So I will not provide code sample to reproduce, but it should be any read attempt.
> 
> !\[image\](https://github.com/user-attachments/assets/8aea8a2b-f59f-4b70-8130-4726fcfa0438)
> 
> 
> \### Sketch
> 
> \`\`\`cpp
> //code of functions I will use:
> 
> typedef struct
> {
> TwoWire \*port; //== &Wire
> uint16\_t address; //== 0x52
> } VL53L7CX\_Platform;
> 
> uint8\_t VL53L7CX\_RdByte(
> VL53L7CX\_Platform \*p\_platform,
> uint16\_t register\_address,
> uint8\_t \*p\_value)
> {
> uint8\_t status = 0;	
> p\_platform-\>port-\>beginTransmission(p\_platform-\>address\>\>1);
> p\_platform-\>port-\>write(highByte(register\_address));
> p\_platform-\>port-\>write(lowByte(register\_address));
> p\_platform-\>port-\>endTransmission();
> p\_platform-\>port-\>requestFrom(p\_platform-\>address\>\>1, 1U);
> \*p\_value = p\_platform-\>port-\>read();
> return status;
> }
> 
> uint8\_t VL53L7CX\_WrByte(
> VL53L7CX\_Platform \*p\_platform,
> uint16\_t register\_address,
> uint8\_t value)
> {
> uint8\_t status = 0;
> p\_platform-\>port-\>beginTransmission(p\_platform-\>address\>\>1);
> p\_platform-\>port-\>write(highByte(register\_address));
> p\_platform-\>port-\>write(lowByte(register\_address));
> p\_platform-\>port-\>write(value);
> status = p\_platform-\>port-\>endTransmission();
> return status;
> }
> 
> //Initialization send these messages:
> 
> ...
> /\* SW reboot sequence \*/
> status |= VL53L7CX\_WrByte(&(p\_dev-\>platform), 0x7fff, 0x00);
> status |= VL53L7CX\_WrByte(&(p\_dev-\>platform), 0x0009, 0x04);
> status |= VL53L7CX\_WrByte(&(p\_dev-\>platform), 0x000F, 0x40);
> status |= VL53L7CX\_WrByte(&(p\_dev-\>platform), 0x000A, 0x03);
> status |= VL53L7CX\_RdByte(&(p\_dev-\>platform), 0x7FFF, &tmp);
> status |= VL53L7CX\_WrByte(&(p\_dev-\>platform), 0x000C, 0x01);
> ...
> 
> //As seen on the logic analyzator image, there is Write(index,data) \[ADDR(W), 0x00, 0x01, 0x03\],
> //then Write(index)/Read(data) \[ADDR(W), 0x7F, 0xFF\] but missing Read(data) part which should be
> //\[ADDR+1(R), DATA\]. It continues with another Write(index, data) \[ADDR, 0x00, 0x0C, 0x01\].
> 
> //There is expected missing Read part where data is received from slave buffer.
> \`\`\`
> 
> 
> \### Error/Debug Message
> 
> \`\`\`plain
> 
> == Rtl8735b IoT Platform ==
> 
> \[Normal mode\]
> BootFromNORFlash
> \[Start Boot ROM...\]
> === Load PARTBL ===
> === Load Done ===
> === Load ISP\_IQ ===
> \[fcs chk pass\]
> ISP\_IQ @ 0x8461080, 0x14f80, 0x0
> mfcs\_data version 0x00010001
> fcs\_data version 0x00010101
> === Process ISP\_IQ ===
> === Load Done ===
> === Load BL ===
> \[Image Start Table @ 0x18200\]
> === Load Done ===
> 
> == Boot Loader ==
> Oct 24 2024:17:41:10
> === Load FCS Para ===
> === Load Done ===
> \[crc pass\]
> === Load ISP\_IQ Sensor ===
> ISP\_IQ @ 0x8461080, 0x14f80
> === Process ISP\_IQ ===
> === Load Done ===
> === Load FW1 ===
> \[Image Start Table @ 0x20106200\]
> RAM Load @ 0x8061100-\>0x20106200, 0x5d48
> DRAM\_TYPE is DDR2 128MB.
> ddr\_freq = 533
> DDR Load @ 0x8067080-\>0x70100000, 0x2c704
> === FW Load Done ===
> 
> Boot Loader \<==
> 
> == RAM Start ==
> Build @ 17:32:16, Oct 24 2024
> 
> $8735b\>
> Lidar Setup Start
> \`\`\`
> 
> 
> \### Reproduce remarks
> 
> \_No response\_
> 
> \### I have checked online documentation, FAQ, GitHub Wiki and existing/closed issues.
> 
> \- \[X\] I confirm I have checked online documentation, FAQ, GitHub Wiki and existing/closed issues.

Best regards,  
electry

---

<div class="post-metadata">

### Author: ![Kelvin\_Huang](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.amebaiot.com/kelvin_huang/32/2130_2.png) [@Kelvin\_Huang](https://forum.amebaiot.com/u/Kelvin_Huang)
#### Post date: [December 2, 2024, 1:35am UTC](https://forum.amebaiot.com/t/i2c-does-not-send-read-datagram-when-wire-requestfrom-is-called/3585/2 "2024-12-02T01:35:56Z")

</div>

Hi @electry,

Can you try adding a delay directly after the API call of requestFrom?

Try delay(1);

Thank you.
