Sensors with 5V outputs use voltage divider or level converter

I bought these sensors for Electron/Photon/Mesh (undecided which to use):

  1. pH probe + DS18B20 temperature + LM35 temperature
    Input = 5V and 5-10 mA
    Output P0 = pH analog 0-5V
    Output T1 = LM35 analog 0-5V
    Output T2 = DS18B20 digital 5V


  1. turbidity sensor
    Input =5V and 30 mA (max)
    Output = 0-5V analog


  1. Analog Electrical Conductivity Sensor
    Input = 12V and <1W
    Output = 0-5V analog

Since all sensors outputs are 5V and the input for Particle’s are 3.3V, should I use voltage divider or Bi-Directional Logic Level Converter ?

Voltage divider or level converter can also work for “digital sensor” ? Because my first sensor has both digital (DS18B20) and analog (LM35) output.

1 Like

A voltage divider setup would work – but can be problematic. You will lose resolution, and the values may not be linear – so you will need to test each result with a known-good value while you are programming.

A LLC only would work for a digital signal. It won’t help with analog sources.

I would recommend an external ADC (something similar to That will read between 0v and 5v, and give you logic-level binary at 3.3v. It would connect right up to one of the SPI lines for communications.

  1. If I choose voltage divider and LLC,
    So for the 4 analog outputs, I will use 4 sets voltage dividers.
    And for the 1 digital output, I will use a LLC?

  2. And If I choose external ADC,
    Since there are 5 sensor outputs (1 digital + 4 analog), do I need to have 5 pcs of ADC MCP3002 ?

  3. Or any other “simpler” way? Using Arduino will be the last option.

For the digital input it depends on your device:

  • On the Photon and Electron, all pins except A3 and A6 are 5V tolerant for digital inputs (if you are not using INPUT_PULLUP or INPUT_PULLDOWN). So on those devices you wouldn’t need a level converter.
  • On all mesh devices, you’d need a level shifter as the inputs are 3.3V max.

For the analog inputs, if you don’t need high accuracy or resolution, the voltage divider is fine.

If you want to use an external ADC, I would use a ADS1015 I2C ADC. It has 4 ADCs, so you only need one chip.

For mesh devices, you need to be careful using SPI with a SPI device running at 5V. The MISO pin from a 5V SPI device needs a level-shifter to avoid damaging the MCU.

However, if you use a 5V I2C device that can interface to 3.3V logic (it treats 3.3V inputs as high), you can use it without a level shifter as long as you use pull-ups on SDA and SCL to 3.3V not 5V.

On the Photon and Electron it doesn’t matter as the SPI and I2C inputs are 5V tolerant.

1 Like

Just wanted to follow up this great note by @rickkas7 : instead of using a full-blown level shifting device, a voltage divider just for the MISO pin should work. I use a MCP3208 ADC to get 8 single-ended channels. Communicates over SPI with the photon/mesh device. The MCP2308 only needs 0.7-0.8V to register a HIGH signal over the SPI bus so the 3.3V logic from the photon and mesh devices will be fine. However, the MISO pin will generate a potentially harmful 5V signal to the controlling MCU on the SPI bus so the voltage divider is mandatory. Hope that's helpful :grinning:

I think I will use Electron/Photon for this project. I will play with my paired Xenon/Argon in another chance (and also because of several ongoing mesh stability issues).

So I am looking at ADS1015 I2C ADC and Adafruit has excellent tutorial. Thank you @rickkas7 for introducing this.

I have never touched a MCP23008 and MCP3002 before. I will try to read about them later. Thanks bro.
I will use your codes from your post to get my sensor readings.

I should have paid attention to the sensor’s output voltage before I bought them.
But “in most cases”, widely available sensors from China (or the ones sold in Indonesia) have 5v outputs.

I am curious, can you explain why this would be problematic. The maximum resolution is determined by the number of bits in the ADC (12 bits for the photon or electron) whereas you are proposing a 10 bit ADC? There is no reason why a resistor based voltage divider should not be any less accurate than the tolerance of the resistors and will be linear?


A problem may arise when for some reason the GND connection of the voltage divider goes away (e.g. loose jumper wire) causing the high level to end up at the pin and consequently damaging it if it exceedes the 3.3V rating.

Accuracy impact is practically negligible, but for the sake of theoretical argument, with a perfectly temperature compensated sensor and ADC an uncompensated voltage divider would reduce accuracy. But that can be considered hypothetical :wink:

@fendytan Hi bro, I have just bought the third sensor and I dont have any proper Idea of how to connect it to Arduino can you give me some help of how did handle it?

I don't think any of the advice here applies to Arduino (or at least not some units) because Arduino has the ability to run on 5v inputs. No voltage divider or level-shifter is needed. Seeing as this is not an Arduino forum, you might want to ask your questions here: .

you might be right to some extent, but the first and the second device is totally applicable with Arduino and working very well because the input is only up to 5V only the third ones input is 12V so there is not enough info available so for that I saw this post thought to give it a try; to ask the writer whom has mentioned the same device i want. Thanks for your nice swift reply.