Now see if we have any data from Arduino keybd/Serial console OK while we still have something to read, get a character and print it out Serial.println(F(" bytes available from BTLE")) Serial.print(BTLE.available()) //gets number of bytes available OK set the last status change to this one Serial.println(F("Disconnected or advertising timed out")) Serial.println(F("Advertising started")) Tell the nRF8001 to do whatever it should be working on.Īci_evt_opcode_t status = BTLE.getState() Serial.println(F("Bluefruit LE nRF8001 UART demo")) īTLE.setDeviceName("Arduino") /* 7 characters max! */ LiquidCrystal_I2C lcd(ADDRESS, 16, 2) // set the LCD I2C addressĪci_evt_opcode_t laststatus = ACI_EVT_DISCONNECTED #define BLE_RDY 2 // This should be an interrupt pin, on Uno thats #2 or #3Īdafruit_BLE_UART BTLE = Adafruit_BLE_UART(BLE_REQ, BLE_RDY, BLE_RST) On UNO & compatible: CLK = 13, MISO = 12, MOSI = 11 Once the circuit is connected, upload this code to the Arduino: //an adaptation of the "echodemo" example in the library examples folder My phone is an older Samsung Galaxy and worked just fine. Typing a word with all three such as “grab” will flash all three. In the modified example below, I have added a red, green, and blue LED to the board, and you can flash these by entering an r, or b or g from the phone. Enter text on the serial window and send it, and it will appear on your phone. The text should appear in the Arduino’s serial monitor. Type in some text and hit the Send button. Here are the parts you will need to build this project: How to Connect the nRF8001 to the Arduino Adafruit has more details on its nRF8001 here. REQ is used similarly to SS that you may have come across in other SPI applications. RST is the reset pin and resets the nRF at startup. REQ signals to the nRF that the Arduino has something to say and RDY tells the Arduino that the nRF has something to say and must go to one of the Arduino’s interrupt request pins, i.e., 2 or 3. These four pins must go to the Arduino as shown and are not negotiable. The first three pins on the PCB are the SPI interface, SCK is just a clock, MISO is Master In Slave Out, and MOSI is Master Out Slave In. In other words, plain old serial Tx and Rx, which makes it very easy to use. One of the cool features of the nRF8001 is that its interface to the user is a UART. Note: I have only tested all this on an Android phone (Samsung Galaxy J3) How the nRF8001 Works We will also type in strings at the serial console, and send these back to the cell phone. We will add a red, green, and blue LED, and by sending an ‘r’ or ‘b’ or ‘g’, we will pulse that LED for a few mS. In other words, we will use the built-in ability to act as a UART. We are going to connect an Arduino UNO to the nRF8001 module and send and receive data to/from it as though it were a serial port. Instead we will use the nRF8001 Bluetooth module which has a lower power consumption and can be connected to smartphones. The HC-05 Bluetooth transceiver module is the most common Bluetooth transceiver, but it has high power consumption and can’t be linked to smartphones. While a handful of Arduino boards have Bluetooth built-in, some projects may require the use of external Bluetooth modules. Unlike the earlier standard Bluetooth, LE requires no contracts or problems with developing apps, and you can distribute via the Play Store it also requires very little power, so it is very suitable for battery operation. Bluetooth LE (Low Energy) was a new version. Data is split into one of 79 slots between 2.4 and 2.4835 GHz in 1MHz bands. Bluetooth was created to exchange data within short range without the need for wires like headphones, heart monitors, and sensors.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |