Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. ACS712 strange values when measuring 3D printer power consumption

ACS712 strange values when measuring 3D printer power consumption

Scheduled Pinned Locked Moved Troubleshooting
14 Posts 4 Posters 3.7k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SushukkaS Offline
    SushukkaS Offline
    Sushukka
    wrote on last edited by
    #4

    I have only one line going through ACS712 and then its splitted to multiple outlets with extension cord. First I though that my 20A ACS712 is actually only 5A one, but same problem happes with the second ACS712 20A. Also even 5A should be able to measure this load as Prusa's maximum intake is around 180W.
    Maybe it has something to do with the power factor, dunno. Now I have anyway managed to pinpoint the problem to 3D printers. When plugging only Arduino+ACS712+Prusa MK2 to the wall, ACS712 shows around 690W loads when the Prusa's maximum is about 180W as mentioned above. My old faithful hair dryer power consumption is measured correctly (430W, 820W, 1400W).

    dbemowskD M 2 Replies Last reply
    1
    • SushukkaS Sushukka

      I have only one line going through ACS712 and then its splitted to multiple outlets with extension cord. First I though that my 20A ACS712 is actually only 5A one, but same problem happes with the second ACS712 20A. Also even 5A should be able to measure this load as Prusa's maximum intake is around 180W.
      Maybe it has something to do with the power factor, dunno. Now I have anyway managed to pinpoint the problem to 3D printers. When plugging only Arduino+ACS712+Prusa MK2 to the wall, ACS712 shows around 690W loads when the Prusa's maximum is about 180W as mentioned above. My old faithful hair dryer power consumption is measured correctly (430W, 820W, 1400W).

      dbemowskD Offline
      dbemowskD Offline
      dbemowsk
      wrote on last edited by
      #5

      @Sushukka said in ACS712 strange values when measuring 3D printer power consumption:

      I have only one line going through ACS712 and then its splitted to multiple outlets with extension cord.

      So with this, are you saying that the multiple outlets with extension cords are all connected through one ACS712?

      Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
      Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

      SushukkaS 1 Reply Last reply
      0
      • dbemowskD dbemowsk

        @Sushukka said in ACS712 strange values when measuring 3D printer power consumption:

        I have only one line going through ACS712 and then its splitted to multiple outlets with extension cord.

        So with this, are you saying that the multiple outlets with extension cords are all connected through one ACS712?

        SushukkaS Offline
        SushukkaS Offline
        Sushukka
        wrote on last edited by Sushukka
        #6

        @dbemowsk Yes, there are about 8 devices behind this line. But they rarely use over 600W together and are actually splitted after UPS. However, I can use all other devices but 3D printers at the same time and having quite reliable numbers. As I mentioned before when I plug only Prusa MK2 and nothing else the values goes crazy. Latest testing results:

        • Only Arduino + ACS712 and Prusa plugged in --> ACS712 power usage: 630W, reference: 196W.
        • Replacing Prusa with a hair dryer to the same setup --> ACS712 power usage: 435/849/1430W, reference: 443/864/1443W.

        What's wrong with my Prusa? :anguished:

        dbemowskD YveauxY 2 Replies Last reply
        0
        • SushukkaS Sushukka

          @dbemowsk Yes, there are about 8 devices behind this line. But they rarely use over 600W together and are actually splitted after UPS. However, I can use all other devices but 3D printers at the same time and having quite reliable numbers. As I mentioned before when I plug only Prusa MK2 and nothing else the values goes crazy. Latest testing results:

          • Only Arduino + ACS712 and Prusa plugged in --> ACS712 power usage: 630W, reference: 196W.
          • Replacing Prusa with a hair dryer to the same setup --> ACS712 power usage: 435/849/1430W, reference: 443/864/1443W.

          What's wrong with my Prusa? :anguished:

          dbemowskD Offline
          dbemowskD Offline
          dbemowsk
          wrote on last edited by
          #7

          @Sushukka I would plug in the printer on it's own with nothing else running and see if it goes crazy. Then turn on other devices til it freaks out. Once it freaks out, measure the current with an amp meter at the ACS712. You will need to disconnect the ACS712 to do this. That way you can see how much draw there actually is that the ACS712 is seeing.

          Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
          Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

          1 Reply Last reply
          0
          • SushukkaS Sushukka

            @dbemowsk Yes, there are about 8 devices behind this line. But they rarely use over 600W together and are actually splitted after UPS. However, I can use all other devices but 3D printers at the same time and having quite reliable numbers. As I mentioned before when I plug only Prusa MK2 and nothing else the values goes crazy. Latest testing results:

            • Only Arduino + ACS712 and Prusa plugged in --> ACS712 power usage: 630W, reference: 196W.
            • Replacing Prusa with a hair dryer to the same setup --> ACS712 power usage: 435/849/1430W, reference: 443/864/1443W.

            What's wrong with my Prusa? :anguished:

            YveauxY Offline
            YveauxY Offline
            Yveaux
            Mod
            wrote on last edited by
            #8

            @Sushukka Read and understand this: https://learn.openenergymonitor.org/electricity-monitoring/ac-power-theory/introduction

            Post your sketch please...

            http://yveaux.blogspot.nl

            SushukkaS 1 Reply Last reply
            0
            • YveauxY Yveaux

              @Sushukka Read and understand this: https://learn.openenergymonitor.org/electricity-monitoring/ac-power-theory/introduction

              Post your sketch please...

              SushukkaS Offline
              SushukkaS Offline
              Sushukka
              wrote on last edited by Sushukka
              #9

              @Yveaux Thank you for the link. Very good document which went straight to my favorites. :)
              Here is the algorithm of the sketch:

              /*
              Measuring AC Current Using ACS712
              This ACS712 algorithm is more precise than ACS712_2 algorithm but because of long while loop
              cannot be used with animated displays or similar non-interruptable functionality
              */
              const int sensorIn = A0;
              int mVperAmp = 100; // use 100 for 20A Module and 66 for 30A Module
              
              
              double Voltage = 0;
              double VRMS = 0;
              double AmpsRMS = 0;
              
              void setup(){ 
               Serial.begin(115200);
              }
              
              void loop() {
               Voltage = getVPP();
               VRMS = (Voltage/2.0) *0.707; 
               AmpsRMS = (VRMS * 1000)/mVperAmp;
               AmpsRMS -= 0.45;     // Empty load correction
               Serial.print(AmpsRMS);
               Serial.print("A ");
               Serial.print(AmpsRMS * 230);
               Serial.print("W\t");
               Serial.print(Voltage);
               Serial.println("V");
              
               delay(500);
              
              }
              
              float getVPP() {
                float result;
                int readValue;             //value read from the sensor
                int maxValue = 0;          // store max value here
                int minValue = 1024;          // store min value here
                
                 uint32_t start_time = millis();
                 while((millis()-start_time) < 1000) { //sample for 1 Sec
                   readValue = analogRead(sensorIn);
                   // see if you have a new maxValue
                   if (readValue > maxValue) {
                       /*record the maximum sensor value*/
                       maxValue = readValue;
                   }
                   if (readValue < minValue) {
                       /*record the maximum sensor value*/
                       minValue = readValue;
                   }
                 }
                 
                 // Subtract min from max
                 result = ((maxValue - minValue) * 5.0)/1024.0;
                    
                 return result;
               }
              

              I have also used another algorithms, but this seems to give now good enough results. This algorithm is taken from: http://henrysbench.capnfatz.com/henrys-bench/arduino-current-measurements/acs712-arduino-ac-current-tutorial/

              Edit: Switched using Emonlib and used:

              emon1.current(0, 9.5);             // Current: input pin, calibration.
              

              Now all other loads seems to show correctly but Prusa is still showing too much (200W vs 300W). So it seems to be that the Prusa's power supply is creating lots of reactive/non-linear load affecting badly to the power factor (right?). Probably this is just that much you can do with these cheap sensors. Maybe need to set Prusa out of this power meter or build own Prusa power sensor with different calibration/correction routines.

              YveauxY 1 Reply Last reply
              0
              • SushukkaS Sushukka

                @Yveaux Thank you for the link. Very good document which went straight to my favorites. :)
                Here is the algorithm of the sketch:

                /*
                Measuring AC Current Using ACS712
                This ACS712 algorithm is more precise than ACS712_2 algorithm but because of long while loop
                cannot be used with animated displays or similar non-interruptable functionality
                */
                const int sensorIn = A0;
                int mVperAmp = 100; // use 100 for 20A Module and 66 for 30A Module
                
                
                double Voltage = 0;
                double VRMS = 0;
                double AmpsRMS = 0;
                
                void setup(){ 
                 Serial.begin(115200);
                }
                
                void loop() {
                 Voltage = getVPP();
                 VRMS = (Voltage/2.0) *0.707; 
                 AmpsRMS = (VRMS * 1000)/mVperAmp;
                 AmpsRMS -= 0.45;     // Empty load correction
                 Serial.print(AmpsRMS);
                 Serial.print("A ");
                 Serial.print(AmpsRMS * 230);
                 Serial.print("W\t");
                 Serial.print(Voltage);
                 Serial.println("V");
                
                 delay(500);
                
                }
                
                float getVPP() {
                  float result;
                  int readValue;             //value read from the sensor
                  int maxValue = 0;          // store max value here
                  int minValue = 1024;          // store min value here
                  
                   uint32_t start_time = millis();
                   while((millis()-start_time) < 1000) { //sample for 1 Sec
                     readValue = analogRead(sensorIn);
                     // see if you have a new maxValue
                     if (readValue > maxValue) {
                         /*record the maximum sensor value*/
                         maxValue = readValue;
                     }
                     if (readValue < minValue) {
                         /*record the maximum sensor value*/
                         minValue = readValue;
                     }
                   }
                   
                   // Subtract min from max
                   result = ((maxValue - minValue) * 5.0)/1024.0;
                      
                   return result;
                 }
                

                I have also used another algorithms, but this seems to give now good enough results. This algorithm is taken from: http://henrysbench.capnfatz.com/henrys-bench/arduino-current-measurements/acs712-arduino-ac-current-tutorial/

                Edit: Switched using Emonlib and used:

                emon1.current(0, 9.5);             // Current: input pin, calibration.
                

                Now all other loads seems to show correctly but Prusa is still showing too much (200W vs 300W). So it seems to be that the Prusa's power supply is creating lots of reactive/non-linear load affecting badly to the power factor (right?). Probably this is just that much you can do with these cheap sensors. Maybe need to set Prusa out of this power meter or build own Prusa power sensor with different calibration/correction routines.

                YveauxY Offline
                YveauxY Offline
                Yveaux
                Mod
                wrote on last edited by
                #10

                @Sushukka The getVPP function samples for 1 second and returns the maximum peak-peak voltage of these samples.
                For purely resistive loads it is correct to multiply this peak-peak voltage by 0.707 to get the RMS value.

                0_1503073849683_psLapLamp_0.png

                If your load looks like the blue graph (reactive load, taken from the link in my previous post) you have to integrate the surface area to get the true RMS value (that's why true RMS multimeters are in general more expensive and are advertised as such). I think the emon lib does exactly that, but I would have to check.

                As a test you could run a sketch which samples the voltage from the ACS712 as fast as possible and outputs these values to the serial port. Recent Arduino versions contain a 'serial plotter' which then graphically show the power usage.
                A test sketch could be as simple as:

                void setup() { 
                 Serial.begin(115200);
                }
                
                void loop() {
                 Serial.println( analogRead(A0) );
                }
                

                Flash it, select serial plotter in the tools menu and watch the output.

                http://yveaux.blogspot.nl

                SushukkaS 1 Reply Last reply
                1
                • YveauxY Yveaux

                  @Sushukka The getVPP function samples for 1 second and returns the maximum peak-peak voltage of these samples.
                  For purely resistive loads it is correct to multiply this peak-peak voltage by 0.707 to get the RMS value.

                  0_1503073849683_psLapLamp_0.png

                  If your load looks like the blue graph (reactive load, taken from the link in my previous post) you have to integrate the surface area to get the true RMS value (that's why true RMS multimeters are in general more expensive and are advertised as such). I think the emon lib does exactly that, but I would have to check.

                  As a test you could run a sketch which samples the voltage from the ACS712 as fast as possible and outputs these values to the serial port. Recent Arduino versions contain a 'serial plotter' which then graphically show the power usage.
                  A test sketch could be as simple as:

                  void setup() { 
                   Serial.begin(115200);
                  }
                  
                  void loop() {
                   Serial.println( analogRead(A0) );
                  }
                  

                  Flash it, select serial plotter in the tools menu and watch the output.

                  SushukkaS Offline
                  SushukkaS Offline
                  Sushukka
                  wrote on last edited by
                  #11

                  @Yveaux said in ACS712 strange values when measuring 3D printer power consumption:

                  void setup() {
                  Serial.begin(115200);
                  }

                  void loop() {
                  Serial.println( analogRead(A0) );
                  }

                  Cool, haven't thought you could use plotter like this. Hair dryer gave pretty sin/cos like load, Kossel 3D printer with a normal computer supply is quite close but Prusa's load was pretty spiky. It looked like:

                                  /|
                                 / |
                                |   \
                        /------/    |
                  ----/             \----
                  

                  Which probably underlines pretty well your point. :) Question is that is there anyway to tackle this when using emonlib?

                  YveauxY 1 Reply Last reply
                  1
                  • SushukkaS Sushukka

                    @Yveaux said in ACS712 strange values when measuring 3D printer power consumption:

                    void setup() {
                    Serial.begin(115200);
                    }

                    void loop() {
                    Serial.println( analogRead(A0) );
                    }

                    Cool, haven't thought you could use plotter like this. Hair dryer gave pretty sin/cos like load, Kossel 3D printer with a normal computer supply is quite close but Prusa's load was pretty spiky. It looked like:

                                    /|
                                   / |
                                  |   \
                          /------/    |
                    ----/             \----
                    

                    Which probably underlines pretty well your point. :) Question is that is there anyway to tackle this when using emonlib?

                    YveauxY Offline
                    YveauxY Offline
                    Yveaux
                    Mod
                    wrote on last edited by
                    #12

                    @Sushukka said in ACS712 strange values when measuring 3D printer power consumption:

                                    /|
                                   / |
                                  |   \
                          /------/    |
                    ----/             \----
                    

                    Cool ASCII-art :+1: Next time you could just attach a screenshot :hatched_chick:

                    I had a quick look at emonlib and it appears to measure the true RMS value; it takes a number of samples and sums the squared values: https://github.com/openenergymonitor/EmonLib/blob/master/EmonLib.cpp#L187
                    It is designed for specific hardware and applies some correction that might not match your sensor.
                    On the other hand, if your other (resistive) loads match the reference power meter the algorithm seems to work ;-)

                    Did you consider that your power meter could be off for reactive loads? :confused:

                    http://yveaux.blogspot.nl

                    SushukkaS 1 Reply Last reply
                    1
                    • YveauxY Yveaux

                      @Sushukka said in ACS712 strange values when measuring 3D printer power consumption:

                                      /|
                                     / |
                                    |   \
                            /------/    |
                      ----/             \----
                      

                      Cool ASCII-art :+1: Next time you could just attach a screenshot :hatched_chick:

                      I had a quick look at emonlib and it appears to measure the true RMS value; it takes a number of samples and sums the squared values: https://github.com/openenergymonitor/EmonLib/blob/master/EmonLib.cpp#L187
                      It is designed for specific hardware and applies some correction that might not match your sensor.
                      On the other hand, if your other (resistive) loads match the reference power meter the algorithm seems to work ;-)

                      Did you consider that your power meter could be off for reactive loads? :confused:

                      SushukkaS Offline
                      SushukkaS Offline
                      Sushukka
                      wrote on last edited by Sushukka
                      #13

                      @Yveaux ASCII art + SID music ftw. :) I played around with the sampling time (changed from 1480 to 3000/6000):

                      double Irms = emon1.calcIrms(6000)
                      

                      Now the values are pretty close together. Still had to manually do the zero load subtraction (around 30W) but after that ACS712 shows surprisingly accurate values even for low 10/20W loads. Now it seems that when Prusa is heating up I get constantly around 100W higher values than I should. But when I turn the Kossel or hair dryer on = adding load to the same line, the Prusa crap seems to fitted in (or filled in) so that the total load seems to be accurate. My "reference" power meter could be off for reactive loads, but not this much and moreover Prusa's power supply is around 200W and I get 300W readings from ACS712.

                      Anyway, I think I'll take the "so be it" step now and just have to live with the fact that Prusa will skew my power readings a bit. Usually there will be some other load in the same line so it should be partly corrected by that. Your help @Yveaux was pretty useful and I thank you for that. :) Also I usually have trusted to some homemade power calculation algorithms because OpenEnergyMonitor is so heavily based on CT3 but as I now saw how much better accuracy its algorithms give I'm going to switch in to that in future projects.

                      1 Reply Last reply
                      1
                      • SushukkaS Sushukka

                        I have only one line going through ACS712 and then its splitted to multiple outlets with extension cord. First I though that my 20A ACS712 is actually only 5A one, but same problem happes with the second ACS712 20A. Also even 5A should be able to measure this load as Prusa's maximum intake is around 180W.
                        Maybe it has something to do with the power factor, dunno. Now I have anyway managed to pinpoint the problem to 3D printers. When plugging only Arduino+ACS712+Prusa MK2 to the wall, ACS712 shows around 690W loads when the Prusa's maximum is about 180W as mentioned above. My old faithful hair dryer power consumption is measured correctly (430W, 820W, 1400W).

                        M Offline
                        M Offline
                        moreau1991
                        wrote on last edited by
                        #14

                        @Sushukka thanks for sharing!

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        28

                        Online

                        11.7k

                        Users

                        11.2k

                        Topics

                        113.1k

                        Posts


                        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • MySensors
                        • OpenHardware.io
                        • Categories
                        • Recent
                        • Tags
                        • Popular