Announcement

Collapse
No announcement yet.

uLCD32PTU & Arduino YUN

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • uLCD32PTU & Arduino YUN

    ]I'm setting up a clock/weather station project and want to use my display to show some of the info. I've been trying to get info to the screen via SoftwareSerial but the screen just goes blank & nothing appears in the serial monitor. I can print to the screen in serial mode using an UNO, the difficulty seems to be with the YUN

    Can anyone give me some pointers please

    Code:
    //#include <AltSoftSerial.h>
    #include <SoftwareSerial.h>
    
    #include <Picaso_Const4D.h>
    #include <Picaso_Serial_4DLib.h>
    
    
    #include <DS3231.h>
    
    //AltSoftSerial DisplaySerial(0, 1);
    SoftwareSerial DisplaySerial(0, 1);
    
    //Init the DS3231 using the hardware interface
    DS3231  rtc(SDA, SCL);
    
    void setup(){
      
    
    Picaso_Serial_4DLib Display(&DisplaySerial);
    
    //For handling errors
    Display.Callback4D = mycallback ;
      
    //5 second timeout on all commands  
    Display.TimeLimit4D   = 5000 ;
    
    // Setup Serial connection
    DisplaySerial.begin(115200);
    
    //If using jumper wires, reverse the logic states below.
    //Refer to the accompanying application note for important information.
      //pinMode(4, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
      //digitalWrite(4, 0);  // Reset the Display via D4
      //delay(100);
      //digitalWrite(4, 1);  // unReset the Display via D4
    
    delay (5000);
    
    Display.gfx_Cls();
    
    Display.gfx_ScreenMode(LANDSCAPE);
    
    //Display.txt_MoveCursor(1,1);
      
      // Initialize the rtc object
      rtc.begin();
    
      // The following lines can be uncommented to set the date and time
      //rtc.setDOW(SATURDAY);     // Set Day-of-Week to SUNDAY
      //rtc.setTime(17,20, 0);     // Set the time to 12:00:00 (24hr format)
      //rtc.setDate(26, 1, 2019);   // Set the date to January 1st, 2014
    }
    
    void loop()
    {
    
    
    // Send Day-of-Week
    //Display.println(rtc.getDOWStr());
    
      // Send date
      
    DisplaySerial.println("Date ");
    
    DisplaySerial.println(rtc.getDateStr());
    
      // Send time
    
    DisplaySerial.println("Time ");
    
    DisplaySerial.println(rtc.getTimeStr());
    
    
      // Wait one second before repeating :)
      delay (1000);
    }
    
    
    void mycallback(int ErrCode, unsigned char Errorbyte)
    {
      // Pin 13 has an LED connected on most Arduino boards. Just give it a name
      int led = 13;
      pinMode(led, OUTPUT);
      while(1)
      {
        digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
        delay(200);                // wait for 200 ms
        digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
        delay(200);                // wait for 200 ms
      }
    }

  • #2
    Hello,

    Have you tried using other pins to communicate with the display?

    Based on the Arduino Yun Reference page:

    ...Digital pins 0 and 1 are used for serial communication between the 32U4 and the AR9331.
    ...Pins 0 and 1 should be avoided as they are used by the Bridge library.
    I hope this helps.

    Best regards,
    Last edited by michael_4D; 9th February 2019, 10:13 AM.
    Michael

    Comment


    • #3
      Hi Michael

      Thanks for you're reply. The quick answer is yes, I've tried pins 2 & 3, however, maybe not with as many code experiments as I have with 0 & 1. I'm going to go back to an UNO and experiment with different pins and SoftwareSerial before going back to the YUN. Pins 0 & 1 have been fine with other displays (using SoftwareSerial) .

      I'll let you know what happens...

      Dougie

      Comment


      • #4
        Hi Michael

        After going back to the UNO I found a few mistakes in the code that stopped the display from working as I expected. I have now corrected those and have a working sketch, at least on the UNO.

        I have ensured that the pins for SoftwareSerial are declared in the options for the board in Workshop 4D

        The code below works perfectly well on the UNO.

        Code:
        // The code for setting the DS3231 up is used courtesy of... 
        // Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
        // web: http://www.RinkyDinkElectronics.com/
        
        #include <SoftwareSerial.h>
        #include <Picaso_Const4D.h>
        #include <Picaso_Serial_4DLib.h>
        #include <DS3231.h>
        
        SoftwareSerial DisplaySerial(2,3);
        
        //Init the DS3231 using the hardware interface
        DS3231  rtc(SDA, SCL); //SDA is A4 & SDA is A5 - UNO
        
        Picaso_Serial_4DLib Display(&DisplaySerial);
        
        void setup(){
        
        //5 second timeout on all commands  
        Display.TimeLimit4D   = 5000 ;
        
        // Setup Serial connection
        DisplaySerial.begin(115200);
        
        //If using jumper wires, reverse the logic states below.
        //Refer to the accompanying application note for important information.
          //pinMode(4, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
          //digitalWrite(4, 0);  // Reset the Display via D4
          //delay(100);
          //digitalWrite(4, 1);  // unReset the Display via D4
        
        delay (5000);
        
        Display.gfx_Cls();
        
        Display.gfx_ScreenMode(LANDSCAPE);
          
          // Initialize the rtc object
        rtc.begin();
        
          // The following lines can be uncommented to set the date and time
          //rtc.setDOW(SATURDAY);     // Set Day-of-Week to SUNDAY
          //rtc.setTime(17,20, 0);     // Set the time to 12:00:00 (24hr format)
          //rtc.setDate(26, 1, 2019);   // Set the date to January 1st, 2014
        }
        
        void loop()
        {
        
        // Send Day-of-Week
        //Display.println(rtc.getDOWStr());
        
          // Send date
        
        Display.txt_MoveCursor(1,1);
        
        Display.print("Date  ");
        
        Display.println(rtc.getDateStr());
        
        Display.println("");
          
          // Send time
        
        Display.print("Time  ");
        
        Display.println(rtc.getTimeStr());
        
          // Wait one second before repeating :)
          delay (1000);
        }

        Comment


        • #5
          I've made a couple of changes for the YUN, for some reason it wouldn't see pins 2 & 3, changing to 6 & 7 made a difference. I started to see the word DATE appear a letter at a time with 5 seconds in between each letter appearing so I commented out the line Display.TimeLimit4D = 5000 ; I also went back to Workshop 4D & put the baud up to 200000. This made all the difference and the code now works on the YUN as expected. Now I need to start pulling in weather data to display & get the screen to sleep after a set period and wake up with a touch if that's possible.

          Hopefully this may be off use to someone who wants to use the display as a serial slave with the YUN, there's not a lot of help out there with this board & 4D displays.

          Code:
          // The code for setting the DS3231 up belongs to 
          // Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
          // web: http://www.RinkyDinkElectronics.com/
          
          #include <SoftwareSerial.h>
          #include <Picaso_Const4D.h>
          #include <Picaso_Serial_4DLib.h>
          #include <DS3231.h>
          
          SoftwareSerial DisplaySerial(6,7);
          
          //Init the DS3231 using the hardware interface
          DS3231  rtc(SDA, SCL); //SDA is A4 & SDA is A5 - UNO
          
          Picaso_Serial_4DLib Display(&DisplaySerial);
          
          void setup(){
          
          //5 second timeout on all commands  
          //Display.TimeLimit4D   = 5000 ;
          
          // Setup Serial connection
          DisplaySerial.begin(200000);
          
          //If using jumper wires, reverse the logic states below.
          //Refer to the accompanying application note for important information.
            //pinMode(4, OUTPUT);  // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
            //digitalWrite(4, 0);  // Reset the Display via D4
            //delay(100);
            //digitalWrite(4, 1);  // unReset the Display via D4
          
          delay (5000);
          
          Display.gfx_Cls();
          
          rtc.begin();
          
          Display.gfx_ScreenMode(LANDSCAPE);
            
            // Initialize the rtc object
          
          
            // The following lines can be uncommented to set the date and time
            //rtc.setDOW(SATURDAY);     // Set Day-of-Week to SUNDAY
            //rtc.setTime(14,58, 0);     // Set the time to 12:00:00 (24hr format)
            //rtc.setDate(9, 2, 2019);   // Set the date to January 1st, 2014
          }
          
          void loop()
          {
          
          // Send Day-of-Week
          //Display.println(rtc.getDOWStr());
          
            // Send date
          
          Display.txt_MoveCursor(1,1);
          
          Display.print("Date  ");
          
          Display.println(rtc.getDateStr());
          
          Display.println("");
            
            // Send time
          
          Display.print("Time  ");
          
          Display.println(rtc.getTimeStr());
          
            // Wait one second before repeating :)
            delay (1000);
          }

          Comment


          • #6
            Have you seen this thread back from 2015?

            https://forum.4dsystems.com.au/node/47093

            Regards
            James

            Comment


            • #7
              Hi James

              Thanks for replying, I hadn't seen that thread. I am using 200000 baud after reading the Workshop4 > Options > Serial Tab. I'll test 19200 baud though as I've just added an indoor DHT sensor to the mix & am now planning to add an outdoor remote sensor as well which may clog up communication, although I may switch to a DUE when I do that.

              Can you point me to any threads that show some sleep/wake code related to serial comms rather than VISI code? I am searching but there's a lot to get through. I would like the display to sleep after a set period but wake with a touch.

              All the best

              Dougie

              Comment


              • #8
                Hello Dougie,

                Can you point me to any threads that show some sleep/wake code related to serial comms rather than VISI code? I am searching but there's a lot to get through. I would like the display to sleep after a set period but wake with a touch.
                May I know what you want to achieve with the sleep mode?

                If you just want to turn off the display's backlight, you could do that with this
                Code:
                Display.gfx_Contrast(0);
                It should look something like this:

                Code:
                if (Display.touch_Get(TOUCH_STATUS) == TOUCH_PRESSED ||Display.touch_Get(TOUCH_STATUS) == TOUCH_MOVING){
                 <reset the timer value>
                 <Do other stuff>
                 if (off_Flag == 1){
                    Display.gfx_Contrast(1);
                    off_Flag = 0;
                }
                } else{
                <update timer value>
                 if (timervalue == preset_time){
                    Display.gfx_Contrast(0);    
                    off_Flag = 1;
                }
                }
                I hope this helps.

                Best regards,
                Michael

                Comment


                • #9
                  Hi Michael

                  Thanks for that, I'll give it a try. I just wanted the option of having the display off when not required.

                  All the best

                  Dougie

                  Comment

                  Working...
                  X