0

building Bluetooth connection on 2.13" diagonal eink display
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

building Bluetooth connection on 2.13" diagonal eink display

by deryaakitis on Tue Aug 13, 2019 3:58 pm

Hi, I'll build a Bluetooth connection on my 2.13" diagonal eink display, programming through CircuitPython. I'm planning to use nRF52840 Express feather. Also making it with as possible as less energy is my main concern. Is nRF52840 Express feather proper for this project? Do you have any other advice for the best match? I can go with Metro M4 express boot by adding a Bluetooth chip, or instead, just put another one Bluetooth supported boot that you advise.

deryaakitis
 
Posts: 14
Joined: Thu Aug 08, 2019 12:54 pm

Re: building Bluetooth connection on 2.13" diagonal eink dis

by adafruit_support_mike on Wed Aug 14, 2019 12:22 am

The nRF52480 has built-in Bluetooth, so it's a good choice for that kind of project.

adafruit_support_mike
 
Posts: 58843
Joined: Thu Feb 11, 2010 2:51 pm

Re: building Bluetooth connection on 2.13" diagonal eink dis

by deryaakitis on Wed Aug 14, 2019 11:51 am

I've just noticed that this one is out of stock. Is there any other board or chip for this usage?

deryaakitis
 
Posts: 14
Joined: Thu Aug 08, 2019 12:54 pm

Re: building Bluetooth connection on 2.13" diagonal eink dis

by adafruit_support_mike on Thu Aug 15, 2019 12:04 am

The nRF52832 also has built-in BLE, and is in stock right now:

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

adafruit_support_mike
 
Posts: 58843
Joined: Thu Feb 11, 2010 2:51 pm

Re: building Bluetooth connection on 2.13" diagonal eink dis

by deryaakitis on Mon Aug 19, 2019 1:02 pm

Hi again, I got nrf52832.
For the beginning, I'm just trying to send a text message to the nrf52 from my phone with the Bluefruit app. There are some Arduino codes on the tutorial for sending the pushed button and color information. I couldn't find if there is something for sending text messages?

deryaakitis
 
Posts: 14
Joined: Thu Aug 08, 2019 12:54 pm

Re: building Bluetooth connection on 2.13" diagonal eink dis

by adafruit_support_mike on Mon Aug 19, 2019 11:34 pm

That would be the 'UART Terminal' option in the BLE Connect app. It sends and receives data as text.

adafruit_support_mike
 
Posts: 58843
Joined: Thu Feb 11, 2010 2:51 pm

Re: building Bluetooth connection on 2.13" diagonal eink dis

by deryaakitis on Tue Aug 20, 2019 3:39 pm

Thanks! I've adjusted the code, it worked well on Ardunio with e-ink display.

But I disconnected the e-ink by mistake while it was refreshing itself. Now, it's grey-color and not working. Do I have any chance to recover it by reseting ?

deryaakitis
 
Posts: 14
Joined: Thu Aug 08, 2019 12:54 pm

Re: building Bluetooth connection on 2.13" diagonal eink dis

by adafruit_support_mike on Wed Aug 21, 2019 12:05 am

Have you completely disconnected and reconnected power, then hooked it up to work with one of the example sketches?

adafruit_support_mike
 
Posts: 58843
Joined: Thu Feb 11, 2010 2:51 pm

Re: building Bluetooth connection on 2.13" diagonal eink dis

by deryaakitis on Thu Aug 22, 2019 1:20 pm

Yep it's well now, thanks!

And I have one more question. I've done the code on Arduino with nrf52832 connected with 2.13" Diagonal eInk display. And I need to connect the system to Metro M4 express, to make the system works on CircuitPython since nrf52832 isn't supported by Circuitpython by itself. Do you have an idea about how I can do that?

I've tried on this way:
I've connected the boards on tx, rx, ground and vin pins and worked on Circuitpython and Arduino at the same time. But the MU Editor for Circuitpython went crazy, it starts to delete the commands on serial terminal by itself.




Circuitpython with this code:

Code: Select all | TOGGLE FULL SIZE
import board
import busio
import digitalio

led = digitalio.DigitalInOut(board.D13)
led.direction = digitalio.Direction.OUTPUT

uart = busio.UART(board.TX, board.RX, baudrate=9600)

while True:
    data = uart.read(32)  # read up to 32 bytes
    # print(data)  # this is a bytearray type

    if data is not None:
        led.value = True

        # convert bytearray to string
        data_string = ''.join([chr(b) for b in data])
        print(data_string, end="")

        led.value = False




Arduino with this code:

#include <bluefruit.h>
#include <Adafruit_LittleFS.h>
#include <InternalFileSystem.h>
#include "Adafruit_EPD.h"
#define EPD_CS      A0
#define EPD_DC      15
#define SRAM_CS     16
#define SD_CS       A2
#define EPD_RESET   -1
#define EPD_BUSY    -1

Adafruit_SSD1675 display(250, 122, EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY);
#define COLOR1 EPD_BLACK

BLEDfu  bledfu;  // OTA DFU service
BLEDis  bledis;  // device information
BLEUart bleuart; // uart over ble
BLEBas  blebas;  // battery

void setup()
{
  Serial.begin(115200);
  while ( !Serial )
  delay(10);   // for nrf52840 with native usb
  Serial.println("Market Label Project");
  Serial.println("---------------------------------------------");
  display.begin();

#if defined(FLEXIBLE_213) || defined(FLEXIBLE_290)
  display.setBlackBuffer(1, false);
  display.setColorBuffer(1, false);
#endif

  display.clearBuffer();
  Bluefruit.autoConnLed(true);
  Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);

  Bluefruit.begin();
  Bluefruit.setTxPower(4);
  Bluefruit.setName("Bluefruit52");
  Bluefruit.Periph.setConnectCallback(connect_callback);
  Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
  bledfu.begin();
  bledis.setManufacturer("Adafruit Industries");
  bledis.setModel("Bluefruit Feather52");
  bledis.begin();
  bleuart.begin();
  blebas.begin();
  blebas.write(100);
  startAdv();

  Serial.println("Please use Adafruit's Bluefruit LE app to connect in UART mode");
  Serial.println("Once connected, enter character(s) that you wish to send");
}
void startAdv(void)
{
  Bluefruit.Advertising.addTxPower();
  Bluefruit.Advertising.addService(bleuart);
  Bluefruit.ScanResponse.addName();
  Bluefruit.Advertising.restartOnDisconnect(true);
  Bluefruit.Advertising.setInterval(32, 244);    // in unit of 0.625 ms
  Bluefruit.Advertising.setFastTimeout(30);      // number of seconds in fast mode
  Bluefruit.Advertising.start(0);                // 0 = Don't stop advertising after n seconds 
}
void loop()
{
  display.clearBuffer();
  drawtext(40, "Price of the Product:", COLOR1);
  int  n=170;
  // Forward data from HW Serial to BLEUART
  while (Serial.available())
  {
    delay(2);
    uint8_t buf[64];
    int count = Serial.readBytes(buf, sizeof(buf));
    bleuart.write( buf, count ); 
  }
  drawtext(205, "$", COLOR1);
  // Forward data from BLEUART to HW Serial
  while ( bleuart.available())
  {
    uint8_t ch;
    ch = (uint8_t) bleuart.read();
    Serial.write(ch);
    drawtextfromterminal(n, ch, COLOR1);
    n=n+8;
    display.display();
  } 
 
}
void drawtext( int n, char *text, uint16_t color) {
  display.setCursor(n, 50);
  display.setTextColor(color);
  display.setTextWrap(true);
  display.print(text);
}
void drawtextfromterminal(int n, char text, uint16_t color) {
  display.setCursor(n, 50);
  display.setTextColor(color);
  display.setTextWrap(true);
  display.print(text);
}
void connect_callback(uint16_t conn_handle)
{
  BLEConnection* connection = Bluefruit.Connection(conn_handle);
  char central_name[32] = { 0 };
  connection->getPeerName(central_name, sizeof(central_name));
  Serial.print("Connected to ");
  Serial.println(central_name);
}
void disconnect_callback(uint16_t conn_handle, uint8_t reason)
{
  (void) conn_handle;
  (void) reason;
  Serial.println();
  Serial.println("Disconnected");
}
Last edited by adafruit_support_mike on Fri Aug 23, 2019 1:07 am, edited 1 time in total.
Reason: added CODE tags

deryaakitis
 
Posts: 14
Joined: Thu Aug 08, 2019 12:54 pm

Re: building Bluetooth connection on 2.13" diagonal eink dis

by adafruit_support_mike on Fri Aug 23, 2019 1:23 am

The nRF53822's TX and RX pins are connected to the USB-to-Serial converter, so you can't use them to talk to the REPL and another board at the same time.

You should be able to create a SoftwareSerial connection though. Just use another pair of pins for the TX and RX signals, and use those pin numbers instead of board.TX and board.RX when you call busio.UART().

adafruit_support_mike
 
Posts: 58843
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.