0

Feather M0 Wifi with external Bluefruit module
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Feather M0 Wifi with external Bluefruit module

by mxklt on Fri Jun 14, 2019 6:24 pm

Hi dudes,

is it possible to connect the Feather M0 Wifi with the external Bluefruit module?

If yes, how can I do it?

Thanks in advance!

Best regards
Max

https://www.adafruit.com/product/3010
https://www.adafruit.com/product/2633

mxklt
 
Posts: 3
Joined: Thu Jun 13, 2019 5:23 pm

Re: Feather M0 Wifi with external Bluefruit module

by franklin97355 on Sat Jun 15, 2019 1:36 pm

It is possible and you would connect them using the SPI pins of the Feather.

franklin97355
 
Posts: 20957
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Feather M0 Wifi with external Bluefruit module

by mxklt on Sun Jun 16, 2019 4:18 am

Hi,

thanks for your answer!

Aren't they already occupied with the onboard wifi chip?

Best regards
Max

mxklt
 
Posts: 3
Joined: Thu Jun 13, 2019 5:23 pm

Re: Feather M0 Wifi with external Bluefruit module

by mxklt on Mon Jun 17, 2019 10:59 am

I think i find a solution to use the wifi & ble module at the same time...

I created a custom spi sercom (sercom1, pins -> 12, 11, 10).

Code: Select all | TOGGLE FULL SIZE
#include <Arduino.h>
#include <SPI.h>
#include "Adafruit_BLE.h"
#include "Adafruit_BluefruitLE_SPI.h"

#include "wiring_private.h"
 
SPIClass mySPI (&sercom1, 11, 12, 10, SPI_PAD_0_SCK_1, SERCOM_RX_PAD_3);



#include "BluefruitConfig.h"



/* ...hardware SPI, using SCK/MOSI/MISO hardware SPI pins and then user selected CS/IRQ/RST */
Adafruit_BluefruitLE_SPI ble(BLUEFRUIT_SPI_CS, BLUEFRUIT_SPI_IRQ, BLUEFRUIT_SPI_RST);


// A small helper
void error(const __FlashStringHelper*err) {
  Serial.println(err);
  while (1);
}




#define FACTORYRESET_ENABLE      0







void setup(void) {
  while (!Serial);  // required for Flora & Micro
  delay(500);

  Serial.begin(115200);
  mySPI.begin();

  // Assign pins 10, 11, 12 to SERCOM functionality
  pinPeripheral(10, PIO_SERCOM);
  pinPeripheral(11, PIO_SERCOM);
  pinPeripheral(12, PIO_SERCOM);

 
  Serial.println(F("Adafruit Bluefruit AT Command Example"));
  Serial.println(F("-------------------------------------"));

  /* Initialise the module */
  Serial.print(F("Initialising the Bluefruit LE module: "));

  if ( !ble.begin(VERBOSE_MODE) )
  {
    error(F("Couldn't find Bluefruit, make sure it's in CoMmanD mode & check wiring?"));
  }
  Serial.println( F("OK!") );

  if ( FACTORYRESET_ENABLE )
  {
    /* Perform a factory reset to make sure everything is in a known state */
    Serial.println(F("Performing a factory reset: "));
    if ( ! ble.factoryReset() ){
      error(F("Couldn't factory reset"));
    }
  }

  /* Disable command echo from Bluefruit */
  ble.echo(false);

  Serial.println("Requesting Bluefruit info:");
  /* Print Bluefruit information */
  ble.info();
}











uint8_t i=0;
void loop(void)
{

  //Serial.println(i);

  mySPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
  mySPI.transfer(i++);
  mySPI.endTransaction();


    // Display command prompt
  Serial.print(F("AT > "));

  // Check for user input and echo it back if anything was found
  char command[BUFSIZE+1];
  getUserInput(command, BUFSIZE);

  // Send command
  ble.println(command);

  // Check response status
  ble.waitForOK();
 

}









void getUserInput(char buffer[], uint8_t maxSize)
{
  memset(buffer, 0, maxSize);
  while( Serial.available() == 0 ) {
    delay(1);
  }

  uint8_t count=0;

  do
  {
    count += Serial.readBytes(buffer+count, maxSize);
    delay(2);
  } while( (count < maxSize) && !(Serial.available() == 0) );
}


Code: Select all | TOGGLE FULL SIZE
// COMMON SETTINGS
// ----------------------------------------------------------------------------------------------
// These settings are used in both SW UART, HW UART and SPI mode
// ----------------------------------------------------------------------------------------------
#define BUFSIZE                        160   // Size of the read buffer for incoming data
#define VERBOSE_MODE                   true  // If set to 'true' enables debug output


// SHARED SPI SETTINGS
// ----------------------------------------------------------------------------------------------
// The following macros declare the pins to use for HW and SW SPI communication.
// SCK, MISO and MOSI should be connected to the HW SPI pins on the Uno when
// using HW SPI.  This should be used with nRF51822 based Bluefruit LE modules
// that use SPI (Bluefruit LE SPI Friend).
// ----------------------------------------------------------------------------------------------
#define BLUEFRUIT_SPI_CS               12
#define BLUEFRUIT_SPI_IRQ              11
#define BLUEFRUIT_SPI_RST              10    // Optional but recommended, set to -1 if unused


When i run the code, the bluefruit spi friend module is shown as initialised.
A factory reset could not perform -> Couldn't factory reset

When i set FACTORYRESET_ENABLE to 0 the next stop is ble.info() -> ble.info() shows no output.

AT commands cannot be executed either.

Screenshot 2019-06-17 16.31.08.png
Screenshot 2019-06-17 16.31.08.png (42.06 KiB) Viewed 40 times


Here is the hardware.

IMG_6468.jpg
IMG_6468.jpg (596.21 KiB) Viewed 40 times

IMG_6469.jpg
IMG_6469.jpg (639.96 KiB) Viewed 40 times


Please ignore the led and the button, these are currently not connected.

I would be happy about quick help and thank you in advance!

Please don't judge me if I made a gross/stupid mistake, I'm still a beginner ;)

btw the bluefruit module has power and you can connect to it.

Best regards
Max

mxklt
 
Posts: 3
Joined: Thu Jun 13, 2019 5:23 pm

Please be positive and constructive with your questions and comments.