Comment
Author: Admin | 2025-04-28
The Arduino Analog pins. Now in this part of the circuit we will connect these voltage signals to Arduino and also interface a 16×2 alphanumeric display to the Arduino so that we can view the results. The circuit for the same is shown belowAs you can see the Voltage pin is connected to Analog pin A3 and the current pin is connected to Analog pin A4. The LCD is powered from the +5V from the 7805 and is connected to the digital pins of Arduino to work in 4-bit mode. We have also used a potentiometer (10k) connected to Con pin to vary the contrast of the LCD. Programming the ArduinoNow that we have a good understanding of the hardware, let us open the Arduino and start programming. The purpose of the code is to read the analog voltage on pin A3 and A4 and calculate the Voltage, Current and Power value and finally display it on the LCD screen. The complete program to do the same is given at the end of the page which can be used as such for the hardware discussed above. Further the code is split into small snippets and explained.As all programs we begin with, defining the pins that we have used. In out project the A3 and A4 pin is used to measure voltage and current respectively and the digital pins 3,4,8,9,10 and 11 is used for interfacing the LCD with Arduinoint Read_Voltage = A3;int Read_Current = A4;const int rs = 3, en = 4, d4 = 8, d5 = 9, d6 = 10, d7 = 11; //Mention the pin number for LCD connectionLiquidCrystal lcd(rs, en, d4, d5, d6, d7);We also have included a header file called liquid crystal to interface the LCD with Arduino. Then inside the setup function we initialise the LCD display and display an intro text as “Arduino Wattmeter” and wait for two seconds before clearing it. The code for the same is shown below.void setup() { lcd.begin(16, 2); //Initialise 16*2 LCD lcd.print(" Arduino Wattmeter"); //Intro Message line 1 lcd.setCursor(0, 1); lcd.print("-Circuitdigest"); //Intro Message line 2 delay(2000); lcd.clear();}Inside the main loop function, we use the analog read function to read the voltage value from the pin A3 and A4. As we know the Arduino ADC output value from 0-1203 since it has a 10-bit ADC. This value has to be then converted to 0-5V which can be done by multiplying with (5/1023). Then again earlier in the hardware we have mapped the actual value of voltage from 0-24V to 0-5V and the actual value of current form 0-1A to 0-5V. So now we have to use a multiplier to revert these values back to actual value. This can be done by multiplying it with a multiplier value. The value of the multiplier can either be calculated theoretically using the formulae provided in hardware section or if you have a known set of voltage and current values you can calculate it practically. I have followed the latter option because it
Add Comment