1

What is the difference between ESP32 Dev kit & Uno for analogread() Function?

As Uno -0 to 1023 As Esp 32 Dev Kit -0 to 4095

So what will be the raw val & scale val ?

For UNO -

int Rawval = analogRead(analogPin);
Serial.print("Rawvalue from Analog input =");
Serial.print(Rawval);
Scaleval = map(Rawval, 0, 675, 0, 20);
Serial.print(" Scaled Value =");

What will be for ESP32 Dev Kit?

Ref UNO- // For 3V3 input to read 100%, 3V3 of 5V ref = (3.3 / 5) * 1023 = 675

/// === RELAY code ===

// raw value 675 correspond to 20%, so for 5% we will get 169
  if ( Rawval < 169) digitalWrite(RELAY_pin, HIGH);  
  else  digitalWrite(RELAY_pin, LOW);   
}

What will be for ESP32 Dev Kit?

9
  • Look in the help section under the question mark in the editor about code quoting. I'd use the triple-backtick method for you, but you've got something weird around For UNO -int Rawval and I don't want to break things as much as fix them.
    – timemage
    Commented Feb 6, 2023 at 4:00
  • 2
    one is 10 bits of data and the other is 12 bits of data ... it appears that the question is not about analogread() at all, but about something else ... please update your question and ask about the real focus of your question
    – jsotola
    Commented Feb 6, 2023 at 4:26
  • what is raw val and scale val?
    – jsotola
    Commented Feb 6, 2023 at 4:27
  • QUESTION IS CLEAR?
    – Rocky
    Commented Feb 6, 2023 at 5:03
  • no, it is not ... the code is also not formatted properly, so it is difficult to read ... please format the code ... as @timemage already said, put ``` on a separate line before the code and also after the code
    – jsotola
    Commented Feb 6, 2023 at 5:14

1 Answer 1

-1

enter image description here

Confusion! Here also, As you said that code for UNO was provided by someone expert.

2
  • 2
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Feb 7, 2023 at 4:15
  • How to map for ESP32 (As 4095 for 3.3v)? Enclosed Logic is for uno. ''' // For 3V3 input to read 100%, 3V3 of 5V ref = (3.3 / 5) * 1023 = 675 Scaleval = map(Rawval, 0, 675, 0, 20); ''' ''' // raw value 675 correspond to 20%, so for 5% we will get 169''' Kindly modify this for ESP32 (4095)-- Enclosed Logic is for uno. If you can enclose logic behind that will also fine for me based on calculations Also for 0.1%
    – Rocky
    Commented Feb 13, 2023 at 4:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.