Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Teensy 3.5... GPS in... 1.5" OLED out... No Display

  1. #1
    Junior Member
    Join Date
    May 2019
    Posts
    4

    Teensy 3.5... GPS in... 1.5" OLED out... No Display

    Originally I had everything working fine with this code (on the bench) using a MEGA; SPI. But the installation in my street rod required a 4 foot run and I soon found out SPI is not happy with that long of a run (garbled display). (Reading GPS stuff has always worked without a hitch). So for the first time I recently ordered a Teensy 3.5 and physically reconfigured such that the Teensy, the GPS, and the OLED are all together as you can see in the image below. The GPS works fine but all I get is a blank screen:

    All 3 are using VSS of 3.3volts. GPS and Display use external power.

    DC 9
    CS 10
    DIN 11
    CLK 13

    (My skillset is somewhere in between 'ignorant' and 'dangerous').

    Thanks for any comments.

    Code:
    Click image for larger version. 
    
    Name:	coupe teensy 1.jpg 
    Views:	28 
    Size:	195.5 KB 
    ID:	16657// ********************************************************************
    
    // Date Written: May ,2019
    // Author: Dave Garner
    // Base code is from  Yvan @ https://Brainy-Bits.com
    // Processor: Teensy 3.5
    // Libraries:
    //   GPS: TinyGPS++
    //   1.5" OLED Display: U8g2lib
    // Input: Adafruit Ultimate GPS
    // Output: 1.5" OLED display
    
    
    
    // This code resides in a Teensy 3.5 in my '36 Chevy Street rod and is used to display the following
    // information:
    // Direction of travel
    // Elevation
    // Direction and distance from/to my home.
    
    // *********************************************************************
    
    #include <TinyGPS++.h>
    TinyGPSPlus gps;
    #include <U8g2lib.h>  // U8g2 Library for Oled https://github.com/olikraus/u8g2
    #include <Math.h>
    
    char CSats[3];
    int  ISats ;
    long IAlt;
    
    
    char CAlt[5];
    char CDis[5];
    int  IDis ;
    char CAngle[4] ="xxx";
    
    const char *cardinalToHome ;
    
    
    
    // static const double Home_LAT = 38.896565, Home_LON = -121.07689;   // test (Aubrun CA)
    
     static const double Home_LAT = 38.652807, Home_LON = -121.153539;   // my home address
    /*
      U8g2 modes:
        Frame Buffer Examples: clearBuffer/sendBuffer. Fast, but may not work with all Arduino boards because of RAM consumption
        Page Buffer Examples: firstPage/nextPage. Less RAM usage, Slower, but should work with all Arduino boards.
        U8x8 Text Only Example: No RAM usage, Fast, but No graphics, 8x8 Text only.
    */
        
    
    // U8g2 Library Full Frame Buffer mode used in this tutorial
     U8G2_SSD1327_MIDAS_128X128_F_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
    
    void setup() {
        Serial.begin(11520);
        Serial.println("---- start -------"); 
        Serial1.begin(9600);
        
        u8g2.begin();  
        u8g2.setContrast(200);  // 0 to 255
    }
    
    
    
    void loop() {  
    delay(500) ;
     Serial.println("------------------ Start Formatting My Stuff 1-----------------");
     
     Serial.print("Serial1.available() ");  Serial.println(Serial1.available());
     while (Serial1.available())
        gps.encode(Serial1.read());
        ISats = gps.satellites.value() ;
        sprintf(CSats, "%02lu",gps.satellites.value());
        Serial.print("satellites.value-=-+");  Serial.println(gps.satellites.value());
        Serial.println("Compass Heading:");
        Serial.println(gps.course.deg());
        const char *cardinalHeading = TinyGPSPlus::cardinal(gps.course.deg()); 
        Serial.print  ("Cardinal Heading-");
        Serial.print  (cardinalHeading);
        Serial.println  ("-");
        Serial.println("Latitude:");
        Serial.println(gps.location.lat(), 6);
        Serial.println("Longitude:");
        Serial.println(gps.location.lng(), 6);
      
        Serial.println("Elevation Feet:");
        Serial.println(gps.altitude.feet());
        IAlt = gps.altitude.feet();    
        sprintf(CAlt, "%4ld" , IAlt);
        Serial.println("");
        unsigned long distanceKmToHome =
        (unsigned long)TinyGPSPlus::distanceBetween(
         gps.location.lat(),
         gps.location.lng(),
         Home_LAT, 
         Home_LON) / 1000;
         distanceKmToHome = distanceKmToHome * 0.621371;
         sprintf(CDis, "%4ld" , distanceKmToHome);
         if ( distanceKmToHome == 0) Serial.println("Home!");
         
         else 
          {      
           sprintf(CDis, "%4lu" , distanceKmToHome);      
           Serial.print(" dist home-");
           Serial.print(CDis);
           Serial.println("-");
           double courseToHome =
           TinyGPSPlus::courseTo(
            gps.location.lat(),
            gps.location.lng(),
            Home_LAT, 
            Home_LON); 
          
            Serial.print(" Heading to home-");
            Serial.print(cardinalHeading);
            Serial.println("-");  
    
            cardinalToHome = TinyGPSPlus::cardinal(courseToHome);  
      
          Serial.print(" cardinalToHome-");
          Serial.print(cardinalToHome);
          Serial.println("-"); 
          }
          if (ISats < 4)
           {
            Serial.print(" No Fix-");
            Serial.println(ISats);
            u8g2.clearBuffer(); 
            u8g2.setFont(u8g2_font_fub14_tr);
            u8g2.drawStr(00, 30, CSats);
            u8g2.setFont(u8g2_font_fub25_tr); 
            u8g2.drawStr(10, 100, "No Fix!");   
            u8g2.sendBuffer(); 
           }
          else
           {
            Serial.print(" Fix!---");
            Serial.println(ISats);
            u8g2.clearBuffer();      
            u8g2.setFont(u8g2_font_fub14_tr);
            u8g2.drawStr(00, 30, CSats);
            u8g2.setFont(u8g2_font_fub25_tr); 
            u8g2.drawStr(25, 60, cardinalHeading);
            u8g2.drawStr(25, 95, CAlt); 
            u8g2.setFont(u8g2_font_fub20_tr);  
            if ( distanceKmToHome == 0) u8g2.drawStr(20, 120, "Home!");   
            else 
             {           
              u8g2.drawStr(00, 120, cardinalToHome);
              u8g2.drawStr(60, 120, CDis);     
             }
            u8g2.sendBuffer();   // Update Oled display   
           }
         }
    Last edited by fatfenders; 05-20-2019 at 04:04 AM.

  2. #2
    Member
    Join Date
    Sep 2015
    Location
    Mechelen, Belgium
    Posts
    21
    Hello,

    Hmm, what speed are you running? Oleds can be very tricky @high speed and the Teensy3.5 is a lot faster than a MEGA.

    Regards, Otto

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,301
    Quote Originally Posted by fatfenders View Post
    But the installation in my street rod required a 4 foot run and I soon found out SPI is not happy with that long of a run (garbled display).
    Wow, 4 feet is a really long run for a high speed protocol like SPI.

    Sometimes adding resistors in series, located close to the Teensy pins, can help the signals travel more cleanly down the long wires. The best resistor value depends on the type of wire. For CAT6 network cable (usually the very best cable that's affordable) a 100 ohm resistor for each signal works best.

    This same issue comes up with addressable LEDs. You can find some good into on the OctoWS2811 page.

    https://www.pjrc.com/teensy/td_libs_OctoWS2811.html

    Scroll down to "Signal Quality".

  4. #4
    Junior Member
    Join Date
    May 2019
    Posts
    4
    Quote Originally Posted by Hersoft View Post
    Hello,

    Hmm, what speed are you running? Oleds can be very tricky @high speed and the Teensy3.5 is a lot faster than a MEGA.

    Regards, Otto
    I don't know how to answer your question "what speed are you running". How do I find that out? How do I change the speed?

  5. #5
    Junior Member
    Join Date
    May 2019
    Posts
    4
    Paul,
    Thanks for responding but as you can tell by my original comments I no longer have that 4' run. You can see in the image the wire runs are now just a couple of inches. I am using 22AWG silicone wire.

  6. #6
    Junior Member
    Join Date
    Jun 2013
    Location
    South Africa
    Posts
    8
    Hey @fatfenders,

    Happened to be looking for other answers when coming across this thread.

    I had exactly a similar issue with a Teensy 3.2 and another I2C OLED on U8g2lib that I couldn't get working. Luckily for me I could set it up for SPI, but it also came up dead!
    After much hunting, frustration and trial & error, I added this to setup()
    Code:
    SPI.begin();
    and it came to life and started working!

    Maybe worth a try if you haven't been able to sort it.

  7. #7
    Junior Member
    Join Date
    May 2019
    Posts
    4
    Leon,
    A somewhat belated 'Thanks' for your post. I just wanted to let you know I got everything working perfectly (today!) and explain what I did. First, I found that Tinygps and U8g2 are not happy to work together. The Tiny code would work well until I issued a U8g2 'sendbuffer'. After that the Tiny stuff would stop working (weird). So I got up to speed on NEOgps and found there were no conflicts. I used SoftSerial for the 1.5" OLED SPI pins (Teensy pins 3-4-5-6) which worked nice physically since I was able to connect the OLED / Teensy pins with 1/2" solid 22AWG. Then used HW RX1 for the GPS on the Teensy and got everything working. I ended up using a Teensy LC and used 83% (program storage) and 58% (dynamic memory).Click image for larger version. 

Name:	p4.jpg 
Views:	11 
Size:	141.2 KB 
ID:	16739Click image for larger version. 

Name:	p3.jpg 
Views:	11 
Size:	156.6 KB 
ID:	16740

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •