3v3 > I2C > 5V issue

I have a robot car, which is driven by an arduino Mboard. The Mboard is running on 3V3. I have an Ultrasonic range finder SR-04 which is being operated by an attiny 85. The Mboard and attiny can succesfull coomunicate to one another with I2C. This still happens on 3V3

The problem is that the SR-04 does not work on 3V3, it needs to be fed with 5V. To make this work I came with two solutions.

  • Put a 1.5V battery in series with the VCC of the SR-04 to get a VCC level of 4.8V or use a 5V batterpack to feed the SR-04. According to the datasheet it runs at TTL levels, that means that the 3V3 input and output of the attiny should be high enough to operate the sensor. As everything above 2.7V is considered a locic '1' on TTL

  • let both attiny85 and sensor work on 5V via a batterypack. The I2C pull-up resistors would be connected to the 5V line. As the atmega32u4 is 5V compatible and the I/O pins for I2C are always either configured as input or as a low written output. I dont think this could harm the 32u4. I posted the schematic for this.

What do you think the best solution would be?

No that is a very very bad idea. The pull up resistors will cause the 3V3 device to see 5V and that could damage it.
Just use two transistors to act as a level converter.

translator-1.pdf (21.4 KB)

You can, in many cases, power a device from 5V but connect the I2C pullup resistors to 3.3V.

The converter boards sold by Adafruit and others are also a good way of fixing this problem.

It is somewhat alot of work to connect the pullups to a seperate line, so im first trying the other solution. I use a 5V battery to supply 5V to the VCC pin of the SR-04 only. The attiny input and output will have to deal with the 5V, but I dont think it can possibly wreck it. It still goes from output > input. And inputs have a very high resistance.

The 3V3 output of the attiny is in TTL theorie high enough to trigger the SR-04 to send a pulse. And the echopin goes in an input of the attiny.

And even if I manage to wreck the attiny :wink: , I can use another. It is a 5V attiny afteral

I use a 5V battery to supply 5V to the VCC pin of the SR-04 only.

Never come across a 5V battery have you got a link to one?

It is somewhat alot of work to connect the pullups to a seperate line,

If soldering two resistors is a lot of work then maybe you are in the wrong hobby.

NEVER connect the pull up resistor of a 3V3 device to 5V.

Also the standard I2C library enables pull up resistors on the lines so that is exactly what you are doing unless you hack the library or get one that disables these resistors by default.

Never come across a 5V battery have you got a link to one?

so I mean a 4.8V battery pack, nobody cares.

Have you even seen the alternative schematic of post #4? Apparantly you have not, because in this schematic the Pull-ups are connected to the 3V3 line. And it is only one 3V3 input (of a 5V tolerant attiny) which has to endure a voltage of 5V. I dont see how one 5V line connected to an input with a few Meg ohm resistance could cause harm to a 5V tolerant chip which happens to run at 3V3, but ofcourse I can also add two whole resistors to make a voltage devider.

If soldering two resistors is a lot of work then maybe you are in the wrong hobby.

If you look again in the first schematic where I had planned to connect the pull-ups to the 5V, you could also see that I would have to disconnect the 3V3 from the 5V logic. These 2 resistors are already on the 3V3 line.

But your post suggest that your sole purpose on this topic is to hate, so can you plz take your hating to an other topic of somebody else and go be grumpy there, Mike? Because I will keep saying 5 Volt instead of 4.8Volts, Mike

bask185:
so I mean a 4.8V battery pack, nobody cares.

The Red wire, Not the White Wire. (ca BOOM)

Nobody cares right?

bask185:
Have you even seen the alternative schematic of post #4? Apparantly you have not, because in this schematic the Pull-ups are connected to the 3V3 line. And it is only one 3V3 input (of a 5V tolerant attiny) which has to endure a voltage of 5V. I dont see how one 5V line connected to an input with a few Meg ohm resistance could cause harm to a 5V tolerant chip which happens to run at 3V3, but ofcourse I can also add two whole resistors to make a voltage devider.
If you look again in the first schematic where I had planned to connect the pull-ups to the 5V, you could also see that I would have to disconnect the 3V3 from the 5V logic. These 2 resistors are already on the 3V3 line.

Where did you procure these '5v tolerant attiny's? The AtTiny can work from 1.8v to 5.5v at 4mhz, but each input pin has a crossbar diode to VCC. So any voltage applied above Vcc+0.4 is shorted through this diode to VCC. This is just a Protection Diode, it is not designed to be '5v tolerant' with Vcc below 5v.


Source : Atmel 2586Q–AVR–08/2013 documentation.

bask185:
But your post suggest that your sole purpose on this topic is to hate, so can you plz take your hating to an other topic of somebody else and go be grumpy there, Mike? Because I will keep saying 5 Volt instead of 4.8Volts, Mike

So we are to ignore any inaccuracies / errors in your posting.

Don't get mad when people correct you. Don't assume they are trying to belittle you, assume they are asking for clarification. When you said you had a 5v battery, I assumed it was a typo, and you actually meant a 6v battery (Lead/Acid 10AH), Now you correct it to to a 4.8V battery (I assume a NICad) Not a NiMH pack that could be 5v (1.25v x 4). Each of the possibilities have different performance characteristics. Max current out, Max charged voltage, Min voltage, charging profiles. It can make a difference in how questions are answered.

