Go Down

Topic: Can you tell me what this means and (Read 954 times) previous topic - next topic

hextejas

Nov 21, 2020, 10:57 pm Last Edit: Nov 22, 2020, 08:35 am by hextejas
if I need to do something ?
Board is a Feather ESP32

Quote
#20 / SDA - GPIO #20, also the I2C (Wire) data pin. There's no pull up on this pin by default so when using with I2C, you may need a 2.2K-10K pullup.
#21 / SCL - GPIO #21, also the I2C (Wire) clock pin. There's no pull up on this pin by default so when using with I2C, you may need a 2.2K-10K pullup.


What do I need to do and what happens if I don't do it




PerryBebbington

#1
Nov 21, 2020, 11:01 pm Last Edit: Nov 21, 2020, 11:05 pm by PerryBebbington
Quote
if I need to do something ?
Board is a Feather ESP32

What do I need to do and what happens if I don't do it ?
It means that you didn't provide enough information for anyone to help you. Is it April 1?

You need to provide more information or you will get silly answers like this one.

Paul__B


hextejas

It means that you didn't provide enough information for anyone to help you. Is it April 1?

You need to provide more information or you will get silly answers like this one.
For some reason the board would not let me put in the quote 

hextejas

Having read about pull up and pull down resistors leads me to the question of:
1) What is the state of the pin if no resistor is attached ? And for my question assume it is a GPIO pin that is not being used by the sketch.
Is it undefined in that it could be anything ?
While I was trying to run the Servo example, and before I was successful, the scope on the SDA pin showed what looked to be either a flat line at 3.3V or a wildly fluctuating line.
I don't know how putting some value resistor on the SDA pin would have any effect but I guess I will have to try it to see.

thanks

TheMemberFormerlyKnownAsAWOL

What is attached to the pin in question?
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

PerryBebbington

Search for floating input, this is a common question for newbies, it shows up in various ways.

From the processor point of view there are 2 and only 2 possible states a pin can be in: 0 or 1. An unconnected input can only be one or the other, which one will be unknown until you read the pin.

PerryBebbington

I2C is designed to allow 2 or more devices to communicate over the same wires. There has to be a way to allow any device to transmit data without the others interfering. Open collector or open drain means a device can drive SDA or SCL low but not high. No device on an I2C can output high, only low. If no device can output high something else has to do that instead, which is what the pull up resistors do.

hextejas


hextejas

I2C is designed to allow 2 or more devices to communicate over the same wires. There has to be a way to allow any device to transmit data without the others interfering. Open collector or open drain means a device can drive SDA or SCL low but not high. No device on an I2C can output high, only low. If no device can output high something else has to do that instead, which is what the pull up resistors do.
Does this mean that any device attached to the SDA pin is talking to it even though the sketch may have no intention to try and control(signal ?) it ?
As an example, the Blink example sketch does not use the SDA pin but there might be an SDA device attached to it. Is there interaction between the pin and the processor ? ( I dont know who/what controls the SDA pin. Is there a separate chip on the Feather board that handles this ?)
I may be getting too deep into the weeds here.

CrossRoads

If your sketch is not performing I2C transfers, there doesn't need to be anything connected.


If your sketch is performing I2C operations, you will have at least one other device connected. One will be the master for an transfer, one will be the slave. The master drives the clock for data going out and in.

If you are not using I2C, the pin is commanded like an other IO pin for reads and writes or PWM or whatever.

Like any other IO pin, the pin should not be left floating, as it can fluctuate. It should be pulled High or Low to a valid level to reduce energy use, especially important battery operation. With Atmega328P & similar, internal pullups can be used for that.  I don't know what ESP32 has. Fluctuating pins lead to internals switching, which leads to higher current draw.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

PerryBebbington

Does this mean that any device attached to the SDA pin is talking to it even though the sketch may have no intention to try and control(signal ?) it ?
As an example, the Blink example sketch does not use the SDA pin but there might be an SDA device attached to it. Is there interaction between the pin and the processor ? ( I don't know who/what controls the SDA pin. Is there a separate chip on the Feather board that handles this ?)
I2C is designed around the idea of 1 master and 1 or more slaves. If you look at any I2C slave device (an I2C OLED display for example) it will have an address. Usually it will have a choice of addresses that you can set with jumpers, for example I have some OLED displays that can have the address 0x78 or 0x7a, this is set by a solder bridge on the board. All I2C devices on the same bus must have different addresses. When the master wants to communicate with a slave it send the address first, this tells the slaves which one is to respond. The others then ignore the data on SDA. The master sends commands and data to the slave. If the master wants data from the slave it sends a command telling the slave to reply with the required data. SCL clocks the data on the bus in either direction.

I2C is normally taken care of by dedicated hardware in the microcontroller that is designed to do in hardware all the I2C functions. This means the processor can instruct the hardware to transfer some data then go and do something else while the hardware takes care of the data transfer.

It is also possible to implement I2C in software, you will see this referred to as 'bit banging', which is a crude way of saying the processor has to set and clear SCL and SCA using software for every single bit. Software I2C is very processor intensive and very slow. My first use of I2C was on a Z80, I wrote a soft I2C interface in Z80 assembly language and it took, so far as I can remember, about 1 second to read the temperatures from 4 I2C temperature sensors.

hextejas

I get the concept of master and slave. It sounds a bit like ethernet. 
So, how do i tell the circuit (?), that the Arduino is the master?
And do I need to do something to each slave, (I have 2) to indicate that they are slaves ? Probably, at least assure that they have unique addresses.
Is this what the pull-up, pull-down resistor is supposed to do, indicate that a slave is present?
 Given the need for a resistor it seems that the explanation should be more clear as to its value.

TheMemberFormerlyKnownAsAWOL

There is no pulldown resistor on I2C, just a pullup.

The pullup is there because the open-collector can only pull down, so something else has to return the line high.

The only thing that indicates that a slave is present is the slave's response to the master.
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

PerryBebbington

Quote
I get the concept of master and slave. It sounds a bit like ethernet.
Hmmm, not really like ethernet.

Quote
So, how do i tell the circuit (?), that the Arduino is the master?
On the Arduino you use
Code: [Select]
Wire.begin();
in setup, that makes it the master.
Most of the devices you are likely to connect to I2C are slaves and have addresses. There is no option for them to be master (how could an OLED display be a master?).

Quote
Is this what the pull-up, pull-down resistor is supposed to do, indicate that a slave is present?
No, see my reply #11

Quote
Given the need for a resistor it seems that the explanation should be more clear as to its value.
2k2 or thereabouts will be fine.

Go Up