{"id":1879,"date":"2024-06-28T07:30:23","date_gmt":"2024-06-28T07:30:23","guid":{"rendered":"https:\/\/iotthinghub.com\/?p=1879"},"modified":"2024-08-11T17:16:24","modified_gmt":"2024-08-11T17:16:24","slug":"current-sensor","status":"publish","type":"post","link":"https:\/\/iotthinghub.com\/?p=1879","title":{"rendered":"Current Sensor"},"content":{"rendered":"\n<p class=\"has-text-color has-link-color wp-elements-1 wp-block-paragraph\" style=\"color:#5c5c5c\">ACS712 is a hall effect-based linear current sensor that can measure both AC and DC current. Let\u2019s look at the connection and steps to interface.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"276\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/current-sensor-1024x276.jpg\" alt=\"\" class=\"wp-image-1882\" style=\"width:809px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/current-sensor-1024x276.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/current-sensor-300x81.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/current-sensor-768x207.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/current-sensor.jpg 1354w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-2 wp-block-paragraph\" style=\"color:#5c5c5c\">For a unipolar supply voltage, it nominally remains at VCC\u2044 2. Thus, VCC = 5 V translates into V <sub>IOUT(Q)<\/sub> = 2.5 V. So for 0A the reference voltage is V<sub>ADC<\/sub> = 2.5V and ADC Value is 512.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large is-resized\"><img decoding=\"async\" width=\"1024\" height=\"141\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/Current-sensor-data-1024x141.jpg\" alt=\"\" class=\"wp-image-1884\" style=\"width:741px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/Current-sensor-data-1024x141.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/Current-sensor-data-300x41.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/Current-sensor-data-768x105.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/Current-sensor-data.jpg 1239w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-3 wp-block-paragraph\" style=\"color:#5c5c5c\">Current sensing value is<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-4 wp-block-paragraph\" style=\"color:#252525\">V<sub>out<\/sub> = (V<sub>CC<\/sub>\/2) + Sensitivity*Current , Here V<sub>CC <\/sub>= 5V<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-5 wp-block-paragraph\" style=\"color:#252525\">Here, ADC Value = V<sub>out<\/sub> * (1024\/5)<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-6 wp-block-paragraph\" style=\"color:#252525\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; = ((V<sub>CC<\/sub>\/2) + Sensitivity*Current)* (1024\/5) =&nbsp; ((5\/2) + Sensitivity*I)* (1024\/5)<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-7 wp-block-paragraph\" style=\"color:#252525\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 512 + (Sensitivity*I*1024)\/5<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-8 wp-block-paragraph\" style=\"color:#252525\">Current I = (5\/(1024* Sensitivity))*(ADC Value-512) <\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-9 wp-block-paragraph\" style=\"color:#252525\">For ACS712ELCTR-20AT the sensitivity is 0.1 and the current value is Current I = (5\/102.4)*(ADC Value &#8211; 512)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" width=\"1024\" height=\"38\" src=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/function-3-2-1024x38.jpg\" alt=\"\" class=\"wp-image-1888\" style=\"width:647px;height:auto\" srcset=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/function-3-2-1024x38.jpg 1024w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/function-3-2-300x11.jpg 300w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/function-3-2-768x29.jpg 768w, https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/06\/function-3-2.jpg 1211w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\nfloat current(uint8_t phase,uint8_t channel)\n{\n  float current;\n  uint16_t ADC_Value;\n  ADC_Value=read_adc(channel);\n  if(phase==AC_Current)\n\t{\n\t\tif(ADC_Value&gt;=512)\n\t\t\t{\n\t\t\t current=(ADC_Value-512)*(5\/(ADC_Scale*sinsitivity)); \/\/VCC=5V\n\t\t\t}\n\t}\n     else if(phase==DC_Current)\n\t{\n\t\tcurrent=(ADC_Value-512)*(5\/(ADC_Scale*sinsitivity)); \/\/VCC=5V\n\t}\n\t\n return current;\n}\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-10 wp-block-paragraph\" style=\"color:#252525\">Here for ACS712-05BT sensitivity 0.185, ACS712-20AT sensitivity 0.1 and ACS712-30AT sensitivity 0.066.<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-11 wp-block-paragraph\" style=\"color:#5c5c5c\">Set timer0 overflow vect and at every interrupt service routine read the current. Let\u2019s look at the main program-<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: cpp; auto-links: false; title: ; quick-code: false; notranslate\" title=\"\">\n  #include&lt;avr\/io.h&gt;\n  #include&lt;stdio.h&gt;\n  #include&lt;avr\/interrupt.h&gt;\n  #include&quot;adc.h&quot;\n  #include&quot;lcd.h&quot;\nfloat VA=1,Amp_ac,Amp_dc,volage=220;\nchar str&#x5B;20];\nint main(void)\n  {\n   LCD_INIT();\n   adc_init();\n   LCD_Clear();\n   timer_ISR();\n   while(1)\n    {\n      sprintf(str,&quot;AC Current=%.2fA&quot;,Amp_ac);\n      LCD_write_string(1,1,str);\n      sprintf(str,&quot;DC Current=%.2fA&quot;,Amp_dc);\n      LCD_write_string(1,2,str);\n      _delay_ms(1000);\n    }\n  return 0;\n}\nISR(TIMER0_OVF_vect)\n{\n\tAmp_ac=current(1,0); \/\/AC Current(1) with channel 0\n\tAmp_dc=current(2,1); \/\/DC Current(2) with channel 1\n\t\n}\n<\/pre><\/div>\n\n\n<p class=\"has-text-color has-link-color wp-elements-12 wp-block-paragraph\" style=\"color:#5c5c5c\">Since we have a PDB supply is fixed at 220V, we can calculate the power = VIcos\u0553. If power factor cos\u0553=0.98 and V=220V then we can calculate the power from the equation.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-7387b849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:33.33%\">\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-3e41869c wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/Current-Sensor.rar\" style=\"padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--40);padding-bottom:var(--wp--preset--spacing--30);padding-left:var(--wp--preset--spacing--40)\">download<\/a><\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:66.66%\">\n<p class=\"has-text-color has-link-color has-upper-heading-font-size wp-elements-13 wp-block-paragraph\" style=\"color:#252525\"><a href=\"https:\/\/iotthinghub.com\/wp-content\/uploads\/2024\/08\/Current-Sensor.rar\">Current Sensor.rar<\/a><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>ACS712 is a hall effect-based linear current sensor that can measure both AC and DC current. Let\u2019s look at the connection and steps to interface. For a unipolar supply voltage, it nominally remains at VCC\u2044 2. Thus, VCC = 5 V translates into V IOUT(Q) = 2.5 V. So for 0A the reference voltage is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-1879","post","type-post","status-publish","format-standard","hentry","category-adc"],"_links":{"self":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/1879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1879"}],"version-history":[{"count":7,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/1879\/revisions"}],"predecessor-version":[{"id":2625,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=\/wp\/v2\/posts\/1879\/revisions\/2625"}],"wp:attachment":[{"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/iotthinghub.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}