Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 48 of 48

Thread: connecting nRF8001 to Teensy 3.1

  1. #26
    I have some additional debugging information:
    1) I hooked the nrf8001 Adafruit board up to an Arduino Nano w/328, which uses the same pinout as the Teensy except for power and ground. I used both the Adafruit code and Paul's code and I could connect via my iphone and interact with the bluetooth board with both distros. So the bluetooth board is working and my wires are correct. I see the echos on echotest and can communicate both ways with my iphone using both iOS apps.

    2) Still no luck with the Teensy 3.1. The exact error I get with Paul's code on the Teensy 3.1 is:
    Adafruit Bluefruit Low Energy nRF8001 Print echo demo
    Error in ACI Setup

    The program hangs and closing and re-opening the serial terminal doesn't show any text after reopening it.

    3) We tried the internal 3v supply off the teensy and an external 5v supply off of a second usb and neither helped.

    4) We tried a second Teensy 3.1 and it didn't help. So it isn't the i2c board I have on my teensy, nor my teensy board.

    I'm using Arduino 1.0.5 and Teensy loader 1.19.
    Last edited by BloomingtonFPV; 11-24-2014 at 06:42 PM.

  2. #27
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    28,455
    Quote Originally Posted by BloomingtonFPV View Post
    I'm using Arduino 1.0.5 and Teensy loader 1.19.
    You need 1.20. Actually, you need newer than 1.20... version 1.20 with a bunch of files updated.

  3. #28
    Last edited by BloomingtonFPV; 12-21-2014 at 01:24 PM.

  4. #29

    Fixed!

    Ok, I got the Callback demo working on MacOS on Teensy 3.1

    Upgraded to Arduino 1.0.6 with a fresh install, and loaded Teensy 1.2

    I used git clone to put the three libraries in the previous post into Documents/Arduino/libraries

    I updated these two file:
    avr_emulation.cpp
    avr_emulation.h
    in /Applications/Arduino 1.0.6.app/Contents/Resources/Java/hardware/teensy/cores/teensy3
    (just do a google search for the names)

    Actually, the nRF8001 library I used was this:
    https://codeload.github.com/adafruit...001/zip/master

    not the one on Paul's git. Don't know if there is a difference...

    I did lots of things all at once, so some things might not be necessary, but I'm just happy it is working...

    Thanks for the help!

  5. #30
    Hi @BloomingtonFPV, the .cpp and .h files from your zipfile are the same as Paul's 2014/11/20 commit:

    Code:
    commit 4a11223f50e4425caeb962cea8af4ec44a6a926f
    Author: PaulStoffregen <paul@pjrc.com>
    Date:   Thu Nov 20 06:55:39 2014 -0800
    
        Always use interrupt response, enable with EIMSK in SPI transaction
    The callback demo works for me also, with Arduino 1.0.6 and Teensy Loader 1.20.

  6. #31
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    28,455
    If anyone's having trouble getting all the stuff installed, the new 1.21-test1 version should have all the files.

    http://forum.pjrc.com/threads/27184-...4-7-2-to-4-8-4

    Of course, nRF8001 hasn't been tested with the new toolchain. If anyone does give it a try, please let me know if it works or fails?

  7. #32
    Junior Member
    Join Date
    Dec 2014
    Posts
    1
    I tested it with the new toolchain...that seems to have fixed my problems.

  8. #33
    Junior Member Chad1's Avatar
    Join Date
    Dec 2014
    Location
    Dallas, TX
    Posts
    6
    Hi all,

    I'm trying to run the Guggenhat code on the Teensy 3.1 with the Bluefruit LE module but cannot get it to work. My hardware setup is slightly different in terms of pinout and actual hardware used. (I'm using the 48 LED/meter strip which requires Data and CLK input. Most other NeoPixel strips only require Data input.) Can someone please help me based on the info below?

    TEENSY 3.1 PINOUT
    (BLE) SCK --> 13 (#define LED statement changed from 13 to 3)
    (BLE) MISO --> 12
    (BLE) MOSI --> 11
    (BLE) REQ --> 6 (not 10)
    (BLE) RDY --> 2
    (BLE) RST --> 9
    (BLE) GND --> GND
    (BLE) VIN --> VIN (5V regulated)

    (NeoPixel) DIN --> 7
    (NeoPixel) CIN --> 8

    DETAILS
    - Using Teensyduino 1.21-test1 and Arduino 1.0.6
    - echoDemo works with Bluefruit LE app => Bluetooth setup on Teensy works
    - Confirmed through other programs that NeoPixel setup works => Problem is not due to faulty connections/pinouts
    - My NeoPixel strip is connected in a zig-zag pattern instead of a coil. I modified the code as suggested in the "Variations" section of the Guggenhat Adafruit project page.
    - Guggenhat code compiles and uploads. I am able to connect via Bluetooth (confirmed through power LED blinking), but the NeoPixels don't illuminate when I send text.

    HYPOTHESIS
    Because (1) The Bluetooth connection and LED connections both work independently of one another, and (2) I am able to connect via Bluetooth but not send data, I think the problem is with the Guggenhat code only communicating with the NeoPixels via DataIn line. Since my NeoPixel strip uses DataIn and CLKIn, the Guggenhat code needs to be updated to include this second data input.

    MY REQUEST
    Can someone please help me update the Guggenhat code to write to the NeoPixels with the two required data inputs instead of just DataIn? As I'm a novice to C++ and Teensy/Arduino, I'm in way over my head on this one. Would appreciate the learning opportunity. Thanks in advance!

  9. #34
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    28,455
    @Chad1 - You've mentioned a specific type of LED, a particular Adafruit tutorial, and certain libraries you're using. Please post links to all these things, and anything else relevant. Please don't make me or anyone else who wants to help have to go searching and use guesswork to figure out exactly what hardware and software you're using.

    Also, see the "forum rule".... if you're seeing a particular problem, post the code and steps needed to reproduce that problem!

  10. #35
    Junior Member Chad1's Avatar
    Join Date
    Dec 2014
    Location
    Dallas, TX
    Posts
    6
    LED strip used: http://www.adafruit.com/products/1948
    Guggenhat tutorial: https://learn.adafruit.com/guggenhat...t-display/code
    My Guggenhat Code: GuggenHat.ino
    NeoMatrix library files: Adafruit_NeoMatrix.h, Adafruit_NeoMatrix.cpp

    The Guggenhat code is the same as the code used in the Adafruit tutorial except...
    1) I changed the pinout to match the one I provided in my earlier post
    2) I followed the steps outlined in the "Variations" section of the tutorial for a zig-zag LED layout

    All libraries are unedited as well. Since the only place in the Guggenhat code where the NeoPixel DataIn pin is referenced is when the NeoMatrix library is used, I think I need to figure out how to edit the NeoMatrix library to use two data pins instead of one. I appreciate any/all help! Sorry for not providing the above info in my first post. If there's anything else anyone needs, please let me know.

  11. #36
    Senior Member mortonkopf's Avatar
    Join Date
    Apr 2013
    Location
    London, uk
    Posts
    966
    you have posted a link to LPD8806 leds, but say you are using code for neopixels (WS2812?). Are you using the right code to drive the right pixels? LPD8806 are four wire and ws2811/12 are three wire. Also, I have found that the FastLed led driver library is superior to the neopixel library, you might want to see if there is an improvement once you figure out what leds you are using.
    m
    Last edited by mortonkopf; 12-18-2014 at 05:35 PM.

  12. #37
    Junior Member Chad1's Avatar
    Join Date
    Dec 2014
    Location
    Dallas, TX
    Posts
    6
    Quote Originally Posted by mortonkopf View Post
    you have posted a link to LPD8806 leds, but say you are using code for neopixels (WS2812?). Are you using the right code to drive the right pixels? LPD8806 are four wire and ws2811/12 are three wire.
    That's the heart of my question/request. I mentioned the code I'm using is meant for three-wire communication, but my LED strip uses four. Somehow I need a way to drive the LED strip I'm using. I was thinking that leveraging/modifying a NeoPixel library would be the path of least resistance. If there is a library dedicated to this four-wire interface that can be substituted in for a NeoPixel library, I'm unaware of it.

  13. #38
    Junior Member Chad1's Avatar
    Join Date
    Dec 2014
    Location
    Dallas, TX
    Posts
    6
    Quote Originally Posted by mortonkopf View Post
    Also, I have found that the FastLed led driver library is superior to the neopixel library, you might want to see if there is an improvement once you figure out what leds you are using.
    One program I leveraged to confirm my LED setup used the FastLED library. I tried to plug the FastLED library and some commands into the Guggenhat code but I don't think I did it correctly (because it still didn't work). If FastLED will make the Guggenhat code work, can you or someone else please tell me where/how to substitute it into the Guggenhat code? For example, what existing NeoPixel commands should be replaced and by which FastLED commands?

  14. #39
    Senior Member mortonkopf's Avatar
    Join Date
    Apr 2013
    Location
    London, uk
    Posts
    966
    that guggenhat code is made up of parts that can be separated out, and you should be able to use the correct lib to drive the leds, and charge led refs. Its a shame that you didn't get neopixels, but there you go. You will not get much joy from the neopixel lib, as far as I am aware, as there are a whole bunch of issues regarding timing and clock functions.

    First off, get the leds working so that they do something. Try use the FastLed library and see if you can get the leds to function. That library supports LPD8806. In the firstLight sketch (i think), you will see a list of Led types that are supported and the way to set the pin configuration.

  15. #40
    Senior Member mortonkopf's Avatar
    Join Date
    Apr 2013
    Location
    London, uk
    Posts
    966
    having a quick look, its not going to be easy to extricate what you need, as they have embedded some of the more common show(). functions into the matrix lib, won't be a straight forward swap out of calls.

  16. #41
    Junior Member Chad1's Avatar
    Join Date
    Dec 2014
    Location
    Dallas, TX
    Posts
    6
    Quote Originally Posted by mortonkopf View Post
    having a quick look, its not going to be easy to extricate what you need, as they have embedded some of the more common show(). functions into the matrix lib, won't be a straight forward swap out of calls.
    Bummer. Because I'm so new to the Arduino envirnment, I'm not remotely qualified to do much of anything beyond swapping out commands. Would really appreciate guidance/help to get this figured out.

  17. #42
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    28,455
    Probably your best course would be to buy at least a small number of 3-wire NeoPixels. Or even just 1 or 2 pixels. The way NeoPixels work makes it perfectly fine to connect fewer pixels. If the software is sending 100 colors for 100 pixels, you can connect only a few. Those few will show the first few colors. The other 90-some colors will not be used, but won't cause any harm.

    With just a few real NeoPixels, you could get it running by following the tutorials as written.

    Transitioning from the NeoPixel library to the FastLED, or to Adafruit's LPD8806 library, will involve several steps without a detailed tutorial. Figuring out the correct steps will be much easier if you've already got all the stuff working with at least a few real NeoPixels.

    You might also try contacting Adafruit and tell them what happened, that you were confused about which product to buy. Maybe they'll let you exchange the LPD8806s for NeoPixels? Maybe not, but it can't hurt to ask.

    One other thing you should know is Teensy transmits 3.3V signals. Many of these LEDs require 5V signals. Some work with 3.3V, but others don't, and there's no way to know in advance if any particular strip will or won't work with only 3.3V signals. The best way to deal with this is a chip that increases the 3.3V signals up to 5V signals.

    https://www.adafruit.com/product/1787

  18. #43
    Senior Member mortonkopf's Avatar
    Join Date
    Apr 2013
    Location
    London, uk
    Posts
    966
    good option from Paul, try an exchange. If this can't happen, it is possible to use what you've got, but you need to do some coding. You do, however, have the building blocks in place - you can get the BLE to connect, I assume you tested that data was held in the char buffer, and you know that you can get your leds to work. The missing link is converting the char array into a place within the matrix using the correct show() type function. You might find some of the code from the scrolling text hat I did a couple of years ago useful: http://orchardelica.com/wp/?page_id=170 if you decide to go with the LPD8806 leds.

    Although this code was for ws2811, the concept is the same, just the location of the led using row and col will be different. You will most likely create a location array based on your how your roll of leds makes the hat matrix, or use an offset value if the rows are always the same length.
    So, you get the char msg into the array, match the letter from the index array to get the bitmap, use this to determine which leds are on or off for the first part of the letter, move it on one, and get the second col of on/off, and so on.

    You should be able to read the code at the link and see a lot of what you need to do with swapping out the calls for FastLed.

  19. #44
    Junior Member Chad1's Avatar
    Join Date
    Dec 2014
    Location
    Dallas, TX
    Posts
    6
    Thanks for the tips, Paul. The LPD8806 LEDs were the best option for the main project I'm working on (which is completed), so exchanging/switching to NeoPixels is not an option. Bluetooth communication as done with the Guggenhat is just one additional feature I wanted to add to this main project.

    Sidenote: the LPD8806 LEDs work great with only 3.3V. In fact I have to turn the brightness down significantly.

  20. #45
    Senior Member mortonkopf's Avatar
    Join Date
    Apr 2013
    Location
    London, uk
    Posts
    966
    for the BLE code, the two key part (analogous to the use of the bluetooth in the code i mentioned above) are:
    Code:
    // Read from BTLE into buffer, up to maxlen chars (remainder discarded).
    // Does NOT append trailing NUL.  Returns number of bytes stored.
    uint8_t readStr(char dest[], uint8_t maxlen) {
      int     c;
      uint8_t len = 0;
      while((c = BTLEserial.read()) >= 0) {
        if(len < maxlen) dest[len++] = c;
      }
      return len;
    }
    and
    Code:
    else { // Not color, must be message string
          msgLen      = readStr(msg, sizeof(msg)-1);
          msg[msgLen] = 0;
          msgX        = matrix.width(); // Reset scrolling
        }
    This is where the incoming data is put into a buffer for use.
    You can then write a small piece of code that grabs this info and sets the leds either on or off. in Guggenhat ino this is done through:
    Code:
    if((t - prevFrameTime) >= (1000L / FPS)) { // Handle scrolling
        matrix.fillScreen(0);
        matrix.setCursor(msgX, 0);
        matrix.print(msg);
        if(--msgX < (msgLen * -6)) msgX = matrix.width(); // We must repeat!
        matrix.show();
        prevFrameTime = t;
      }
    which uses the matrix lib. You will need to change this section to something where you do a bit read and then show.

  21. #46
    Junior Member
    Join Date
    Aug 2013
    Posts
    6
    Quote Originally Posted by BloomingtonFPV View Post
    Actually, the nRF8001 library I used was this:
    https://codeload.github.com/adafruit...001/zip/master

    not the one on Paul's git. Don't know if there is a difference...
    I just got my nRF8001, wired it to my Teensy 3.0, installed a fresh Arduino 1.06, TeensyDuino 1.20, then 1.21-test2, including the bundled Adafruit_nRF8001 library, but was getting the "Error in ACI Setup". So, following this tip, I replaced the Adafruit_nRF8001 library with the one from Adafruit's GitHub and now it's working fine. FYI.

  22. #47
    Junior Member
    Join Date
    Jan 2014
    Posts
    4
    Hello,

    I've been trying to run the callbackEcho example with the nrf8001 and a Teensy 3.0 but I receive the "Error in ACI Setup". I am using Arduino 1.6.7 and I downloaded the latest teensyduino (1.28). I have replaced the nrf library with the one from Adafruit's GitHub like the posts above suggest but it did not resolve the issue. I have also previously replaced some core files, which I got from this thread. Figured I should mention this as something there could possibly interfere?

    My connections are:
    (BLE) SCK --> 13
    (BLE) MISO --> 12
    (BLE) MOSI --> 11
    (BLE) REQ --> 10
    (BLE) RDY --> 2
    (BLE) RST --> 9
    (BLE) GND --> GND
    (BLE) VIN --> VIN

    I have configured my USB type as "Serial + Keyboard + Mouse + Joystick" and I am watching the output in the Serial Monitor, accessed from the Tools menu, after setting the port to the only one available.

    Since I am extremely new I think it wouldn't harm to also ask some semi-related to the topic questions:
    1. Would it be possible to use the nrf8001 to send virtual key commands to Windows (like media controls)? My project's aim is to build a bluetooth keyboard but I might have picked the wrong bluetooth module.
    2. Is there a resource where I can get a jump start on what are HID, Serial and UART and more importantly the differences in the communication? I tried googling, but everything I found went right into the small details.

    Thanks in advance for your help!

  23. #48
    Junior Member
    Join Date
    Jan 2019
    Posts
    9
    I can't get the nRF8001 echo demo to work on a Teensy 3.5. I have tried to pin map the 3.2 to the 3.5 and uno that are discussed in length here on the forums, but have had no luck. The serial monitor displays "Adafruit Bluefruit Low Energy nRF8001 Print echo demo", but never shows "Advertising starting"; so I removed (!serial) from the code, but that didn't help.

    SCLK - SCK0 on D13
    MISO - MISO0 on D12
    MOSI - MOSI0 on D11
    REQ - CS0 on D10 - I've tried this on D6 as well
    RDY - D2
    ACT - NA
    RST - CS0 on D9
    GND
    5V

    Thank you for any help you can provide!

    Code:
    /*********************************************************************
    This is an example for our nRF8001 Bluetooth Low Energy Breakout
    
      Pick one up today in the adafruit shop!
      ------> http://www.adafruit.com/products/1697
    
    Adafruit invests time and resources providing this open source code, 
    please support Adafruit and open-source hardware by purchasing 
    products from Adafruit!
    
    Written by Kevin Townsend/KTOWN  for Adafruit Industries.
    MIT license, check LICENSE for more information
    All text above, and the splash screen below must be included in any redistribution
    *********************************************************************/
    
    // This version uses the internal data queing so you can treat it like Serial (kinda)!
    
    #include <SPI.h>
    #include "Adafruit_BLE_UART.h"
    
    // Connect CLK/MISO/MOSI to hardware SPI
    // e.g. On UNO & compatible: CLK = 13, MISO = 12, MOSI = 11
    #define ADAFRUITBLE_REQ 10
    #define ADAFRUITBLE_RDY 2     // This should be an interrupt pin, on Uno thats #2 or #3
    #define ADAFRUITBLE_RST 9
    
    Adafruit_BLE_UART BTLEserial = Adafruit_BLE_UART(ADAFRUITBLE_REQ, ADAFRUITBLE_RDY, ADAFRUITBLE_RST);
    /**************************************************************************/
    /*!
        Configure the Arduino and start advertising with the radio
    */
    /**************************************************************************/
    void setup(void)
    { 
      Serial.begin(9600);
      while(!Serial); // Leonardo/Micro should wait for serial init
      Serial.println(F("Adafruit Bluefruit Low Energy nRF8001 Print echo demo"));
    
      // BTLEserial.setDeviceName("NEWNAME"); /* 7 characters max! */
    
      BTLEserial.begin();
    }
    
    /**************************************************************************/
    /*!
        Constantly checks for new events on the nRF8001
    */
    /**************************************************************************/
    aci_evt_opcode_t laststatus = ACI_EVT_DISCONNECTED;
    
    void loop()
    {
      // Tell the nRF8001 to do whatever it should be working on.
      BTLEserial.pollACI();
    
      // Ask what is our current status
      aci_evt_opcode_t status = BTLEserial.getState();
      // If the status changed....
      if (status != laststatus) {
        // print it out!
        if (status == ACI_EVT_DEVICE_STARTED) {
            Serial.println(F("* Advertising started"));
        }
        if (status == ACI_EVT_CONNECTED) {
            Serial.println(F("* Connected!"));
        }
        if (status == ACI_EVT_DISCONNECTED) {
            Serial.println(F("* Disconnected or advertising timed out"));
        }
        // OK set the last status change to this one
        laststatus = status;
      }
    
      if (status == ACI_EVT_CONNECTED) {
        // Lets see if there's any data for us!
        if (BTLEserial.available()) {
          Serial.print("* "); Serial.print(BTLEserial.available()); Serial.println(F(" bytes available from BTLE"));
        }
        // OK while we still have something to read, get a character and print it out
        while (BTLEserial.available()) {
          char c = BTLEserial.read();
          Serial.print(c);
        }
    
        // Next up, see if we have any data to get from the Serial console
    
        if (Serial.available()) {
          // Read a line from Serial
          Serial.setTimeout(100); // 100 millisecond timeout
          String s = Serial.readString();
    
          // We need to convert the line to bytes, no more than 20 at this time
          uint8_t sendbuffer[20];
          s.getBytes(sendbuffer, 20);
          char sendbuffersize = min(20, s.length());
    
          Serial.print(F("\n* Sending -> \"")); Serial.print((char *)sendbuffer); Serial.println("\"");
    
          // write the data
          BTLEserial.write(sendbuffer, sendbuffersize);
        }
      }
    }

Posting Permissions

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