Replies: 2 comments 4 replies
-
FYI, the Wire transmission is buffered until the end due to the HW requirements on the Pico (need to fill the FIFO before transmission can begin). So you probably want to move that delay() down...
if you want or need a 100ms delay between write and read transactions. Otherwise the read will happen immediately after the write completes. No real idea w/the clock stretching reports. The I2C read is pure HW driven. SCL is set to a pullup on-chip, but obviously the device is able to drive it low since the scope trace shows it low. You might want to use the RPi forums https://www.raspberrypi.org/forums/viewforum.php?f=144 to see if your experience is unique or if others have worked through it. Per the docs, it seems like clock stretching should work just fine on the Pico... |
Beta Was this translation helpful? Give feedback.
-
@earlephilhower I quickly would like to follow up with regard to Wire::setTimeout. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I try to read out a SHT21 sensor.
While this works on SAMD21 Arduino, with Hold mode or no hold mode, in the pico it works only with "no hold method".
It seems that the master (pi pico) does not ACK the bytes from the slave.
thats the code:
`
#include <Wire.h>
#include <Sodaq_SHT2x.h>
void setup()
{
Wire.setSDA(4);
Wire.setSCL(5);
Wire.setClock(10000);
Wire.begin();
Serial.begin(9600);
}
void loop()
{
uint16_t result;
Wire.requestFrom(0x40, 3);
uint32_t timeout = millis() + 1000; // Don't hang here for more than 300ms
while (Wire.available() < 3) {
if ((millis() - timeout) > 0)
{
Serial.print(" timeout: ");
Serial.println(Wire.available());
break;
}
}
`
Sending the command to the slave works. After the read command, the slave is pulling SCL down. After releasing it, slave sends 8 bytes, but there is no ACK (SDA Low at 9th clock) from the master:
Thats what it looks like on SAMD21:
as you can see, the frst bytes are ACKed with SDA Low, the third and last byte is NACKed.
Beta Was this translation helpful? Give feedback.
All reactions