Calm down.

Chuck.

This is just a Protection Diode, it is not designed to be '5v tolerant' with Vcc below 5v.

Didnt know those diodes were on every I/O -_-, anways good thing we have resistors.

Don't get mad when people correct you. Don't assume they are trying to belittle you, assume they are asking for clarification. When you said you had a 5v battery, I assumed it was a typo, and you actually meant a 6v battery (Lead/Acid 10AH), Now you correct it to to a 4.8V battery (I assume a NICad) Not a NiMH pack that could be 5v (1.25v x 4). Each of the possibilities have different performance characteristics. Max current out, Max charged voltage, Min voltage, charging profiles. It can make a difference in how questions are answered.

Well it makes a bigger difference in how you ask those questions, this

Never come across a 5V battery have you got a link to one?

I find belitteling considering others ways you can ask this;

  • what kind of battery do you use. Do you mean a 4.8V NiMH pack?

On another note, how can you possibly think of a 6V lead acid battery, knowing very well we would most likely fry our absolute maximum 5.5V attiny where we are talking about...

It is still stupid we are talking about it, I never asked how to get 5V on the PCB.

I find belitteling considering others ways you can ask this;

  • what kind of battery do you use. Do you mean a 4.8V NiMH pack?

How you would you have felt about the response, don't be a stupid **** there is no such thing as a 5V battery?
I do not think my response was belitteling

Have you even seen the alternative schematic of post #4? Apparantly you have not, because in this schematic the Pull-ups are connected to the 3V3 line.

I have seen it. Did you draw it in crayon? It was very poor and there were no indications as to what the connections were on the boxes you drew.

I dont see how one 5V line connected to an input with a few Meg ohm resistance could cause harm to a 5V tolerant chip which happens to run at 3V3

Where are there resistors of a few meg ohms? You have the output of your distance sensor going into a chip powered on 3V3, that is wrong. But if your response is:-

And even if I manage to wreck the attiny :wink: , I can use another.

Then you should be belittled and take your chip that is on your shoulder elsewhere.

But your post suggest that your sole purpose on this topic is to hate, so can you plz take your hating to an other topic

It wasn't, it was not even a glimmer of a thought.
However as you choose to take it that way then I will leave you to wallow in your own self imposed ignorance.

Or a 5v battery could mean one of those USB power bank thingies - and those have some additional caveats. So it really is important to be accurate in your posts - what you should say is something like "4.8v NiMH battery pack" (or whatever kind of battery pack it is). Not only does that remove any ambiguity, but it also means that we can point out specific concerns relevant to the parts you're using.

If you wish to solve your problem, you need to take corrections gracefully. Even if you think the tone is rude - are they providing information that gets you closer to solving the problem? If so, your goal is not served by taking offense and getting into a fight. If you want to bicker and try to start drama - then argue with people trying to help, but that won't get you closer to a solution.

In any event... if you use pullups to 3.3v, it's okay to have a 5v device communicate with 3.3v one that way, at least so long as it's open drain - as opposed to an output that gets driven high. If in doubt, make sure it's not trying to put 5v onto them before you connect it to the 3.3v part. This is a major reason why I2C is open drain with pullups - that way the part can work on one voltage, and still communicate with a microcontroller or microprocessor running at lower voltage.

However, in the case of the HC-SR04, that's not open drain - the output is a logical high (ie, Vcc). What I'd do is divide the output with resistor divider. I don't think you need to do anything for the Trig input - i've seen lots of projects that run on 3.3v uC, connecting the trigger pin straight to the uC.

Have you heard of DC-DC converters? Search that on ebay - low current ones are dirt cheap, and might make your life easier.

Oh boys, so many emotions :frowning:

Electricians don't care whether a power supply has 4.8 or 5V, that's within the typical 10%. Many people power their stand-alone Arduinos by 4.5V (3 AA... cells). Combining devices of (more or less) different Vcc is subject to different considerations.

I also feel much confusion and many creeds about logic levels, in detail with I2C. Most important facts are

  • Integrated MOS chips do not normally sustain voltages above Vcc or below Gnd, by architecture (parasitic diodes). Bipolar devices are more tolerant, e.g. some o.c. outputs can support voltages above 30V.
  • ATmega digital pins have built in hysteresis (Schmitt triggers), and recognize LOW below 0.3Vcc, and HIGH above 0.7Vcc. According to Wikipedia that's exactly the level specification for the I2C bus. Anything in between won't change the digital state of the pin in a defined way. TTL levels are different and not applicable here.
  • These voltage levels should be respected, for best noise immunity of the bus.
  • Voltage dividers are not applicable to interface 3.3V devices to a 5V bus, because the signal lines are bidirectional (driven LOW by both master and slave). The use of proper level converters is strongly recommended.

Now some guesses:

  • I2C devices do (not?) cooperate with devices of other Vcc?
    Here we have to consider the points outlined above, voltage tolerance and signal level acceptance. I don't know whether or how many I2C chips support input voltages above their Vcc. Some operate with a separate digital Vcc, so that no compatibility issues should be expected with such devices. Otherwise connecting a 3.3V module to an I2C bus may prevent the bus signals from reaching their expected HIGH (3.5-5V) level, regardless of pullup resistors to 5V. Then it's not only the poor 3.3V device, that may be killed, but also the other (5V) devices may never sense a true/reliable HIGH signal.