UART communication TI CC1352R1 Launchpad and Notecard Wifi

Hi,

I made a simple program using TI CC1352R1 Launchpad to send a JSON message note to Notecard Wifi and Notecarrier A. The UART baud rate is set to 9600. Here is the test message at Tera Term.
{“req”:“note.add”,“body”:{“temp”:40.5,“humid”:60.23}}

The connection from TI CC1352R1 Launchpad and Notecarrier A is below.

TI CC1352R1 Launchpad UART RX ↔ Notecarrier A TX
TI CC1352R1 Launchpad UART TX ↔ Notecarrier A RX
TI CC1352R1 Launchpad GND ↔ Notecarrier A GND

The message was not sent to Notehub.

The TI CC1352R1 Launchpad UART output is 3.3V. Do I need to use a voltage level converter for it to communicate with Notecard WiFi?

Regards,
Markel

Hi @mtrobregado ,

If you’d like your message to sync instantly, you’ll need to add the parameter “sync”:true to the payload of your “req”:“note.add” request. For example:

{“req”:“note.add”,”sync”:true,“body”:{“temp”:40.5,“humid”:60.23}}

If that isn’t your issue, can you confirm if you are receiving any communication back from the Notecard over UART?

Thanks,
Alex

Hi,

It did not work. I tried hub.sync also and did not work.

{“req”:“note.add”,“body”:{“temp”:40.5,“humid”:60.23}}
{“req”:“hub.sync”}

I have not configured my program yet to output the message from notecard.

Regards,
Markel

Hi,

The Notecarrier A V+ output is 4.5V. I am thinking I need to use a logic level shifter board for the UART communication.

Regards,
Markel

The Notecard requires 1.8V to 3.3V so this should be ok with the TI CC1352R1. How are you powering the Notecarrier? V+ is an input header and can accept voltages from 2.5-5.5V; the Notecard will regulate it internally to the required voltages.

Can you confirm if you can read the serial data output from your TI CC1352R1 using a Serial to USB converter? 9600 Baud should be acceptable for the Notecard so it’s worth confirming that it is working correctly.

Thanks,
Alex

Hi,

I am powering the Notecard WiFi and Notecarrier A using USB cable.

The TI CC1352R1 Launchpad output to Tera Term is below.

I use the left button to output this.
{“req”:“note.add”,“body”:{“temp”:40.5,“humid”:60.23}}

I use the right button to output this.
{“req”:“hub.sync”}

Anyway, I have not modified the program to also print out the UART output from the Notecard WiFi. I will also use logic analyzer to check the UART communication between 2 boards. I will do that tomorrow.

Regards,
Markel

1 Like

I checked using logic analyzer there is no reply from the Notecard WiFi after sending this JSON string from TI CC1352R1 Launchpad UART.

{“req”:“note.add”,“body”:{“temp”:40.5,“humid”:60.23}}

According to this, there should be no problem with UART voltage levels.
https://discuss.blues.com/t/why-cant-i-talk-to-notecard-over-uart-from-my-custom-board/893

The connection from TI CC1352R1 Launchpad and Notecarrier A is below.

TI CC1352R1 Launchpad UART RX ↔ Notecarrier A TX
TI CC1352R1 Launchpad UART TX ↔ Notecarrier A RX
TI CC1352R1 Launchpad GND ↔ Notecarrier A GND

Here is picture of my setup.

What am I doing wrong.?

I am able to communicate with the Notecard using Blues Wireless online serial console. But, I am not able to communicate with it using TI CC1352R1 Launchpad UART.

Regards,
Markel

I am sending these JSON string from TI CC1352R1 Launchpad.
const char testnote[100] = “{"req":"note.add","body":{"temp":40.5,"humid":60.23}}”;
const char syncnotehub[100] = “{"req":"hub.sync"}”;

Regards,
Markel

Hi @mtrobregado ,

Can you communicate with the Notecard via the Notecarrier A’s USB port? I.e. over serial over USB?

Can I get you to check what firmware version you are running on the Notecard WiFi, please? If possible, you should try to update it to eliminate known bugs.

Thanks,
Alex

Hi Alex,

I can communicate with Notecard via the Notecarrier A USB and send commands using Blues wireless online CLI. So, I do not understand, why I am not able to do the same from another board UART at 9600 baud rate.

I updated the firmware from 3.5.1 to latest 7.5.2 and same issue.

I have a STM32 Black Pill board. I will use it to communicate to the Notecard WiFI using your guides tomorrow. If it does not work then maybe the Notecard has issues.

Regards,
Markel

Hi Alex,

Since I am using Texas Instruments board, I referred to note c library for TI MSP430.

I notice the example_min.c JSON messages has a newline(\n) at the end. So, I modified my test program to include this and it worked.

I am using simplelink_cc13x2_26x2_sdk_5_10_00_48 and modified pininterrupt example program. Here is code.

 *  ======== pinInterrupt.c ========
 */
#include <unistd.h>
#include <string.h>

