// Convert 5V Analog Inputs to 3.3V Analog Inputs for NodeMCU or Arduino Nano // Note Summary // Note : Safety is very important when dealing with electricity. We take no responsibilities while you do it at your own risk. // Note : NodeMCU is a very famous micro-controller with Wifi function which is commonly used for Internet Of Thing (IOT) application. // Note : However, the analog input of NodeMCU only support up to 3.3V. // Note : A voltage divider is needed in between a 5V output sensor and the nodeMCU. // Note : This is just an example using a potentiometer and how the conversion is made in programming code /*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*/////////////*/ float resistor1 = 170; // Declare the resistance of resistor 1 float resistor2 = 330; // Declare the resistance of resistor 2 float sensorValue; /* Variable to read sensor value*/ float variableAdjustment; /* Variable to adjust voltage due do different resistance values*/ void setup() { /* Put your codes here to run only once during micro controller startup */ /* 0- General */ Serial.begin(9600); /* to display readings in Serial Monitor at 9600 baud rates */ } void loop() { /* Put your codes here to run over and over again endlessly */ /* 0- General */ sensorValue = analogRead(A0); variableAdjustment = (sensorValue * 0.66) / (resistor2 / (resistor1 + resistor2)); Serial.println(variableAdjustment); delay(100); }