NRF8001 won't execute blePeripheral.begin();

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jmac4790
 
Posts: 5
Joined: Mon Jan 07, 2019 4:31 am

NRF8001 won't execute blePeripheral.begin();

Post by jmac4790 »

I'm having an issue with my nrf8001 module. The code i have included was working fine last week (with the same Arduino UNO as pictured below) but now it is getting stuck on the blePeripheral.begin(); line. Is there any way to check if the module is working correctly or is there a mistake in my code? This is the code i'm using;

Code: Select all

#include<SPI.h>
#include<BLEPeripheral.h>

#define BLE_REQ 10
#define BLE_RDY 2
#define BLE_RST 9

BLEPeripheral blePeripheral = BLEPeripheral(BLE_REQ,BLE_RDY,BLE_RST);
BLEService pressureReadingService = BLEService("BBB0");

BLEFloatCharacteristic pressure1Characteristic = BLEFloatCharacteristic("BBB1",BLERead | BLENotify);
BLEDescriptor pressure1Descriptor = BLEDescriptor("2901", "kPa");

BLEFloatCharacteristic pressure2Characteristic = BLEFloatCharacteristic("BBB2",BLERead | BLENotify);
BLEDescriptor pressure2Descriptor = BLEDescriptor("2901", "kPa");

BLEFloatCharacteristic pressure3Characteristic = BLEFloatCharacteristic("BBB3",BLERead | BLENotify);
BLEDescriptor pressure3Descriptor = BLEDescriptor("2901", "kPa");

#include <Wire.h>

long previousMillis = 0;    //Stores the last time sensor was read
long interval = 2000;         //Interval between sensor readings

void setup() 
{
  Serial.begin(9600);
  Serial.println(F("Bluetooth Low Energy Sensor Reader"));

  blePeripheral.setLocalName("Pressure Reader");
  blePeripheral.setDeviceName("Pressure Reader");
  blePeripheral.setAdvertisedServiceUuid(pressureReadingService.uuid());
  blePeripheral.addAttribute(pressureReadingService);
  
  blePeripheral.addAttribute(pressure1Characteristic);
  blePeripheral.addAttribute(pressure1Descriptor);

  blePeripheral.addAttribute(pressure2Characteristic);
  blePeripheral.addAttribute(pressure2Descriptor);

  blePeripheral.addAttribute(pressure3Characteristic);
  blePeripheral.addAttribute(pressure3Descriptor);
Serial.println("12");
  blePeripheral.begin();
  Serial.println("34");
}
void loop() 
{
  Serial.println("1234");
  blePeripheral.poll();
  Serial.println("5678");

  if (millis() - previousMillis > interval)
  {
    pollSensors();
    previousMillis = millis();
  }
}

void pollSensors()
{
  float voltage1 = analogRead(A0);
  float pressure1 = voltage1*5/1023;      //Change for correct calibration

  float voltage2 = analogRead(A1);
  float pressure2 = voltage2*2*5/1023;    //Change for correct calibration

  float voltage3 = analogRead(A2);
  float pressure3 = voltage3*2*5/1023;    //Change for correct calibration

  if (!isnan(pressure1) && pressure1Characteristic.value() !=pressure1)
  {
    pressure1Characteristic.setValue(pressure1);
    Serial.print(F("Pressure 1: "));
    Serial.println(pressure1);
  }

  if (!isnan(pressure2) && pressure2Characteristic.value() !=pressure2)
  {
    pressure2Characteristic.setValue(pressure2);
    Serial.print(F("Pressure 2: "));
    Serial.println(pressure2);
  }

  if (!isnan(pressure3) && pressure3Characteristic.value() !=pressure3)
  {
    pressure3Characteristic.setValue(pressure3);
    Serial.print(F("Pressure 3: "));
    Serial.println(pressure3);
  }
}
And this is the wiring
49587790_361923307941756_5892801477797216256_n.jpg
49587790_361923307941756_5892801477797216256_n.jpg (391.36 KiB) Viewed 84 times
VIN->5V
GND->GND
RST->Digital 9
RDY_>Digital 2
REQ->Digital 10
MOSI->Digital 11
MISO->Digital 12
SCK->Digital 13

Any help is much appreciated. TIA

User avatar
jmac4790
 
Posts: 5
Joined: Mon Jan 07, 2019 4:31 am

Re: NRF8001 won't execute blePeripheral.begin();

Post by jmac4790 »

Invoice No. 1929079
Purchased 11 December, 2018
49603568_2270918919855466_5736347372665962496_n.jpg
49603568_2270918919855466_5736347372665962496_n.jpg (310.73 KiB) Viewed 76 times
49805619_2107019516024153_8505675425370865664_n.jpg
49805619_2107019516024153_8505675425370865664_n.jpg (279.29 KiB) Viewed 76 times
49571331_2234617710085316_8919821993394569216_n.jpg
49571331_2234617710085316_8919821993394569216_n.jpg (452.44 KiB) Viewed 76 times

Locked
Please be positive and constructive with your questions and comments.

Return to “Wireless: WiFi and Bluetooth”