Qiyaashaynta hadda iyadoo la isticmaalayo sensor-ka hadda ee Allegro ACS758 oo leh LCD1602 (I2C) ee Arduino
Cashiggan, waxaan baran doonnaa sida loo cabbiro hadda iyadoo la adeegsanayo sensor-ka hadda ee Allegro ACS758 oo lagu muujiyo akhrinta LCD1602 iyadoo la isticmaalayo isgaarsiinta I2C. Qaabkan ayaa faa'iido u leh codsiyo kala duwan, sida la socodka isticmaalka korantada ee wareegyada ama maareynta isticmaalka batteriga ee qalabka. Marka ay dhamaato mashruucan, waxaad yeelan doontaa nidaam shaqeeya oo muujinaya akhrinta hadda ee waqtiga dhabta ah.


Sensor-ka hadda ee ACS758 wuxuu cabbiri karaa ilaa 200A, taasoo ka dhigaysa mid ku habboon codsiyada korantada sare. LCD1602 wuxuu muujin doonaa hadda amperes-ka oo ay weheliso danabka u dhigma ee uu dareemo sensor-ka hadda. Si aad u caddeyso tillaabooyinka, hubi inaad fiiriso fiidiyowga (fiidiyowga 00:00) si aad u aragto muujin muuqaal ah.
Qalabka La Sharaxay
Qaybaha ugu muhiimsan ee mashruucan waxaa ka mid ah sensor-ka hadda ee Allegro ACS758 iyo LCD1602 oo leh I2C. ACS758 wuxuu u shaqeeyaa isagoo cabbiraya goobta magnetic-ka ee uu dhalo hadda ku qulqulaya conductor-ka. Wuxuu bixiyaa danab soo saar ah oo u dhigma hadda qulqulaya, kaas oo si fudud u akhrin karo Arduino-ga.
LCD1602 waa bandhig xarfo 16x2 ah oo adeegsada isgaarsiinta I2C, taasoo u oggolaanaysa isku xirnaan fudud iyo xakameyn kaliya laba biin oo xog ah. Tani waxay yaraynaysaa tirada fiilooyinka loo baahan yahay, iyadoo fududaynaysa habka fiilada. Interface-ka I2C wuxuu u oggolaanayaa qalab badan inay ku xirtaan isla baska, taasoo ka dhigaysa doorasho kala duwan oo ku habboon mashruucyada.
Faahfaahinta Xogta
| Soo saaraha | Allegro Microsystems |
|---|---|
| Nambarka qaybta | ACS758 |
| Danabka Logic/IO | 3.3V / 5V |
| Danabka sahayda | 5V |
| Hadda soo saarista (kanaal kasta) | 200 A ugu badan |
| Hadda ugu sarreysa (kanaal kasta) | 200 A |
| Hagaha soo noqnoqoshada PWM | N/A |
| Heerarka caqabadaha gelinta | 0.3V (hoose), 2.7V (sare) |
| Hoos u dhaca danabka / RDS(on) / saturation | 0.5V ugu badan |
| Xadka kulaylka | ilaa 150°C |
| Baakad | TO-220 |
| Qoraalo / noocyo | Ikhtiyaarrada laba-geesoodka ah iyo kuwa hal-geesoodka ah |
- Hubi inaad si fiican u qabato kulaylka codsiyada hadda sare.
- Ka saar sahayda korantada si aad uga fogaato buuqa saameynaya akhrinta.
- U isticmaal fiilooyin isku loolan ah wadada hadda si loo yareeyo faragelinta.
- Xaqiiji danabka soo saarista ee u dhigma hadda eber si aad u calaabayso.
- Hubi polarity markaad isticmaalayso sensor-ka hal-geesoodka ah.
Tilmaamaha Fiilada

