Hello ,
can someone can help me understadn the logic beyond the pullups?
this is what I know please correct me if I'm wrong:
- usually the Arduino is the server and the sensor device is the client
meaning that the scl go from the arduino to the device.
2.the sda goes both-ways - the pi "ask" something and the devcie return to him an "answer".
- all the data\clock will will be 5V (assuimg the Arduino is 5V and the device is 5V also).
- I understand I need to use pullups to avoid "noise" in the system
if I'm correct until here this is the main question:
noraml states on the line:
"0" - Arduino is sending "0" and the device get "0"
"1" - Arduino is sending "1" (which is 5V) and the device is getting 5V
what if the arduino is sending "0" and there is noise of 1V on the line , how does the pullups help me?
The outputs SDA/SCL cannot drive the line HIGH, they can only pull it LOW. Resistors are required by design to pull the line HIGH.
Using lower values for the pullup resistors makes the communications less sensitive to external interference/electrical noise induced in the connections between devices, but there are restrictions on the allowed values that vary between devices.
The details can be found in many places on the internet, such as here.
Using lower values for the pullup resistors makes the communications less sensitive to external interference/electrical noise induced in the connections between devices, but there are restrictions on the allowed values that vary between devices.
I ve read somewhere that the i2c libraries turn on the internal mpu pullups and hence no external pullups are required.
Can you confirm this?
The Arduino Wire library turns on the internal pullups. But they are very weak (30K to 50K) and often are not sufficient for proper operation. Also, weak pullups lead to noise problems, resulting in data transmission errors.
For reliable I2C comms, 4.7K pullups are used in a 5V system, 3.3K in a 3.3V system.
This provides around 1mA of pullup current, which leads to pretty sharp rising edges on positive going signals.
The internal pullup only leads to a long, drawn out rising edge which is not good for digital electronics.
If the I2C wires are long, or there a lot of devices connected, then even small value resistors should be considered, with 3 to maybe 5mA of total pullup current provided. You need to read the datasheet for your device and see how much current they can pull low.
SCL & SDA go both ways - SCL can be held low by the slave device for clock stretching.
Thanks guys for the clarification.
so to see I understand
when no data is send\read from the i2c device the line should hold on "1"
and when I use a pullups of 4.7K with 5V I make sure that I will get "1" no metter what
Did I understand correct?
but what happand when data is send\read and the line in "0" ? and then there is a noise?
or I didn't understadn the i2c idea?
is there a "i2c for dummies" ? that explain in very simple way the used?
Thanks ,
You should read about transistors. Specifically, open collector/drain outputs.
when no data is send\read from the i2c device the line should hold on "1"
and when I use a pullups of 4.7K with 5V I make sure that I will get "1" no metter what
Did I understand correct?
but what happand when data is send\read and the line in "0" ? and then there is a noise?
Correct. Noise on the dataline would only be a problem if the line is problematic when the SCL clock line transitions from Low to High to clock in the data bit.
If the SDA line is low, a 0 is clocked in, the line is high a 1 is clocked in.
If the line is somewhere between around 1V and 3V, then it's not clear if a 0 or 1 is clocked in.
For each byte sent and received, the master create creates 8 clock pulses.
The slave sends one extra low data bit, the Acknowledge bit.
The slave may also pull the clock line low at the end of a transfer if it needs some extra time (clock stretching).
Ok
I think I underatdn it now
Thanks!