DIY

Current sensor for Arduino

Current sensor for Arduino  Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino From this article we will learn how to make a current sensor compatible with Arduino and most other widely popular microcontrollers. This project features a compact design and circuitry based on SMD components.
This current sensor can easily be used to measure up to 15A and even at a peak current of around 20A.
Tools and materials: -LM358; -Resistor 2.2 kOhm (code SMD 222); – Resistor 100 kOhm (code 104-SMD); – SMD capacitor 1 uF – 2 pcs; -Capacitor SMD 100 nF or 0, 1 μF; -Shunt resistor 5 mOhm (SMD code R005); – Screw terminal; -3-pin plug; -Multimeter; -Printing board;
-A solution of ferric chloride for etching;
-Engraver; -Drills 1.2 mm and 0.8 mm;
-Printer;
-Pliers;
-Tweezers;
-Plastic container for etching process;
-Soldering iron with a fine tip;
-Solder and flux;
-Arduino (option);
-Display (option);
-Breadboard (option);
Step One: Shunt Resistor
The main component in this circuit is the shunt resistor. It is with this resistor that a small voltage drop is measured and then amplified to measurable values ​​by the Arduino. It is important that the value of this resistor is small enough not to create a significant voltage drop across the circuit. The low resistance in the milliohm range also ensures that the total power dissipated is very low and therefore the resistor itself does not heat up. The voltage drop is small enough for the microcontroller to directly measure it, which is why an operational amplifier is used.
The shunt used in this circuit is labeled – R005, which means it has a resistance of 5 mΩ.
Current sensor for Arduino  Current sensor for Arduino Step two: schema
The wizard develops a schematic for the device and exports it to a PDF for printing.
Current sensor for Arduino Current sensor for Arduino Download the file below.
Current Sensor Layout.pdf
Step Three: Making the PCB
After completing the design of the circuit and layout, the wizard printed it at a scale that the print size would match the actual size of the PCB … You need to print in a mirror image. I cut a blank for the board according to the dimensions of the circuit.
Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Copper exposed to air for a long time tends to form an oxide layer, which can affect the overall conductivity. It is important that this oxide layer is removed with very fine sandpaper.
Current sensor for Arduino  Current sensor for Arduino Current sensor for Arduino He puts the printed circuit face down on the board and iron it with an iron. After that, it soaks the workpiece in water for 10 minutes. Takes out the blank and removes the paper.
Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Pours solution into the container ferric chloride and places the board blank into it. Shake the board periodically. As a result of this operation, all the copper around the picture will dissolve.
Current sensor for Arduino Current sensor for Arduino  Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Washes the board in water, and then erases the toner from the tracks with acetone.
Current sensor for Arduino  Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Step four: holes
Drilled holes with the help of an engraver.
Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Step five: installation
Since the master did not have a soldering station, he mounted SMD components using a soldering iron and an iron.
 Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Then he solders the pin connector and screw clamp.
Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Current sensor for Arduino Step six: coding and calibration
Now you need to code the microcontroller and calibrate the sensor value to get accurate readings.
The master used the Arduino Nano and the Arduino IDE.
The code can be broken down into the following steps:
Initializing the library for the OLED display ( for that he used the Adafruit library)
Setting analog pin 0 as input
Reading analog value from OP-Amp output on analog pin 0
Multiply the analog value by the calibration factor to get the correct current in amperes (or milliamperes).
Displaying the value on an OLED display
The OP-Amp acts as a non-inverting amplifier in this circuit and produces a voltage proportional to the voltage drop across the shunt. This voltage is then measured with the Arduino ADC, which outputs a number between 0 and 1023 (the 10-bit resolution of the Arduino ADC). This number is not equal to the actual current value, so mathematical manipulation must be performed in software to get the exact value. In this case, a multimeter comes to the rescue. Most multimeters can accurately measure currents up to 10 A, so it can be used as a reference to determine the calibration factor.
The idea is to use a small load along with a power supply with a millimeter and a current shunt in series with the load.
So here the multimeter can measure the actual current drawn by the load and from our current shunt module we can get the corresponding analog value via the Arduino.
Calibration factor can be calculated as:
Calibration factor = (multimeter reading/Arduino reading )
This line in the code is written like this:
float val = analogRead (A0);
float amp = val * 0,015426; //this is the calibration factor
Download the code below.
Current_sensor_code_with_OLED.ino
Current sensor for Arduino  Current sensor for Arduino Step Seven: Testing
After completing the hardware and software setup, the last thing to do is check the functionality and accuracy of the current sensor module. For this, the master used a 12V rechargeable battery and a 5V step-down converter module. As a load, he connected a smartphone for charging. As you can see in the photo, the values ​​on the multimeter and the display are the same.
Current sensor for Arduino Current sensor for Arduino  Current sensor for Arduino Everything is ready.
Current sensor for Arduino  Current sensor for Arduino

Source:

usamodelkina.ru

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button