Si aad u fiilayso sensor-ka hadda ee Allegro ACS758 iyo bandhiga LCD1602, ku bilow isku xirka korantada iyo dhulka. Ku xir biinka VCC ee ACS758 biinka 5V ee Arduino-ga, oo ku xir biinka GND dhulka Arduino-ga. Biinka soo saarista signal-ka (Vout) ee ACS758 waa in lagu xiraa biinka gelinta analog-ga A0 ee Arduino-ga.
Marka xigta, bandhiga LCD1602, ku xir biinka VCC biinka 5V ee Arduino-ga iyo biinka GND dhulka. SDA (xariiqda xogta) ee LCD waa inay ku xirtaa biinka A4 ee Arduino-ga, iyo SCL (xariiqda saacadda) waa inay ku xirtaa biinka A5. Qaabkani wuxuu u oggolaanayaa isgaarsiinta I2C ee u dhaxaysa Arduino-ga iyo LCD1602.
Tusaalooyinka Koodka & Sharaxaadda
Sketch-ka Arduino wuxuu ku bilaabmaa qeexida biinka gelinta ee sensor-ka hadda. Doorsoomaha VIN waxaa lagu qeexay A0, kaas oo ah meesha laga akhrin doono soo saarista sensor-ka. Danabka sahayda iyo nooca ACS758 ayaa sidoo kale la qeexay. Xasaasiyadda nooca la doortay waxaa lagu xisaabiyaa iyadoo la adeegsanayo sensitivity array.
#define VIN A0 // qeex biinka Arduino A0 sida gelinta danabka (V in)
const float VCC = 5.0; // danabka sahayda 5V ama 3.3V
const int model = 2; // geli nooca (hoos ka eeg)
Faalashada setup(), LCD-ga waa la bilaabay oo farriin soo dhawayn ah ayaa la muujiyay. Iftiinka dambe waa la shiday si loo helo muuqaal wanaagsan. Halkan waxaad ku habayn kartaa farriinta bilowga ah si ay ugu habboonaato mashruucaaga.
void setup() {
Serial.begin(9600); // bilaab kormeerka serial-ka
lcd.begin(); // bilaab LCD-ga
lcd.backlight();
lcd.print("Robojax");
lcd.setCursor (0,1); // tag bilowga xariiqda 2aad
lcd.print("ACS758 Current Sensor");
delay(2000); // sug 2 ilbiriqsi
lcd.clear();
}
Faalashada loop(), danabka sensor-ka waa la akhriyaa oo waa la farsameeyaa si loo xisaabiyo hadda. Haddii danabku ka sarreeyo xadka goynta ee la qeexay, hadda waxaa lagu muujiyaa kormeerka serial-ka iyo LCD-ga labadaba. Haddii aan hadda la helin, farriin ayaa la muujiyaa oo sheegaysa "No Current". Tani waxay u oggolaanaysaa la socodka waqtiga dhabta ah ee qulqulka hadda.
void loop() {
float voltage_raw = (5.0 / 1023.0) * analogRead(VIN); // Akhri danabka sensor-ka
float current = voltage / FACTOR;
if (abs(voltage) > cutOff) {
Serial.print("V: "); Serial.print(voltage, 3); // daabac danabka
lcd.print(current); // muuji hadda LCD-ga
} else {
Serial.println("No Current"); // soo saar marka aan hadda la helin
}
delay(500); // sug ka hor akhrinta xigta
}
Hubi inaad daawato sharaxaadda buuxda ee koodka fiidiyowga (fiidiyowga 01:30) si aad u hesho faahfaahin dhamaystiran oo ku saabsan qayb kasta.
Muujin / Waxa Laga Filan Karo
Marka la shido, nidaamku wuxuu ku muujin doonaa hadda ku socda sensor-ka ee LCD-ga waqti-gaab ah. Waxaad tijaabin kartaa qaabaynta adigoo ku dabaqaya hadda la yaqaan oo fiirinaya akhrinta. Haddii sensor-ku ogaado hadda, qiimaha voltage-ka iyo hadda waxay ku cusboonaan doonaan shaashadda. Haddii aysan jirin hadda, farriinta "No Current" ayaa soo bixi doonta. Ka digtoonow isku-xirka polarity-ga rogan, kaas oo keeni kara akhrin khaldan ama dhaawac qaybaha.
/*
*
* Arduino Sketch for Allegro ACS758 Current Sensor with LCD1602 & I2C module
* This sensor can measure current at a range of up to 200A.
* It operates with 3.3V or 5V.
* This sketch requires you to watch the following two videos before using this code:
* 1- ACS758 Sensor https://www.youtube.com/watch?v=SiHfjzcqnU4
* 2- LCD1602 with I2C https://www.youtube.com/watch?v=q9YC_GVHy5A
*
*
* Written by Ahmad Shamshiri on Tuesday, June 19, 2018, at 20:40 in Ajax, Ontario, Canada
* for Robojax.com
* View the video instruction for this code at https://youtu.be/tug9wjCwDQA
* This code has been downloaded from Robojax.com
*/
#define VIN A0 // define the Arduino pin A0 as voltage input (V in)
const float VCC = 5.0;// supply voltage 5V or 3.3V. If using PCB, set to 5V only.
const int model = 2; // enter the model (see below)
float cutOffLimit = 1.00;// reading cut-off current. 1.00 is 1 Amper
/*
"ACS758LCB-050B",// for model use 0
"ACS758LCB-050U",// for model use 1
"ACS758LCB-100B",// for model use 2
"ACS758LCB-100U",// for model use 3
"ACS758KCB-150B",// for model use 4
"ACS758KCB-150U",// for model use 5
"ACS758ECB-200B",// for model use 6
"ACS758ECB-200U"// for model use 7
The sensitivity array is holding the sensitivity of the ACS758
current sensors. Do not change.
*/
float sensitivity[] ={
40.0,// for ACS758LCB-050B
60.0,// for ACS758LCB-050U
20.0,// for ACS758LCB-100B
40.0,// for ACS758LCB-100U
13.3,// for ACS758KCB-150B
16.7,// for ACS758KCB-150U
10.0,// for ACS758ECB-200B
20.0,// for ACS758ECB-200U
};
/*
* Quiescent output voltage is a factor of VCC that appears at the output
* when the current is zero.
* For bidirectional sensors it is 0.5 x VCC
* For unidirectional sensors it is 0.12 x VCC
* For model ACS758LCB-050B, the B at the end represents Bidirectional (polarity doesn't matter)
* For model ACS758LCB-100U, the U at the end represents Unidirectional (polarity must match)
* Do not change.
*/
float quiescent_Output_voltage [] ={
0.5,// for ACS758LCB-050B
0.12,// for ACS758LCB-050U
0.5,// for ACS758LCB-100B
0.12,// for ACS758LCB-100U
0.5,// for ACS758KCB-150B
0.12,// for ACS758KCB-150U
0.5,// for ACS758ECB-200B
0.12,// for ACS758ECB-200U
};
const float FACTOR = sensitivity[model]/1000;// set sensitivity for selected model
const float QOV = quiescent_Output_voltage [model] * VCC;// set quiescent Output voltage for selected model
float voltage;// internal variable for voltage
float cutOff = FACTOR/cutOffLimit;// convert current cut off to mV
// ======== start of LCD1602 with i2C settings
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// ======= END of LCD1602 with i2C settings
void setup() {
//Robojax.com ACS758 Current Sensor
Serial.begin(9600);// initialize serial monitor
Serial.println("Robojax Tutorial");
Serial.println("ACS758 Current Sensor");
Serial.println("with LCD1602 & I2C");
// initialize the LCD,
lcd.begin();
// Turn on the backlight and print a message.
lcd.backlight();
lcd.clear();
lcd.print("Robojax");
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print("ACS758 Current Sensor");
delay(2000);
lcd.clear();
}
void loop() {
//Robojax code ACS758 with LCD1602 and I2C
float voltage_raw = (5.0 / 1023.0)* analogRead(VIN);// Read the voltage from sensor
voltage = voltage_raw - QOV + 0.007 ;// 0.007 is a value to make voltage zero when there is no current
float current = voltage / FACTOR;
if(abs(voltage) > cutOff ){
Serial.print("V: ");
Serial.print(voltage,3);// print voltage with 3 decimal places
Serial.print("V, I: ");
Serial.print(current,2); // print the current with 2 decimal places
Serial.println("A");
//start of loop Robojax code ACS758 with LCD1602 and I2C
lcd.clear();
lcd.setCursor (0,0); // set to line 1, char 0
lcd.print("Current: ");
lcd.setCursor (9,0); // go to start of 2nd line
lcd.print(current);
lcd.setCursor (15,0); // go to start of 2nd line
lcd.print("A");
lcd.setCursor (0,1);
lcd.print("Sense V: ");
lcd.setCursor (9,1); // go to start of 2nd line
lcd.print(voltage);
lcd.setCursor (15,1); // go to start of 2nd line
lcd.print("V");
lcd.backlight();
//end of loopcode Robojax code ACS758 with LCD1602 and I2C
}else{
Serial.println("No Current");
lcd.clear();
lcd.setCursor (0,0);
lcd.print("No Current");
}
delay(500);
}
Waad u baahan tahay
-
AmaazonACS758 current sensor on Amazonamzn.to
-
eBay
-
AliExpressPurchase Allegro ACS758 Current Sensor from AliExpresss.click.aliexpress.com
Kheyraadka & Tixraacyada
Wali wax kaydsan ah oo weli ma jiro.
Faylasha📁
Faylka Fritzing
-
LCD LCD1602-I2C module with 4 wires
LCD1602-I2C.fzpz0.01 MB
Faylal kale
-
Alegro ACS Current LibraryArduino library for Allegro ACS current sensor modules. Provides functions to read current measurements from ACS712 and similar sensors.
robojax_Alegro_ACS_Current_library.zip0.02 MB