7 Replies Latest reply on Jul 28, 2015 4:01 PM by PabloM_Intel

    Arduino analogRead strange values on Edison Arduino Breakout board

    stefDSC

      Hi,

       

      The Arduino AnalogReadSerial example works fine on my Arduino Uno/Ethernet boards (0-1023 values), but when I run it on my Edison kit with Arduino Breakout, the analogRead(A0) values are at ~500 for 5V and ~78 for 0V, there is also significant lag. Any ideas?

       

       

      Thanks,

      Stefan

        • 1. Re: Arduino analogRead strange values on Edison Arduino Breakout board
          PabloM_Intel

          Hi stefDSC,

           

          That’s interesting, I just run the same example and my results seem to be good (0-1023) with no significant lag.

           

          Could you please tell me what image are you using in your Edison and in which position are the J8 (reference) and J9 (3.3-5V) jumpers in your board?

           

          You can also try to add 5V directly and see what is shown in the serial monitor; same for 3.3V and 0V.

           

          Regards,

          PabloM_Intel

          • 2. Re: Arduino analogRead strange values on Edison Arduino Breakout board
            stefDSC

            Hi Pablo,

             

            Thanks for getting back to me. I have image 146 and J8 and J9 are both in the default position (closer to center of board).

             

            I added both 5V and GND directly to A0 (and A5 on a pin change) via jumper and the results matched the limits of the pot. I also got the same results with a second Edison that I tried. The code from the Arduino worked when I uploaded to an Aduino Uno, but did not work when I uploaded to the Edison.

             

            Thanks,

            Stefan

            • 3. Re: Arduino analogRead strange values on Edison Arduino Breakout board
              stefDSC

              Hi Pablo,

               

              I just retried the example again and now A0 is reading correctly. I was using a pretty simple piece of code, but something must have caused a conflict. The example works.

               

              Thanks for your help,

               

              Stefan

              • 4. Re: Arduino analogRead strange values on Edison Arduino Breakout board
                stefDSC

                Hi Pablo,

                 

                 

                Sorry to bother you again, but I'm stuck again on another Arduino example. The Servo example runs fine on my Uno, but I'm not getting any movement at my motor when using the Edison. I tried pins 3, 5 and 9, which I believe are all capable of PWM. Do I need to set these pins somehow?

                 

                Here's the Arduino code:

                // Controlling a servo position using a potentiometer (variable resistor)
                // by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

                #include <Servo.h>

                Servo myservo;  // create servo object to control a servo

                int potpin = 0;  // analog pin used to connect the potentiometer
                int val;    // variable to read the value from the analog pin

                void setup()
                {
                  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
                }

                void loop()
                {
                  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
                  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
                  myservo.write(val);                  // sets the servo position according to the scaled value
                  delay(15);                           // waits for the servo to get there
                }

                • 5. Re: Arduino analogRead strange values on Edison Arduino Breakout board
                  PabloM_Intel

                  Hi stefDSC,

                   

                  Do you remember if you did anything specific in the first example (AnalogRead) to make it work? Also, could you please tell me what COM port are you using when selecting the Port from the Arduino IDE?

                   

                  Regards,

                  PabloM_Intel

                  • 6. Re: Arduino analogRead strange values on Edison Arduino Breakout board
                    stefDSC

                    Pablo,

                     

                    I went back and used the bare-bones example. I think there may somehow have been an issues with the libraries not working together. I had referenced SPI.h, WiFi.h, Ethernet.h, EthernetUpd.h, and Servo.h, when I commented out SPI, Ethernet and EthernetUpd, analogRead started working correctly. I haven't gone back and tracked down the cause yet. I think analogRead may have also worked with Ethernet.h not commented out.

                     

                    I was able to get the servo working, I found that part of my issue had do with the differences in the Edison board and Arduino board. On Arduino, I was able to drive my motor from Vin, but am not able to get power out of Vin on the Edison, I needed to break power directly from the power cable.

                     

                    Lastly, I also had an issue connecting WiFi to an unprotected host. It appears that in the WiFi library, the wpa_supplicant is turned off when a password is not required.

                     

                     

                    Thanks,

                    Stefan

                    .


                    • 7. Re: Arduino analogRead strange values on Edison Arduino Breakout board
                      PabloM_Intel

                      Hi stefDSC,

                       

                      Sorry for the late reply. Were you able to connect your WiFi to an unprotected host? Did you use ‘systemctl enable wpa_supplicant’ to turn it on? If you want to check some more information about wpa_supplicant you can follow the next link http://download.intel.com/support/edison/sb/edison_wifi_331438001.pdf.

                       

                      Regards,

                      PabloM_Intel