12 Replies Latest reply on Jul 15, 2015 11:54 AM by neuberfran

    sketch all right in arduino uno with error on the intel edison

    neuberfran

      erro29.png

      int Rele1 = 7;

      const int sensorPin = A0;

      float sensorValue_aux = 0;

      float sensorValue = 0;

      float currentValue = 0;

      float voltsporUnidade = 0.0048828125;

       

       

      int st_rl = 0;

      // String st_lamp = '0';

      String st_lamp =  String('0');                       // converting a constant char into a String

       

       

       

       

      void setup(){

        pinMode(Rele1,OUTPUT);

        Serial.begin(9600);

      }

       

       

      void loop(){

        char c = Serial.read();

       

       

      for(int i=500; i>0; i--)

      {

      sensorValue_aux = (analogRead(sensorPin) -511); // le o sensor na pino analogico A0 e ajusta o valor lido ja que a saída do sensor é vcc/2 para corrente =0

      sensorValue += pow(sensorValue_aux,2); // soam os quadardos das leituras no laco

      }

       

      sensorValue = (sqrt(sensorValue/ 500)) * voltsporUnidade; // finaliza o calculo da méida quadratica e ajusta o valor lido para volts

      currentValue = (sensorValue/66)*1000; // calcula a corrente considerando a sensibilidade do sernsor (66 mV por amper)

       

       

       

      if (currentValue < 0.10){

        st_lamp = "Lampada apagada";

      }else{

        st_lamp = "Lampada ligada";

      }

       

       

        if (c == 's'){

          Serial.print ("Valor do st: ");

          Serial.print (st_rl);

          Serial.print (" Corrente: ");

          Serial.print (currentValue);

          Serial.print (" Status da lampada:  ");

          Serial.println (st_lamp);

        }

        if (c == 'a'){

          if (st_rl == 0){

            digitalWrite(Rele1, HIGH);

            Serial.print ("Valor anterior do st: ");

            Serial.print (st_rl);

            Serial.print (" Status anterior da lampada:  ");

            Serial.print (st_lamp);

            st_rl = 1;

            Serial.print (" Valor do st mudado para: ");

            Serial.print (st_rl);

            Serial.print (" Status atual da lampada:  ");

            Serial.println (st_lamp);

          }

          else{

            digitalWrite(Rele1, LOW);

            Serial.print ("Valor do st: ");

            Serial.print (st_rl);

            st_rl = 0;

            Serial.print (" Valor do st mudado para: ");

            Serial.print (st_rl);

            Serial.print (" Status da Lampada: ");

            Serial.println (st_lamp);

          }

        }

       

       

            Serial.print (" Status atual da lampada:  ");

            Serial.println (st_lamp);

             delay(5000);

       

       

      }

        • 1. Re: sketch all right in arduino uno with error on the intel edison
          CMata_Intel

          Hi neuberfran

           

          In the image you have attached, it seems that the arduino IDE is able to compile the code because of the line:

          Sketch uses 80,282 bytes (0%) of program storage space. Maximum is 10,000,000 bytes.

           

          Are you having issues while uploading the code? or is a problem with the functionality of it (the code is not doing what it should)?

           

          Regards;

          CMata

          • 3. Re: sketch all right in arduino uno with error on the intel edison
            CMata_Intel

            Hi neuberfran

             

            The link you posted: Re: ACtion regenerating makefile is about the XDK IDE.

            What is the status with the Arduino IDE? Are you able to successfully upload the code to the board? Are you getting a Transfer complete message at the end of the log when you click on Upload?

             

            You should see something like this:

            Capture.JPG

             

            Regards;

            CMata

            • 4. Re: sketch all right in arduino uno with error on the intel edison
              neuberfran

              CMata_Intel

               

               

              #include <Wire.h>

              #include <rgb_lcd.h>

               

              int Rele1 = 7;

               

              float sensorPin = analogRead(A0);

               

              float sensorValue_aux = 0;

               

              float sensorValue = 0;

               

              float currentValue = 0;

               

              float voltsporUnidade = 0.0048828125;

               

              bool ledStatus = false;

               

              rgb_lcd lcd;

               

               

              int st_rl = 0;

               

              // String st_lamp = '0';

               

              String st_lamp =  String('0');                       // converting a constant char into a String

               

               

              void setup(){

               

                pinMode(Rele1,OUTPUT);

               

                Serial.begin(9600);

               

                // set up the LCD's number of columns and rows:

                lcd.begin(16, 2);

                lcd.setRGB(0,0,0);

                // Print a message to the LCD.

                lcd.print("Estado:");

               

                delay (1000);

               

              }

               

              float k = analogRead(sensorPin);

               

              void loop(){

               

                char c = Serial.read();

               

                Serial.print (" Analogica: ");

               

                Serial.print (k);

               

              for(int i=500; i>0; i--)

               

              {

               

              // int sensorPin = analogRead(A0); 

               

              sensorValue_aux = (analogRead(A0) -511); // le o sensor na pino analogico A0 e ajusta o valor lido ja que a saída do sensor é vcc/2 para corrente =0

               

              sensorValue += pow(sensorValue_aux,2); // soam os quadardos das leituras no laco

               

              }

               

              sensorValue = (sqrt(sensorValue/ 500)) * voltsporUnidade; // finaliza o calculo da méida quadratica e ajusta o valor lido para volts

               

              currentValue = (sensorValue/66)*1000; // calcula a corrente considerando a sensibilidade do sernsor (66 mV por amper)

               

              Serial.print (currentValue);

               

               

              if (currentValue < 0.10){

               

                st_lamp = "Lampada apagada";

               

              }else{

               

                st_lamp = "Lampada ligada";

               

              }

               

                if (c == 's'){

               

                  Serial.print ("Valor do st: ");

               

                  Serial.print (st_rl);

               

                  Serial.print (" Corrente: ");

               

                  Serial.print (currentValue);

               

                  Serial.print (" Status da lampada:  ");

               

                  Serial.println (st_lamp);

               

                }

               

                if (c == 'a'){

               

                  if (st_rl == 0){

               

                    digitalWrite(Rele1, HIGH);

               

                    Serial.print ("Valor anterior do st: ");

               

                    Serial.print (st_rl);

               

                    Serial.print (" Status anterior da lampada:  ");

               

                    Serial.print (st_lamp);

               

                    st_rl = 1;

               

                    Serial.print (" Valor do st mudado para: ");

               

                    Serial.print (st_rl);

               

                    Serial.print (" Status atual da lampada:  ");

               

                    Serial.println (st_lamp);

               

                  }

               

                  else{

               

                    digitalWrite(Rele1, LOW);

               

                    Serial.print ("Valor do st: ");

               

                    Serial.print (st_rl);

               

                    st_rl = 0;

               

                    Serial.print (" Valor do st mudado para: ");

               

                    Serial.print (st_rl);

               

                    Serial.print (" Status da Lampada: ");

               

                    Serial.println (st_lamp);

                  

               

                  }

               

                }

               

                    Serial.print (" Status atual da lampada:  ");

               

                   Serial.println (st_lamp);

               

                   // Serial.println (sensorPin);

               

                     delay(5000);

               

                     lcd.setCursor(0, 1);

                     lcd.print("                ");

                     lcd.setRGB(0,0,ledStatus?255:00);

                     lcd.setCursor(0, 1);

                     lcd.print(st_lamp);

               

               

              }

               

              I change the code and now is ok. But have a logic problem

              gimp1.xcfgimp2.xcf

              • 6. Re: sketch all right in arduino uno with error on the intel edison
                neuberfran

                I said yesterday: "But have a logic problem"

                 

                "I change the code and now is ok. But have a logic problem"

                 

                convert ac current negative of the acs712 to display in LCD

                 

                help this

                • 7. Re: sketch all right in arduino uno with error on the intel edison
                  CMata_Intel

                  Hi neuberfran,

                   

                  What is the logic problem you are getting?

                  A good way to start troubleshooting this is to measure with a tester the AC current and check the output you are obtaining in the Arduino IDE. With this you will be able to debug the code and where is the error, you could try changing the equation of the conversion from the sensor to the decimal value.

                   

                  Regards,

                  Charlie

                  • 8. Re: sketch all right in arduino uno with error on the intel edison
                    neuberfran

                    In arduino IDE in ubuntu I have almost success with this code

                     

                    https://forum.arduino.cc/index.php?topic=179541.0

                     

                    const int currentPin = 3;

                    const unsigned long sampleTime = 100000UL;                           // sample over 100ms, it is an exact number of cycles for both 50Hz and 60Hz mains

                    const unsigned long numSamples = 250UL;                               // choose the number of samples to divide sampleTime exactly, but low enough for the ADC to keep up

                    const unsigned long sampleInterval = sampleTime/numSamples;  // the sampling interval, must be longer than then ADC conversion time

                    const int adc_zero = 510;                                                     // relative digital zero of the arudino input from ACS712 (could make this a variable and auto-adjust it)

                     

                    void setup()

                    {

                    Serial.begin(9600);

                    }

                     

                    void loop()

                    {

                    unsigned long currentAcc = 0;

                    unsigned int count = 0;

                    unsigned long prevMicros = micros() - sampleInterval ;

                    while (count < numSamples)

                    {

                       if (micros() - prevMicros >= sampleInterval)

                       {

                         int adc_raw = analogRead(currentPin) - adc_zero;

                         currentAcc += (unsigned long)(adc_raw * adc_raw);

                         ++count;

                         prevMicros += sampleInterval;

                       }

                    }

                     

                    float rms = sqrt((float)currentAcc/(float)numSamples) * (75.7576 / 1024.0);

                    Serial.println(rms);

                    }

                    in arduino IDE in windows 8.1 I have problem with monitor


                    If you see a code it's quotes 1024. I tried change this to 4096 (because intel edison breakboard has 12-bit adc channel - 2^12= 4096 and not 2^10 (arduino 10 bit adc) = 1024), but don't work for me


                     


                    • 9. Re: sketch all right in arduino uno with error on the intel edison
                      CMata_Intel

                      Hi neuberfran,

                       

                      Let's continue this in Measure AC current with ACS712 30A and javascript(node.js). Also, is the same outcome while using Ubuntu and Windows?

                      Do you have better results using the line:

                      float rms = sqrt((float)currentAcc/(float)numSamples);  // Without  * (75.7576 / 1024.0)
                      

                       

                      Regards,

                      Charlie

                      • 10. Re: sketch all right in arduino uno with error on the intel edison
                        neuberfran

                        OK. Yes we can continue there. They are the same (windows 8.1 and ubuntu). Except tha in windows I can't use option monitor

                        to see voltages directly in the screen.

                         

                        Now I will try this :

                        float rms = sqrt((float)currentAcc/(float)numSamples);  // Without  * (75.7576 / 1024.0)


                        What about this:

                        Re: ACtion regenerating makefile

                        • 11. Re: sketch all right in arduino uno with error on the intel edison
                          neuberfran

                          This topic is solved.(without 75.75) Except in 1 momentunnamed (1).png

                          Now We can try in javascript.