Go Down

Topic: Logic level coonverter necessary for 3.3v sensor on Uno board? (Read 256 times) previous topic - next topic

dotancohen

Consider an arbitrary sensor that is powered by 3.3v, for use with an Arduino Uno.

The sensor will be powered from the 3.3v pin on the Arduino. Should a logic level converter be used for reading the output? On a project constrained for space, would it make more sense to just read the output directly and deal with the 0 - 3.3v reading instead of converting that to a 0 - 5v reading?

Wawa

That module seems to have a V-in pin for 5volt power, so you don't have to power it with 3.3volt.
And an I2C level converter, so you can connect it directly to the Uno's 5volt I2C bus.
Leo..

dotancohen

Thank you Wawa. I suppose that the sensor in the OP was a bad example, I've removed the example.

In general, for an arbitrary 3.3v sensor powered from the 3.3v pin, is it alright to read the output directly without a logic level converter?

Thanks.

jremington

Please DO NOT modify your original post, as answers to it are confusing.

You can read a 3.3V sensor output with a 5V Arduino. However, you cannot control or send information to the sensor without using a level converter.

dotancohen

Please DO NOT modify your original post, as answers to it are confusing.
I will keep that in mind, thank you. In this particular instance only the confusing part was removed, and it was redundant anyway.

Quote
You can read a 3.3V sensor output with a 5V Arduino. However, you cannot control or send information to the sensor without using a level converter.
Thank you, that is what I needed to know. I appreciate the assistance.

Wawa

The ATmega datasheet states logic LOW/HIGH thresholds at 0.3*VCC and 0.6*VCC,
which means anything above 3volt (0.6*5) should register as HIGH.
Leo..

wvmarle

In general, for an arbitrary 3.3v sensor powered from the 3.3v pin, is it alright to read the output directly without a logic level converter?
The proper answer should be: "depends on the sensor". Which for whatever reason you're seemingly unwilling to disclose.

It matters whether it's just a simple digital on/off output; I2C or SPI interface; Serial interface; analog output; or something more exotic.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

dotancohen

The proper answer should be: "depends on the sensor". Which for whatever reason you're seemingly unwilling to disclose.
This is a general question, not related to any specific sensor. I'm learning!

Quote
It matters whether it's just a simple digital on/off output; I2C or SPI interface; Serial interface; analog output; or something more exotic.
I was thinking along the lines of a sensor that would output a voltage signal in the [0, 3.3] range, to be read with analogRead(). I did not even think about other sensors.

Here is a 3.3v SPI device:
https://www.aliexpress.com/item/32870471046.html

I assume that with this SPI or with an I2C device one would need a logic level converter. Is that correct?

wvmarle

Here is a 3.3v SPI device:
https://www.aliexpress.com/item/32870471046.html
That's I2C and indeed doesn't seem to have level shifters on board, so you'd have to add them externally.

A 0-3.3V analog output can be read using analogRead() without any issues, it's just that you have only about 70% of the range so you lose resolution, and stability may be an issue due to the two independent supply voltages (3.3V and 5V). Depending on the sensor (yes, there we go again) and how it's all wired and powered (yet another set of variables) it may be better to use a 2:1 voltage divider and use the internal 1.1V reference.

A 0/3.3V digital output can be read with a regular digitalRead() call.

So... still no generic answer.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

dotancohen

That's I2C and indeed doesn't seem to have level shifters on board, so you'd have to add them externally.
Great, thanks.

Quote
A 0-3.3V analog output can be read using analogRead() without any issues, it's just that you have only about 70% of the range so you lose resolution, and stability may be an issue due to the two independent supply voltages (3.3V and 5V).
If the 3.3v is coming from the Arduino itself from the 3.3v pin, might there still be an issue with the different voltages?

If the 3.3v is coming from an eternal source, but its ground and the Arduino ground are connected, might there still be an issue with the different voltages?

Quote
Depending on the sensor (yes, there we go again) and how it's all wired and powered (yet another set of variables) it may be better to use a 2:1 voltage divider and use the internal 1.1V reference.
I'll go over the Sparkfun voltage divider tutorial now, thank you.
https://learn.sparkfun.com/tutorials/voltage-dividers/all

Quote
A 0/3.3V digital output can be read with a regular digitalRead() call.
As I understand it, digitalRead() returns HIGH when the input voltage is above 3.0 volts on a 5v board, and above 2.0 volts on a 3.3v board. It also returns LOW when the input voltage is below 1.5 volts on a 5v board, and below 1.0 volts on a 3.3v board. So for some borderline cases I do believe there may be a difference, pushing the voltage into the "uncertainty zone", especially for borderline-HIGH values.

Quote
So... still no generic answer.
That's fine. One does not learn from a specific implementation.

I very much appreciate you sharing your knowledge and helping myself and my daughters learn this terrific field!

Wawa

Here is a 3.3v SPI device:
https://www.aliexpress.com/item/32870471046.html
If you compare that to the board that you since have deleted, then you will see that a 5-pin chip (the 3.3volt regulator) is missing, and the two I2c level shifter fets (with the 103 resistors near), and a LED (with drive transistor).
This is a stripped-down 3.3volt only version of the previous one, without object illumination LED.

The limited A/D range when you connect 3.3volt devices to a 5volt processor can be fixed by connecting the Aref pin to the 3.3volt pin.
If you do, then you MUST set Aref to EXTERNAL in setup(), otherwise you will damage the A/D.
Now 0-3.3volt produces 0-1023.
You still can input 0-5volt, but anything over 3.3volt will return 1023.
Leo..

wvmarle

If the 3.3v is coming from the Arduino itself from the 3.3v pin, might there still be an issue with the different voltages?

If the 3.3v is coming from an eternal source, but its ground and the Arduino ground are connected, might there still be an issue with the different voltages?
The issue is not so much the voltage level, as it is the stability of this voltage. Every 3.3V source has a slightly different idea of how much 3.3V really is. Changes in the load on the voltage source always affect the actual voltage coming out. The same accounts for the 5V source. And that in turn can affect the readings, but whether it does and how much it does depends on the power supplies and the way the signal is produced.
Quality of answers is related to the quality of questions. Good questions will get good answers. Useless answers are a sign of a poor question.

dotancohen

The limited A/D range when you connect 3.3volt devices to a 5volt processor can be fixed by connecting the Aref pin to the 3.3volt pin.
If you do, then you MUST set Aref to EXTERNAL in setup(), otherwise you will damage the A/D.
Now 0-3.3volt produces 0-1023.
You still can input 0-5volt, but anything over 3.3volt will return 1023.
Thank you Leo! I was previously unaware of the reference voltage. I found lots of info from Google, the following two pages were most helpful:
https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/
https://forum.arduino.cc/index.php?topic=526271.0

dotancohen

The issue is not so much the voltage level, as it is the stability of this voltage. Every 3.3V source has a slightly different idea of how much 3.3V really is. Changes in the load on the voltage source always affect the actual voltage coming out. The same accounts for the 5V source. And that in turn can affect the readings, but whether it does and how much it does depends on the power supplies and the way the signal is produced.
I see, that makes sense. Thank you.

Wawa

If you power the sensor and Aref from the same Arduino 3.3volt supply,
then the above becomes irrelevant.
Leo..

Go Up