The ESP32 analogue to digital converters do not have a full-scale range of 0V to 3.3V. With reference to this documentation, the programmable attenuator allows full-scale voltage of roughly 1.1V, 1.5V, 2.2V or 3.9V (but input signal must never go above 3.3V). As shown by the graph near the top of that documentation, the range does not quite extend down to zero volts.rankit0092 wrote:And ESP32 gives 1023 on 3.3v so i will never get proper output for voltage greater then 3.3.
i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
Re: i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
You could use both an Arduino and an ESP32, getting the Arduino to transmit data from the Arduino to the ESP32 via SPI or I²C communication. You may need to use voltage dividers or bidirectional level shifters to ensure the ESP32 inputs do not go above 3.3V. For I²C see the options here.
-
- Posts: 16
- Joined: Tue Jan 23, 2018 5:31 am
Re: i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
Thank you for all the support.
I able to read analog reading on my esp32 but,
now is there any coding logic to make,
5v ADC count = 3.3v ADC count ???
this is because I want same analog counts for later on so I must have to find a way to convert or MAP my counts same as ARDUINO(5v 10 bit ADC).
please help me to complete this in order to complete my product.
I able to read analog reading on my esp32 but,
now is there any coding logic to make,
5v ADC count = 3.3v ADC count ???
this is because I want same analog counts for later on so I must have to find a way to convert or MAP my counts same as ARDUINO(5v 10 bit ADC).
please help me to complete this in order to complete my product.
Re: i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
Option 1
Set the ADC to 10 bit resolution and attenuation to 6dB. Then carefully adjust the resistors of the divider circuit so 5V input gives 1023 and 0V input gives 0.
Look at the graph here under the first section titled "ADC Calibration". You need to carefully adjust the input resistor so with 5V input the digital value is on the edge of changing from 1023 to 1022. Similarly with 0V input you need to adjust the resistor connected to 3.3V so the digital value is on the edge of changing from 0 to 1. It's advisable to repeat this procedure. In order to adjust the resistors, add preset potentiometers connected as variable resistors: Option 2
Set the ADC to 12 bit resolution and the attenuation to 6dB. Design your resistor network so 5V input gives very roughly 1.8V into the ESP32 and 0V input gives roughly 0.2V into the ESP32. You are then certain that for input voltages between 0V and 5V the digital value will be well within the range 0 to 4095. You need to write some code to get the serial monitor to display the digital values when the input is connected to 0V and when connected to 5V. You can then use the Arduino map() function to map from that range of ADC values to the range 0 to 1023 (you would need to cast the result to an integer).
I am not certain the Arduino map() function works on the ESP32. If not, use the mathematics described in the Arduino reference.
Especially if making more than one of these items, I would choose option 2 because it avoids needing to have preset potentiometers and having to fiddle around with them.
Set the ADC to 10 bit resolution and attenuation to 6dB. Then carefully adjust the resistors of the divider circuit so 5V input gives 1023 and 0V input gives 0.
Look at the graph here under the first section titled "ADC Calibration". You need to carefully adjust the input resistor so with 5V input the digital value is on the edge of changing from 1023 to 1022. Similarly with 0V input you need to adjust the resistor connected to 3.3V so the digital value is on the edge of changing from 0 to 1. It's advisable to repeat this procedure. In order to adjust the resistors, add preset potentiometers connected as variable resistors: Option 2
Set the ADC to 12 bit resolution and the attenuation to 6dB. Design your resistor network so 5V input gives very roughly 1.8V into the ESP32 and 0V input gives roughly 0.2V into the ESP32. You are then certain that for input voltages between 0V and 5V the digital value will be well within the range 0 to 4095. You need to write some code to get the serial monitor to display the digital values when the input is connected to 0V and when connected to 5V. You can then use the Arduino map() function to map from that range of ADC values to the range 0 to 1023 (you would need to cast the result to an integer).
I am not certain the Arduino map() function works on the ESP32. If not, use the mathematics described in the Arduino reference.
Especially if making more than one of these items, I would choose option 2 because it avoids needing to have preset potentiometers and having to fiddle around with them.
-
- Posts: 16
- Joined: Tue Jan 23, 2018 5:31 am
Re: i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
Archibald wrote:Option 1
Set the ADC to 10 bit resolution and attenuation to 6dB. Then carefully adjust the resistors of the divider circuit so 5V input gives 1023 and 0V input gives 0.
Look at the graph here under the first section titled "ADC Calibration". You need to carefully adjust the input resistor so with 5V input the digital value is on the edge of changing from 1023 to 1022. Similarly with 0V input you need to adjust the resistor connected to 3.3V so the digital value is on the edge of changing from 0 to 1. It's advisable to repeat this procedure. In order to adjust the resistors, add preset potentiometers connected as variable resistors: Option 2
Set the ADC to 12 bit resolution and the attenuation to 6dB. Design your resistor network so 5V input gives very roughly 1.8V into the ESP32 and 0V input gives roughly 0.2V into the ESP32. You are then certain that for input voltages between 0V and 5V the digital value will be well within the range 0 to 4095. You need to write some code to get the serial monitor to display the digital values when the input is connected to 0V and when connected to 5V. You can then use the Arduino map() function to map from that range of ADC values to the range 0 to 1023 (you would need to cast the result to an integer).
I am not certain the Arduino map() function works on the ESP32. If not, use the mathematics described in the Arduino reference.
Especially if making more than one of these items, I would choose option 2 because it avoids needing to have preset potentiometers and having to fiddle around with them.
thank you this sounds as I think.
but I have already set esp32 at maximum 11dB attenuation to read my sensor output in 0-3.3volt, and I'm using a voltage divider to step down the sensor output to 3.3volt. I'm successfully able to read it.
can u tell me about your second option for my 11dB attenuation??/
yes map function is work for ESP32 greetings
thanks for your support.
Re: i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
According to documentation here, at 11dB attenuation the full scale voltage is about 3.9V but you must never put more than 3.3V into your ESDP32. So, if you set resolution to 10 bits and put 3.3V into your ESP from your voltage divider, you will not get 1023 digital. You will only get roughly 865. That's why for my Option 1, I suggested setting the attenuator to 6dB so you will get the full 0 to 1023 range.
You can use 11dB attenuation for my Option 2. Just make sure that with 5V input to the voltage divider that the voltage going into the ESP32 does not exceed 3.3V. With 12-bit resolution, you will get a digital range up to roughly 3460 which you can map in software to 1023. When the input to the voltage divider is zero, the digital value will depend on the value of resistor R3. With this option the value of R3 does not need to be accurate. Just make sure that when the input to the voltage divider is zero that the digital value is not zero. This ensures that you are not in the 'dead zone' at the bottom end of that graph. For Option 2, I am suggesting you use 12-bit resolution so in theory the sensor reading will be accurate to within one bit after software mapping to 0 - 1023 digital range.
Strictly we ought to consider the effects on the readings of any variation of supply voltage and of any noise on the 3.3V supply. Let's not complicate things!
You can use 11dB attenuation for my Option 2. Just make sure that with 5V input to the voltage divider that the voltage going into the ESP32 does not exceed 3.3V. With 12-bit resolution, you will get a digital range up to roughly 3460 which you can map in software to 1023. When the input to the voltage divider is zero, the digital value will depend on the value of resistor R3. With this option the value of R3 does not need to be accurate. Just make sure that when the input to the voltage divider is zero that the digital value is not zero. This ensures that you are not in the 'dead zone' at the bottom end of that graph. For Option 2, I am suggesting you use 12-bit resolution so in theory the sensor reading will be accurate to within one bit after software mapping to 0 - 1023 digital range.
Strictly we ought to consider the effects on the readings of any variation of supply voltage and of any noise on the 3.3V supply. Let's not complicate things!
Re: i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
I would use a simple amplifier with max 5V output or adjusted to scale between 0-5V output.rankit0092 wrote:I want to use my esp32 to measure a water quality parameters like pH, ORP etc. by ANALOG PINS
I have codes written for ARDUINO BOARD. so those codes give me output in a 10-bit resolution which is mapped between 0 to 5 volt.
but in an ESP32-WROOM board by default, it gives 12-bit resolution(0 to 4095) and which is mapped between 0 to 3.3 volt.
by using analogReadResolution(10) I'm able to change resolution but it gives me improper readings as the analog pins are mapped on 0 to 3.3 volt.
so how can I get readings like an Arduino analog pin???
when i give 5 volts, I want 1023 ADC reading on pin36 and 0 when I give 0-volt
insert how can I map ADC pins between 0 to 5 volt??
Another way is also to run it again through AD-DA converter with 5V out.
Also you can just connect ADC IC with SPI and read stuff in the code but I think you should just rewrite your code to use 3.3V with higher resolution
Re: i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
There's no need for an amplifier. The sensors already have outputs in the range 0V to 5V so the voltage must be a reduced, not amplified, before going into the ESP32.Deouss wrote:I would use a simple amplifier with max 5V output or adjusted to scale between 0-5V output.
A voltage output is not required. The original post asks for readings as if using the analogue to digital converter of a 5 volt Arduino. In other words digital values 0 to 1023 are wanted (as I understand it).Deouss wrote:Another way is also to run it again through AD-DA converter with 5V out.
The voltage corresponding to maximum digital value will depend on the setting of the attenuator associated with each ESP32 analogue to digital converter; it will not be 3.3V.Deouss wrote:Also you can just connect ADC IC with SPI and read stuff in the code but I think you should just rewrite your code to use 3.3V with higher resolution
Re: i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
So just drive 3.3-logic RF mosfet at 3.9V VCC with ESP pin voltages whatever you like. What's the problemArchibald wrote:The voltage corresponding to maximum digital value will depend on the setting of the attenuator associated with each ESP32 analogue to digital converter; it will not be 3.3V.
Re: i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
@Deouss . . . . . You seem to be misunderstanding the requirement here. The original poster is not trying to drive a voltage. The requirement is to get digital values 0 to 1023 as if using an ADC of a 5 volt Arduino. The sensors can have outputs in the range 0V to 5V.Deouss wrote:So just drive 3.3-logic RF mosfet at 3.9V VCC with ESP pin voltages whatever you like. What's the problem
I am replying to your posts because I fear they may confuse rankit0092.
Re: i want to map analog pins on 5volt between 0 to 1023 (10 bit resolution)
So sensor output is 0-5V that must be mapped to esp input 0-3.3VArchibald wrote:@Deouss . . . . . You seem to be misunderstanding the requirement here. The original poster is not trying to drive a voltage. The requirement is to get digital values 0 to 1023 as if using an ADC of a 5 volt Arduino. The sensors can have outputs in the range 0V to 5V.
I am replying to your posts because I fear they may confuse rankit0092.
Means fet gate must be logic 5V and D-S VCC 3.3V - just connect sensors to gate and fet drain to pin.
I'd put regulator before drain
Who is online
Users browsing this forum: Bing [Bot], tonystuart and 83 guests