Hi,
Thank you for your answer. Yes, you are right. I have to be more specific.
The following description is provided by the manufacturer (Adafruit) to wire the breakout board (Bluetooth module) up with the UNO or MEGA:
"Now that we have headers attached we can easily wire it up to our Arduino
VIN -- connects to the Arduino 5V pin
GND -- connects to Arduino ground
SCK -- connects to SPI clock.
On Arduino Uno/Duemilanove/328-based, thats Digital 13.
On Mega's, its Digital 52 and on
Leonardo/Micro its ICSP-3 (See SPI Connections for more details)
MISO -- connects to SPI MISO.
On Arduino Uno/Duemilanove/328-based, thats Digital 12.
On Mega's, its Digital 50 and on
Leonardo/Micro its ICSP-1 (See SPI Connections for more details)
MOSI -- connects to SPI MOSI.
On Arduino Uno/Duemilanove/328-based, thats Digital 11.
On Mega's, its Digital 51 and on
Leonardo/Micro its ICSP-4 (See SPI Connections for more details)
REQ connects to our SPI Chip Select pin. We'll be using Digital 10 but you can later change this to any pin
RST connects to Digital 9 - this is for resetting the board when we start up, you can later change this to
any pin
RDY is the interrupt out from the nRF8001, we'll connect to Digital 2 but be aware that if you want to change it, it must connect to an interrupt capable pin (see this Arduino page for which pins are interrupt-capable. Digital 2 is OK on Uno/Leonardo/Micro/Mega/etc.)"
I followed the above steps and everything worked well with UNO and MEGA.
However, when I switch from UNO or Mega to 1284p, something happens. The code is exactly the same. The attached image is the 1284p pinout that I am using.
I connect the MISO, MOSI, and SCK pins to the 5,6,7 pin respectively.
Based on the description of the manufacturer, the other three pins (REQ, RDY, and RST) can be connected to any other digital pins.
The REQ or Chip Select (SS) I connected it to the digital 4 pin. As to the RDY or Interrupt Pin, I connected to the digital 2 pin. And finally, I connected the RST pin to the digital pin number 14.
Also. I connected the Vcc and Gnd.
These are the connections I made and followed based always on the instructions provided by the manufacturer.
And this is the original code from the manufacturer:
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"
#include <Arduino.h>
//Here the REG, RDY, and RST are assigned to a digital output
// Connect CLK/MISO/MOSI to hardware SPI
// e.g. On UNO & compatible: CLK = 13, MISO = 12, MOSI = 11
#define ADAFRUITBLE_REQ 4 // I chose this pin because based on the Sanguino Pinout, SS or CS is
//pin4
#define ADAFRUITBLE_RDY 2 // This should be an interrupt pin, on Uno thats #2 or #3. On 1284p,
// pin2 is also an interrupt pin
#define ADAFRUITBLE_RST 14 // I decided to choose this pin. It might be another one
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);
}
}
}
I do not know if I made a mistake making the connections (wiring up). I would say no. However, when running the code on the 1284p, the Serial Monitor does not show the message saying the connections have been established.
To me, it is an issue with the definitions and matching pins between the 1284p and the Bluetooth but I can not see it.
By the way, on the Arduino IDE I chose "Pinout:Sanguino" and obviously the 1284p.
I am stuck with something apparently "easy".
Any ideas???
Thank you so much in advance.
Regards.