• Ok, I think I am getting closer. I'm just really trying to navigate how the two different libraries (Arduino and Espruino) talk to each other.

    I have the following code on the puck.js. I can see and connect to the Arduino Adafruit Feather board with the puck on a button push.

    // Initialize the UART connection on Puck.js
    Serial1.setup(9600, { tx: D29, rx: D28 });
    
    // Function to send a message
    function sendMessage(message) {
      NRF.connect("ff:8d:05:ae:17:64 random").then(function(d)   {
        device = d;
        console.log("Device ",device);
        Serial1.print(message);
      });
    }
    
    // Send a message when the button is pressed
    setWatch(function() {
      sendMessage("Hello, Arduino!");
    }, BTN, { edge: "rising", debounce: 50, repeat: true });
    

    The code on the Arduino Feather is below. In the Serial output, when I click the puck button it shows the Device Connected in the output - but I can not for some reason get the UART message to be passed between the puck and the Arduino board. I'm sure it's something simple I'm missing - so sorry if this is an easy one.

    [#include](https://forum.espruino.com/search/?q=%23include) <Arduino.h>
    [#include](https://forum.espruino.com/search/?q=%23include) <SPI.h>
    [#include](https://forum.espruino.com/search/?q=%23include) "Adafruit_BLE.h"
    [#include](https://forum.espruino.com/search/?q=%23include) "Adafruit_BluefruitLE_SPI.h"
    [#include](https://forum.espruino.com/search/?q=%23include) "Adafruit_BluefruitLE_UART.h"
    
    [#include](https://forum.espruino.com/search/?q=%23include) "BluefruitConfig.h"
    
    [#if](https://forum.espruino.com/search/?q=%23if) SOFTWARE_SERIAL_AVAILABLE
      [#include](https://forum.espruino.com/search/?q=%23include) <SoftwareSerial.h>
    [#endif](https://forum.espruino.com/search/?q=%23endif)
    
        [#define](https://forum.espruino.com/search/?q=%23define) FACTORYRESET_ENABLE         1
        [#define](https://forum.espruino.com/search/?q=%23define) MINIMUM_FIRMWARE_VERSION    "0.6.6"
        [#define](https://forum.espruino.com/search/?q=%23define) MODE_LED_BEHAVIOUR          "MODE"
        [#define](https://forum.espruino.com/search/?q=%23define) LED_BUILTIN                 13
    /*=========================================================================
    
    Adafruit_BluefruitLE_UART ble(bluefruitSS, BLUEFRUIT_UART_MODE_PIN,
                          BLUEFRUIT_UART_CTS_PIN, BLUEFRUIT_UART_RTS_PIN);
    
    // A small helper
    void error(const __FlashStringHelper*err) {
      Serial.println(err);
      while (1);
    }
    
    /**************************************************************************/
    /*!
        @brief  Sets up the HW an the BLE module (this function is called
                automatically on startup)
    */
    /**************************************************************************/
    
    void setup() {
      // Start the hardware serial communication at 9600 baud rate
      Serial.begin(9600); // Serial Monitor
      Serial1.begin(9600); // UART Communication (Replace Serial1 with appropriate Serial for your Feather)
    
      Serial.println(F("Adafruit Bluefruit Command Mode 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();
    
        Serial.println(F("Please use Adafruit Bluefruit LE app to connect in UART mode"));
        Serial.println(F("Then Enter characters to send to Bluefruit"));
        Serial.println();
    
        ble.verbose(false);  // debug info is a little annoying after this point!
    
        /* Wait for connection */
        while (! ble.isConnected()) {
            delay(500);
        }
    
        while(ble.isConnected()){
          Serial.println(F("Device is connected."));
          delay(500);
        }
        pinMode(LED_BUILTIN, OUTPUT); // Optional: Use the built-in LED to indicate received data
    }
    
    void loop() {
      // Check if there is any data available on Serial1
      if (Serial.available()) {
        // Read the incoming byte
        String incomingMessage = "";
        while (Serial.available()) {
          char incomingByte = Serial.read();
          incomingMessage += incomingByte;
        }
        // Print the incoming message to the Serial Monitor
        Serial.println("Received: " + incomingMessage);
    
        // Optional: Blink LED to indicate message received
        digitalWrite(LED_BUILTIN, HIGH);
        delay(1000);
        digitalWrite(LED_BUILTIN, LOW);
      }
    }
    
About

Avatar for user158306 @user158306 started