Acs712-30A code for DC current

Hello, happy to be part of your community,unfortunately I do not know C / C ++ and I will undertake to study it well,
and I need to integrate in a sketch that I’m using to command 3 relays and a temperature probe ds18B20 of the code for an Acs712 to control a current load continue, I found other sketches but I think they are for vpp and alternating current, also while integrating them in the code make me display strange values ​​(800A empty) I have a acs712-30A, I use a wemos D1 mini, the current sensor has been tested with other sketch and adapted to the entry of the wemos to 3.3V 0.0032 instead of 0.0049 / 1024 and I measure the current precisely but this code does not work if integrated into blynk, thank you for any answers.
I apologize to the moderators if I have a wrong section

Basically: You need to get a sketch working with your hardware and sensors first. This isn’t a forum for general help with coding.

No one is gonna write the code for you, so hit the books! :slight_smile:

hello, thanks for your answer, at the moment I have a working sketch on blynk with 3 relay + 1 temperature sensor, I have a working sketch for the acs712 dc current but I can not integrate it on blynk, I do not think in a day can study me C / C ++ for something like that, that may come later. thanks anyway

Mkay… I have never worked with the ACS712 sensor, but if you search the forum you’ll find examples on how other users got it to work (I think).

If you paste your code (and DO format it correctly) perhaps someone can help you with the integration part :slight_smile:

1 Like

yes I got the code written by other users but it does not fit my case because probably they were sketch for alternating current (?), I try to paste here the code that works fine with my sensor, if someone can take a look for it insert in Blynk I would be very grateful.

  Arduino Acs712 DC Current Sensing
  Function: Sense the DC Current and Display on the Serial Monitor
  Prepared By: Krishnarajsinh Jadav

double Voltage = 0;
double Current = 0;

void setup(){ 

void loop(){
  // Voltage is Sensed 1000 Times for precision
  for(int i = 0; i < 1000; i++) {
    Voltage = (Voltage + (.0032 * analogRead(A0)));   // (5 V / 1024 (Analog) = 0.0049) which converter Measured analog input voltage to 5 V Range
  Voltage = Voltage /1000;
  Current = (Voltage -2.5)/ 0.066;    // Sensed voltage is converter to current 

Serial.print("\n Voltage Sensed (V) = ");            // shows the measured voltage 
Serial.print(Voltage,2);                             // the '2' after voltage allows you to display 2 digits after decimal point
Serial.print("\t Current (A) = ");                   // shows the voltage measured 
Serial.print(Current,2);                             // the '2' after voltage allows you to display 2 digits after decimal point


// this is the working sketch for my acs712-30A sensor, it detects the DC current well, I read the value through the Ide’s serial monitor. thank you

I said “DO format it correctly” :facepunch: :wink:

@distans They just never learn :stuck_out_tongue: Lets see if this one reads current topic/postings and/or searches :wink:

Sadly no :frowning: Wild guess - congested loop?

Sorry :relaxed: but when I posted the code I was mobile, however I read other discussions here on the community (search button) but nothing that I can make it work for my case :disappointed_relieved:
thank you

1 Like

I admit it is harder to find the correct back-ticks on mobile… but I have done it, so I know others can as well :wink:

:disappointed_relieved: Sad… I agree… but for different reasons… since I know I and others have posted examples and even a fully working Blynk sketch using this exact sensor. :disappointed_relieved: & :disappointed: that you couldn’t find it with a simple search of a keyword like ACS712

thanks anyway for the help to those who have intervened, I will still try in the hope of finding a sketch that goes well, i follow you,you are great :wink: