6 Replies Latest reply on Dec 1, 2017 3:02 PM by Intel Corporation

    SD.h and SPI.h conflitcs with Time.h Intel Edison with Arduino

    edubay95

      Hi!

       

      I have use the SD.h librarie to save the data receive of a sensor of temperature with Arduino. It works well.

      The problem comes when I try to use the libraries Time.h and TimeLib.h to indicate the time when was read the temperature. For any reason it give me the next error:

       

      Arduino:1.8.5 (Windows 10), Tarjeta:"Intel® Edison"

       

      In file included from C:\Users\Eduardo\AppData\Local\Arduino15\packages\Intel\tools\core2-32-poky-linux\1.6.2+1.0/core2-32-poky-linux/usr/include/fcntl.h:68:0,

                       from C:\Users\Eduardo\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\SD\src\SD.cpp:27:

       

      C:\Users\Eduardo\AppData\Local\Arduino15\packages\Intel\tools\core2-32-poky-linux\1.6.2+1.0/core2-32-poky-linux/usr/include/bits/stat.h:91:21: error: field 'st_atim' has incomplete type

           struct timespec st_atim;  /* Time of last access.  */

                           ^

      C:\Users\Eduardo\AppData\Local\Arduino15\packages\Intel\tools\core2-32-poky-linux\1.6.2+1.0/core2-32-poky-linux/usr/include/bits/stat.h:92:21: error: field 'st_mtim' has incomplete type

           struct timespec st_mtim;  /* Time of last modification.  */

                           ^

      C:\Users\Eduardo\AppData\Local\Arduino15\packages\Intel\tools\core2-32-poky-linux\1.6.2+1.0/core2-32-poky-linux/usr/include/bits/stat.h:93:21: error: field 'st_ctim' has incomplete type

           struct timespec st_ctim;  /* Time of last status change.  */

                           ^

      C:\Users\Eduardo\AppData\Local\Arduino15\packages\Intel\tools\core2-32-poky-linux\1.6.2+1.0/core2-32-poky-linux/usr/include/bits/stat.h:152:21: error: field 'st_atim' has incomplete type

           struct timespec st_atim;  /* Time of last access.  */

                           ^

      C:\Users\Eduardo\AppData\Local\Arduino15\packages\Intel\tools\core2-32-poky-linux\1.6.2+1.0/core2-32-poky-linux/usr/include/bits/stat.h:153:21: error: field 'st_mtim' has incomplete type

           struct timespec st_mtim;  /* Time of last modification.  */

                           ^

      C:\Users\Eduardo\AppData\Local\Arduino15\packages\Intel\tools\core2-32-poky-linux\1.6.2+1.0/core2-32-poky-linux/usr/include/bits/stat.h:154:21: error: field 'st_ctim' has incomplete type

           struct timespec st_ctim;  /* Time of last status change.  */

                           ^

      Se encontraron múltiples librerías para "SD.h"

      Usado: C:\Users\Eduardo\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\SD

      No usado: C:\Programas descargados\Arduino\libraries\SD

      exit status 1

      Error compilando para la tarjeta Intel® Edison.

       

       

      If I use libraries separately they work well.

       

      Please, HELP   

        • 1. Re: SD.h and SPI.h conflitcs with Time.h Intel Edison with Arduino
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello Eduardo,

          Thank you for contacting Intel Technical Support.
          Your request has been received and is currently being investigated. 
          We will get back to you as soon as possible.

          Regards,
          Octavian

          • 2. Re: SD.h and SPI.h conflitcs with Time.h Intel Edison with Arduino
            Intel Corporation
            This message was posted on behalf of Intel Corporation

            Hello Eduardo,

            Thank you for your patience.
            The time.h library is not compatible with the Arduino-intel IDE unfortunately. 

            As a workaround , please follow the steps in this article to get you set. https://communities.intel.com/thread/57023

            Hope this helps.

            Regards,
            Octavian

            • 3. Re: SD.h and SPI.h conflitcs with Time.h Intel Edison with Arduino
              edubay95

              But if I use Time.h and TimeLib.h libraries it works well. So they are compatible ~~

              When it's no compatible is when works with SD.h or SPI.h libraries.

              #include <LiquidCrystal.h>
              //#include <time.h>
              #include <Time.h>
              #include <TimeLib.h>
              
              
              
              
              const int rs = 7, en = 8, d4 = 9, d5 = 10, d6 = 11, d7 = 12;
              LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
              
              
              byte enie[8] =
              {
                0b00001110,
                0b00000000,
                0b00010110,
                0b00011001,
                0b00010001,
                0b00010001,
                0b00010001,
                0b00000000
              };
              
              
              #define PULSCORTA 0
              #define PULSLARGA 1
              #define pinpuls1 4
              #define pinpuls2 5
              #define pinpuls3 6
              #define pinluz 2
              
              
              bool luz = HIGH, MODOAJUSTE = 1;
              int puls1, puls2, puls3;
              int parametro;
              
              
              int valor[6] = {0, 0, 0, 1, 1, 0};
              int maxim[6] = {23, 59, 59, 31, 12, 99};
              int minim[6] = {0, 0, 0, 1, 1, 0};
              
              
              char fecha[50];
              char hhora[50];
              
              
              void setup() {
              
              
                Serial.begin(9600);
              
              
                pinMode(pinpuls1, INPUT_PULLUP); //Interruptor 1 . Activo a 0 por Pullup
                pinMode(pinpuls2, INPUT_PULLUP); //Interruptor 1 . Activo a 0 por Pullup
                pinMode(pinpuls3, INPUT_PULLUP); //Interruptor 1 . Activo a 0 por Pullup
                pinMode(pinluz, OUTPUT);
              
              
                lcd.begin(16, 2);
                lcd.createChar(0, enie);
                lcd.setCursor(0, 0);
                
                digitalWrite(pinluz, luz);
                Serial.println("Establece la hora y fecha (h:m:s d/m/a)");
                Serial.println("Hora: ");
                lcd.print("Hora:");
              
              
              }
              
              
              void loop() {
              
              
                while (MODOAJUSTE) {
              
              
                  //INICIO PULSADOR 1
                  if (digitalRead(pinpuls1) == LOW) {
                    puls1 = leer_pulsador(pinpuls1);
                    if (puls1 == PULSCORTA) {
                      parametro++;
                      if (parametro > 5)
                        parametro = 0;
                      conversion(parametro);
                      puls1 = 2; //se ajusta para que no interfiera en el resto de los if
                    }
                    if (puls1 == PULSLARGA) {
                      Serial.println("Cambio luz e inicializo a ");
                      parametro = 0;
                      conversion(parametro);
                      if (luz == 1) {
                        luz = !luz;
                        digitalWrite(pinluz, luz);
                      } else if (luz == 0) {
                        luz = !luz;
                        digitalWrite(pinluz, luz);
                      }
                      puls1 = 2; //se ajusta para que no interfiera en el resto de los if
                    }
                    delay(300);
                  }
                  //FIN PULSADOR 1
              
              
                  //INICIO PULSADOR 2
                  if (digitalRead(pinpuls2) == LOW) {
                    puls2 = leer_pulsador(pinpuls2);
                    if (puls2 == PULSCORTA) {
                      valor[parametro]++; //Aumento 1
                      if (valor[parametro] > maxim[parametro])
                        valor[parametro] = minim[parametro];
                      imprimir_valor(valor);
                      puls2 = 2; //se ajusta para que no interfiera en el resto de los if
                    }
                    delay(200);
                  }
              
              
                  //FIN PULSADOR 2
              
              
                  //INICIO PULSADOR 3
                  if (digitalRead(pinpuls3) == LOW) {
                    puls3 = leer_pulsador(pinpuls3);
                    if (puls3 == PULSCORTA) {
                      valor[parametro]--; //Disminuyo 1
                      if (valor[parametro] < minim[parametro])
                        valor[parametro] = maxim[parametro];
                      imprimir_valor(valor);
                      puls3 = 2; //se ajusta para que no interfiera en el resto de los if
                    }
                    delay(300);
                  }
                  if (puls3 == PULSLARGA) {
                    Serial.println("Guardando valores...");
                    MODOAJUSTE = 0;
                    puls3 = 2; //se ajusta para que no interfiera en el resto de los if
                  }
                  //FIN PULSADOR 3
              
              
                  setTime(valor[0], valor[1], valor[2], valor[3], valor[4], valor[5]);
                }
              
              
                imprimir_fecha();
                delay(2000);
              
              
              }
              
              
              int leer_pulsador(int pin) {
                unsigned long tiempopulsado = millis();
                if (pin == pinpuls1 || pin == pinpuls3) { //Pulsacion larga
                  while (digitalRead(pin) == LOW) {
                    if ((millis() - tiempopulsado) >= 2000) {
                      return 1;
                      break;
                    }
                  }
                }
                //Puslsacion corta
                return 0;
              }
              
              
              
              
              void imprimir_valor(int valor[]) {
              
              
                //lcd.clear();
                lcd.setCursor(10,0);
                if (valor[parametro] < 10) {
                  lcd.print("0");
                  Serial.print("0");
                }
              
              
                lcd.print(valor[parametro]);
                Serial.println(valor[parametro]);
              
              
              }
              
              
              
              
              void imprimir_fecha() {
              
              
                time_t  t = now();
                sprintf(fecha, "%02d/%02d/%04d  ",  day(t), month(t), year(t));
                sprintf(hhora, "%02d:%02d:%02d  ",  hour(t), minute(t), second(t));
                
                Serial.print(fecha);
                Serial.println(hhora);
              
              
                lcd.clear();
                lcd.setCursor(0, 0);
                lcd.print(fecha);
                lcd.setCursor(0, 1);
                lcd.print(hhora);
              
              
              }
              
              
              void conversion(int parametro) {
                lcd.clear();
                lcd.setCursor(0,0);
                switch (parametro) {
                  case 0:
                    Serial.println("Hora: ");
                    lcd.print("Hora:");
                    break;
                  case 1:
                    Serial.println("Minuto: ");
                    lcd.print("Minuto:");
                    break;
                  case 2:
                    Serial.println("Segundo:");
                    lcd.print("Segundo:");
                    break;
                  case 3:
                    Serial.println("Dia:");
                    lcd.print("Dia:");
                    break;
                  case 4:
                    Serial.println("Mes:");
                    lcd.print("Mes:");
                    break;
                  case 5:
                    Serial.println("Año:");
                    lcd.print("A");
                    lcd.write(byte(0));
                    lcd.print("o:");
                    break;
                }
              }
              
              • 4. Re: SD.h and SPI.h conflitcs with Time.h Intel Edison with Arduino
                Intel Corporation
                This message was posted on behalf of Intel Corporation

                Hello Eduardo,

                Thank you for your patience.

                Yes Time.h and TimeLib.h libraries are compatible. What we can notice from the error message is that you have multiple libraries of "SD.h" installed. The problem can be with the Arduino IDE since it is reading the same library in different locations. I would suggest you remove one of the libraries and restart the IDE. 

                Hope this helps.

                Regards,
                Octavian

                • 5. Re: SD.h and SPI.h conflitcs with Time.h Intel Edison with Arduino
                  edubay95

                  I have done what you said, but if I remove one, it gives an error when I compile, and if I remove the other it gives other error ~~

                  I think that a library needs the other...

                  And when I use only the SD.h library (without delete any) its works well

                  • 6. Re: SD.h and SPI.h conflitcs with Time.h Intel Edison with Arduino
                    Intel Corporation
                    This message was posted on behalf of Intel Corporation

                    Hi edubay95, 

                    I have added the error message below, which shows the SD.h library is in two locations. 

                    "Se encontraron múltiples librerías para "SD.h"
                    Usado: C:\Users\Eduardo\AppData\Local\Arduino15\packages\Intel\hardware\i686\1.6.7+1.0\libraries\SD
                    No usado: C:\Programas descargados\Arduino\libraries\SD"

                    The locations are C:\Users\...\libraries\SD and C:\Programas...\libraries\SD. The issue can be that the Arduino IDE is reading two locations for the same library. I'd recommend to remove one of the "SD.h" library path. 
                    Please keep in mind the Arduino IDE is out of our support scope. If you need further assistance with the libraries, please contact Arduino directly. 

                    Regards, 
                    Ezequiel