/* Driver Header files */
#include <ti/drivers/PIN.h>
#include <ti/drivers/UART.h>

/* POSIX Header files */
#include <semaphore.h>

/* TI-Drivers Configuration */
#include "ti_drivers_config.h"
/*
 * Device specific header file containing CPUdelay()
 */
#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/cpu.h)

static sem_t sem;

/* Pin driver handles */
static PIN_Handle buttonPinHandle;
static PIN_Handle ledPinHandle;

/* Global memory storage for a PIN_Config table */
static PIN_State buttonPinState;
static PIN_State ledPinState;

/*
 * Initial LED pin configuration table
 *   - LEDs CONFIG_PIN_LED_0 is on.
 *   - LEDs CONFIG_PIN_LED_1 is off.
 */
PIN_Config ledPinTable[] = {
    CONFIG_PIN_LED_0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    CONFIG_PIN_LED_1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW  | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
};

/*
 * Application button pin configuration table:
 *   - Buttons interrupts are configured to trigger on falling edge.
 */
PIN_Config buttonPinTable[] = {
    CONFIG_PIN_BUTTON_0  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    CONFIG_PIN_BUTTON_1  | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,
    PIN_TERMINATE
};

// The request field sets up service operation parameters
#define PRODUCT_UID "your product uid"
#define F_PRODUCT "\"product\":\"" PRODUCT_UID "\","
#define F_REQ "\"req\":\"hub.set\""
#define F_MODE "\"mode\":\"continuous\""

const char  syncnotehub[100] = "{\"req\":\"hub.sync\"}\n";
UART_Handle uart;
UART_Params uartParams;
uint8_t flag = 0;
int32_t semStatus;
/*
 *  ======== buttonCallbackFxn ========
 *  Push buttons callback function.s
 */
void buttonCallbackFxn(PIN_Handle handle, PIN_Id pinId) {
    uint32_t currVal = 0;

    /* Debounce logic, only toggle if the button is still pushed (low) */
    CPUdelay(8000 * 50);
    if (!PIN_getInputValue(pinId)) {
        /* Toggle LED based on the button pressed */
        switch (pinId) {
            case CONFIG_PIN_BUTTON_0:
                currVal =  PIN_getOutputValue(CONFIG_PIN_LED_0);
                PIN_setOutputValue(ledPinHandle, CONFIG_PIN_LED_0, !currVal);
                flag = 1;
            break;

            case CONFIG_PIN_BUTTON_1:
                currVal =  PIN_getOutputValue(CONFIG_PIN_LED_1);
                PIN_setOutputValue(ledPinHandle, CONFIG_PIN_LED_1, !currVal);
                flag = 2;
            default:
                /* Do nothing */
            break;
        }

        sem_post(&sem);
    }
}

/*
 *  ======== mainThread ========
 */
void *mainThread(void *arg0)
{

    /* Create semaphore */
    semStatus = sem_init(&sem, 0, 0);

    if (semStatus != 0) {
        /* Error creating semaphore */
        while (1);
    }
    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, ledPinTable);
    if(!ledPinHandle) {
        /* Error initializing LED pins */
        while(1);
    }

    buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
    if(!buttonPinHandle) {
        /* Error initializing button pins */
        while(1);
    }

    /* Setup callback for button pins */
    if (PIN_registerIntCb(buttonPinHandle, &buttonCallbackFxn) != 0) {
        /* Error registering button callback function */
        while(1);
    }

    UART_init();

    /* Configure the LED pin */
    //GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

    /* Create a UART with data processing off. */
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.baudRate = 9600;

    uart = UART_open(CONFIG_UART_0, &uartParams);

    if (uart == NULL) {
        /* UART_open() failed */
        while (1);
    }

    char *request1 = "{" "\"req\":\"hub.set\"" "," "\"product\":\"" PRODUCT_UID "\"," "\"mode\":\"continuous\"" "}\n";

    uint8_t len = 0;
    len = strlen(request1);
    UART_write(uart, request1, len);

    //UART_write(uart, initnote, sizeof(initnote));

    char *request2 = "{\"req\":\"note.add\",\"sync\":true,\"file\":\"sensors.qo\",\"body\":{\"count\":\"20\"}}\n";

    while(1)
    {
      /* Do not write until read callback executes */
      sem_wait(&sem);

      if(flag == 1)
      {
        flag = 0;
        len = strlen(request2);
        UART_write(uart, request2, len);

      }
      else if (flag == 2)
      {
        flag = 0;
        len = strlen(syncnotehub);
        UART_write(uart, syncnotehub, len);

      }
    }
}

Here is output at Notehub.

This issue has been solved. I am moving forward with my project.

Regards,
Markel
type or paste code here

2 Likes

@mtrobregado good catch! Thanks for updating this ticket with your findings.

I went through the docs to double-check that we are documenting this - Notecard Requests & Responses - Blues Developers. Although I appreciate this isn’t particularly clear so I will see if it can be made more explicit that a newline is required when using plain UART (i.e. not using the note-c library).

Thanks,
Alex

1 Like