TI CC3220SF MQTT Exosite Murano IOT

 

CC3200SF Exosite Murano2

This project features the Texas Instruments SimpleLink™ Wi-Fi® CC3220SF LaunchPad™ and demonstrates Internet Of Things capability by sending and receiving data from Exosite Murano using MQTT.

Setting up Exosite Murano to communicate with TI CC3220SF LP:

  1. Login to exosite.io . If you do not have an existing account, create an account by signing up.
  2. Go to IOT Marketplace and select TI SimpleLink Launchpad to create a new IOT Connector.

    This slideshow requires JavaScript.

  3. Set a IOT Connector Name.exosite4
  4. Go to Home Page and select your new IOT Connector.
  5. Go to “Devices” and add a new device. Name your new device “cc3220sf”. Uncheck “Restrict provisioning period”.exosite5
  6. Click the 3 dots and select “Manually set device credentials”. Save the randomly generated token at notepad.exosite6
  7. Copy product domain link. Save domain link at notepad.

    This slideshow requires JavaScript.

  8. Go to “Settings” and select “MQTT”. Set “Password” for Authentication.

    This slideshow requires JavaScript.

  9. Go to “Resources”, and delete all resources.
  10. Create a new resource “sw1”, with data format “String”. Create 3 resource for led0, led1, led2, with data format “Boolean” and select “I want to modify this value from the cloud”.

    This slideshow requires JavaScript.

  11. Go to “Device”, click the 3 dots and select “View dashboard”. The Dashboard window, where you can set GUI, to represent your data.exosite13 
  12. Select “ADD PANE”. At the new pane click the plus sign to add widget. Create a toggle switch widget for led0, led1, and led2. Optional is to create a new pane and widget for the sw1 string.

    This slideshow requires JavaScript.

  13. Select the up arrow to hide the dashboard settings.exosite17

 

Modifying the MQTT CCS Project for Exosite Murano:

  1. You need to have the latest CCSv9.20, CC3220SF SDKv3.30, Uniflash installed.
  2. Import the CCS Project to your CCSv9.20 workspace.
  3. At mqtt_client_app.c set the SERVER_ADDRESS, device name, password.

    This slideshow requires JavaScript.

  4. Rebuild all, tirtos_builds_CC3220SF_LAUNXL_release_ccs, and mqtt_client_CC3220SF_LAUNXL_tirtos_ccs.

Uniflash Setup:

  1. Open Uniflash, and Start Image Creator for CC3220SF Launchpad. Create a project, and set Device Type “CC3220SF” and Device Mode “Develop”.

    This slideshow requires JavaScript.

  2. At Uniflash Simple View, select your CCS project bin file and select the CC2640R2F SDKv3.30 service pack bin file located at “C:\ti\simplelink_cc32xx_sdk_3_30_01_02\tools\cc32xx_tools\servicepack-cc3x20”.uniflash3
  3.  

    Go to Uniflash Development Mode -> User Files. Select the document icon to add rootca.der file.uniflash4x

  4. Make sure the CC3220SF SOP Jumper is set to 010. Select “Connect”, then “Burn”. Select Program Image.

Testing the Program:

  1. After the program is flashed to the CC3220SF Launchpad, open Serial Console. A print out of “Connection Success” indicate successful connection to Exosite Murano.teraterm1
  2. Go to “Devices”. Select the led resources to change it’s state.exosite22
  3. Go to Dashboard, change the led state using toggle switch as shown in this video below.

 

References:

Exosite Murano MQTT Reference

Next Steps:

  1. Send several sensor data to Exosite Murano.
  2. Try out ExoSense, “it is an end-to-end solution for remote monitoring applications that need to gather data from sensors, machines, PLCs, legacy controls”.

 

Continue reading TI CC3220SF MQTT Exosite Murano IOT

Adding Bluetooth Connectivity to DPS3005 PSU using TI CC2640R2F BLE MCU

This project features the Texas Instruments SimpleLink Bluetooth Low Energy CC2640R2F Launchpad interfaced to a DPS3005 Programmable Power Supply. Making the DPS3005 to have Bluetooth Connectivity.

Serial Modbus RTU is the communication protocol used between TI CC2640R2F and DPS3005. DPS3005 has a connector with pins GND, RX, TX and VCC which is used to connect to TI CC2640R2F Launchpad 3.3V pins and GND for power and also RX and TX for Serial Modbus RTU Communication.

Values set during Video Demo:

  1. Voltage – 0x0096 (1.50V), 0x00C8 (2.00V), 0x012C (3.00V), 0x0190 (4.00V)
  2. Current – 0x01F4 (0.500A)

Single Write Register Serial Modbus Format:

Address Code (1 byte), Function Code (1 byte), Register Address (2 bytes), Register Data (2 bytes), CRC Code (2 bytes)

Example Serial Modbus Format setting Voltage to 0x012C (3.00V):

0x01 0x06 0x0000 0x012C CRC Code

Bluetooth Low Energy Services shown at IOS LightBlue App:

  1. DPS Modbus Service – Custom Bluetooth Service.

 

 

Program: TI CC2640R2F DPS Peripheral

Note: See, program link README.md for instructions.

 

Bluetooth Low Energy Point of Sale using TI CC2652RB SimpleLink™ crystal-less BAW wireless MCU

IMG_20190321_234500
Bluetooth Low Energy Point of Sale System

This project features the TI CC2652RB SimpleLink™ crystal-less BAW multiprotocol 2.4-GHz wireless MCU. The CC652RB BAW technology is explained in the video below.

Overall Project Features:

  1. CC2652RB Bluetooth Low Energy Weighing Scale with 3Kg Weighing Scale Kit. This functions as a Bluetooth Peripheral Device. To properly calibrate the 3Kg Weighing Scale Kit refer to my blog post MSP430 Serial Weighing Scale. You need to get the correct calibration factor value for the Weighing Scale Kit.
  2. CC2652RB Bluetooth Low Energy Weighing Scale Point Of Sale. This functions as a Bluetooth Central Device.

Program: TI CC2652RB BLE Point Of Sale

Note: See, program link README.md for instructions.

Project Demo:

MSP430 Serial Weighing Scale

IMG_20190311_013602

The picture above shows a 3Kg Weighing Scale Kit with HX711 Load Cell Amplifier Board. The Weighing Scale is interfaced to the MSP430FR5969 Launchpad. The weight value is then send to PC through USB connection and then displayed at Tera Term. For testing I am using a water bottle with 1 litre of water. 1 litre of water is equivalent in weight to 1 Kg.

The Energia Program for this project is based from the resources of Sparkfun HX711 Load Cell Amplifier Board. However, the program originally works for Arduino and you would need to do some procedure for it to work for Energia.

Once you downloaded the HX711 github example firmware from Sparkfun link, you save the HX711-master folder to Energia Library folder location “C:\energia-1.8.7E21-windows\energia-1.8.7E21\libraries”.

After that you need to do a few modifications to HX711 code library, .c and .h files, for it to work for Energia. Here are some below.

  1. Replace Arduino includes with Energia.
  2. Remove unnecessary codes that is for other boards such as for ESP8266.

First thing to do is to determine the calibration factor for your weighing scale setup using the code below.

#include "HX711.h"

#define DOUT  5
#define CLK  6
// most launchpads have a red LED
#define LED RED_LED

HX711 scale(DOUT, CLK);

float calibration_factor = -146940; //for 3 kg weighing scale.

void setup() {
  // initialize the digital pin as an output.
  pinMode(LED, OUTPUT);    
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  Serial.begin(9600);
  Serial.println("HX711 calibration sketch");
  Serial.println("Remove all weight from scale");
  Serial.println("After readings begin, place known weight on scale"); 
  Serial.println("Press a,s,d,f to increase calibration factor by 10,100,1000,10000 respectively");
  Serial.println("Press z,x,c,v to decrease calibration factor by 10,100,1000,10000 respectively");

  scale.set_scale();
  scale.tare();  //Reset the scale to 0

  long zero_factor = scale.read_average(); //Get a baseline reading
  Serial.print("Zero factor: "); //This can be used to remove the need to tare the scale. Useful in permanent scale projects.
  Serial.println(zero_factor);

}

void loop() {
  scale.set_scale(calibration_factor); //Adjust to this calibration factor

  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 3);
  Serial.print(" Kg"); //Change this to kg and re-adjust the calibration factor if you follow SI units like a sane person
  Serial.print(" calibration_factor: ");
  Serial.print(calibration_factor);
  Serial.println();

  if(Serial.available())
  {
    char temp = Serial.read();

    if(temp == '+' || temp == 'a')
      calibration_factor += 10;
    else if(temp == '-' || temp == 'z')
      calibration_factor -= 10;
    else if(temp == 's')
      calibration_factor += 100;
    else if(temp == 'x')
      calibration_factor -= 100;
    else if(temp == 'd')
      calibration_factor += 1000;
    else if(temp == 'c')
      calibration_factor -= 1000;
    else if(temp == 'f')
      calibration_factor += 10000;
    else if(temp == 'v')
      calibration_factor -= 10000;
    else if(temp == 't')
      scale.tare(); //Reset the scale to zero
  }  
}

Using the keys a, s, d, f, z, x, c, v, you adjust the calibration factor by 10,100,1000,10000 increments or decrements. I adjust the calibration factor until the weight of 1 Kg is shown. For 1 Kg the calibration factor is -323400.

TeraTerm1

I use this calibration factor at the HX711  Example Code.

#include <SPI.h>
#include <OneMsTaskTimer.h>
#include <LCD_SharpBoosterPack_SPI.h>
#include "HX711.h"

/*
 Example using the SparkFun HX711 breakout board with a scale
 By: Nathan Seidle
 SparkFun Electronics
 Date: November 19th, 2014
 License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

 This example demonstrates basic scale output. See the calibration sketch to get the calibration_factor for your
 specific load cell setup.

 This example code uses bogde's excellent library: https://github.com/bogde/HX711
 bogde's library is released under a GNU GENERAL PUBLIC LICENSE

 The HX711 does one thing well: read load cells. The breakout board is compatible with any wheat-stone bridge
 based load cell which should allow a user to measure everything from a few grams to tens of tons.

 Arduino pin 2 -> HX711 CLK
 3 -> DAT
 5V -> VCC
 GND -> GND

 The HX711 board can be powered from 2.7V to 5V so the Arduino 5V power should be fine.

*/

#define calibration_factor -323400.0 //This value is obtained using the SparkFun_HX711_Calibration sketch                                 

#define DOUT  5
#define CLK   6
#define LED RED_LED

//HX711 scale(DOUT, CLK, 128);
HX711 scale(DOUT, CLK);

// Variables
LCD_SharpBoosterPack_SPI myScreen;
uint8_t myOrientation = 0;
uint16_t myCount = 0;

void setup() {

  // initialize the digital pin as an output.
  pinMode(LED, OUTPUT);    
  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
  Serial.begin(9600);
  //myScreen.begin();
  //myScreen.clearBuffer();
  Serial.println("HX711 scale demo");

  scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale.tare();  //Assuming there is no weight on the scale at start up, reset the scale to 0

  Serial.println("Readings:");
}

void loop() {
  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 3); //scale.get_units() returns a float
  Serial.print(" Kg"); //You can change this to kg but you'll need to refactor the calibration_factor
  //myScreen.setFont(1);  
  //myScreen.text(10, 40, String(scale.get_units(), 2));
  //myScreen.text(10, 25, "Kg");
  //myScreen.flush();
  Serial.println();

}

Here is video demo of the HX711 Example Program.


After the correct calibration factor is set for your weighing scale setup, the correct weight will be shown at Tera Term.

Using Cheap Logic Analyzer + Sigrok Pulseview to analyze TI Launchpad I2C Signals

vktech salae clone
Enter a caption

From my previous projects and product development, I often interface I2C sensors to microcontrollers. Usually the I2C sensor manufacturer provides code library, in which you can port and make it work with the microcontroller. But If a I2C sensor was made by STMicroelectronics, the code library they have normally works for STMicroelectronics MCU. Other I2C sensor code library often works for MCU boards that are a favorite by makers and hobbyist such as Arduino Boards.

I recently experienced interfacing a old I2C Acceleromter + Magnetometer to TI CC2640R2F Launchpad. I had trouble re-using the available code library and I had to refer to the datasheet to make a code library from scratch that would work with TI CC2640R2F Launchpad. With basic I2C read and write I was eventually able to make it work. But what would be more assuring is to be able to verify my I2C code library using a Logic Analyzer.

Professional Logic Analyzers cost 200$ to several thousand dollars. For a electronic hobbyist, spending 200$ or more for a Logic Analyzer is too expensive for me. I searched in the internet and electronic hobbyist recommends to use Sigrok Pulseview. It supports several logic analyzers which can be found in this link. I choose a VKTech Saleae Clone worth around 10$, that includes shipment.

For testing the Logic Analyzer I am going to use a CC2640R2F Launchpad + Sensor BoosterPack setup. I am going to run the TMP007 Example Program.

TMP007 Example Program Tera Term Output: 

tmp007 tera term

Relevant TMP007 I2C Address:

  • 0x40 – TMP007 I2C Slave Address
  • 0x03 – TMP007 I2C Object Temperature Register Address.
  • 0x01 – TMP007 I2C Die Temperature Register Address.

Logic Analyzer + CC2640R2F Launchpad + Sensors BoosterPack Connection:

img_20190129_130000

Sigrok PulseView Installation and Setup:

  1. Download and install Sigrok PulseView from this link.
  2. Connect Logic Analyzer USB to PC.
  3. Setup your Logic Analyzer. Select fx2lafw driver and scan for devices. Select your device and press “OK”.
  4. Click probe icon and remove unnecessary channels.
  5. Set your sampling rate and frequency.
  6. Click signal icon and select I2C.
  7. Setup and select your logic analyzer.pulseview1x
  8. Click the I2C and assign the correct channels for your I2C lines.pulseview2
  9. Click “Run” to start capturing I2C signals.

I2C Logic Analyzer Capture reading TMP007 I2C Object Temperature Register 0x03:

pulseview3

I2C Logic Analyzer Capture reading TMP007 I2C Die Temperature Register 0x01:

pulseview4

TI CC2640R2F Eddystone Beacon

BLE Eddystone Beacon

This project features the Texas Instruments SimpleLink Bluetooth Low Energy CC2640R2F Launchpad  powered by 2xAA batteries to function as Bluetooth Low Energy Eddystone Beacon.

What are Beacons?

Beacons are used to mark important places. They have been used throughout history. A good example of a beacon is a lighthouse. A lighthouse is a tower, building, or other type of structure designed to emit light from a system of lamps and lenses. It serves as a beacon to sea vessels and function as navigational aid.

Similar to a lighthouse, Bluetooth Beacons broadcast identifiers to provide information about a particular place.

Google developed the Eddystone open Beacon format. Any Bluetooth Beacons that uses the Eddystone Beacon format are called Eddystone Beacons. Here below are the types of Eddystone Beacon format.

  • Eddystone-UID: A unique, static ID with a 10-byte Namespace component and a 6-byte Instance component.
  • Eddystone-URL: A compressed URL that, once parsed and decompressed, is directly usable by the client.
  • Eddystone-TLM: Beacon status data that is useful for beacon fleet maintenance, and powers Google Proximity Beacon API’s diagnostics endpoint. -TLM should be interleaved with an identifying frame such as Eddystone-UID or Eddystone-EID (for which the encrypted eTLM version preserves security).
  • Eddystone-EID: A time-varying beacon frame that can be resolved to a stable identifier by a linked resolver, such as Proximity Beacon API.

For this project the TI CC2640R2F Eddystone Beacon will advertise Eddystone-URL packets. Every 10th advertise is a Eddystone-TLM Packet which will consist of Battery Voltage, Temperature, Advertise Packet Count and Running time. The TI CC2640R2F Launchpad does not have temperature sensor and Temperature Value is set at 19.5 Celsius.

At Power On the TI CC2640R2F Eddystone Beacon will go to Configuration Mode. At this state the device is connectable. If there is no connection made within 30 seconds the device will enter Beacon Mode. At Beacon Mode the device is not connectable.

At Configuration Mode you can change Beacon Settings using the Eddystone URL Configuration Service, shown in this video below.

Program: TI CC2640R2F Eddystone Beacon

Note: See, program link README.md for instructions.

Using the Eddystone URL Configuration Service you can also change the Beacon Interval and TX Power. I do not have a Spectrum Analyzer to verify the change in TX Power. An alternative way to verify a change in TX Power is to measure the peak current consumption of a device during Beacon Advertisement. To do this I use a XDS110 Debug Probe plus Energy Trace Add-On.

0 dBM Energy Trace Current Consumption Profile:

0dbmbeacon
7.319 mA Peak Current

5 dBM Energy Trace Current Consumption Profile:

5dbmbeacon
11.721 mA Peak Current

Beacon Advertisement Current Waveform:

advertising

Using Energy Trace I can also get the estimated Battery Life with Beacon Interval = 300 ms and TX Power = 0 dBM. The estimated Battery Life is 4 months and 3 days.

energytrace

Bluetooth Low Energy Game Controller

Slide1

This project features the Texas Instruments SimpleLink Bluetooth Low Energy CC2640R2F Launchpad interfaced to a Educational BoosterPack MKII to function as Bluetooth Low Energy Game Controller.

Hardware Block Diagram:

Slide2

BOOSTXL-BATPAKMKII is used to power up the Bluetooth Low Energy Game Controller. Alternatively you can use 4 AA batteries as power supply.

Project Hardware Modifications:

  • Remove TI CC2640R2F Launchpad R52. This effectively disconnects the LaunchPad’s BPRST header pin from the CC2640R2F device’s RESET_N pin. Then EN1 circuitry of BOOSTXL-BATPAKMKII pulls the signal down to ground which is connected to the TI CC2640R2F BPRST Pin 13. If you are using 4 AA batteries as power supply skip this step.R52
  • Put a 10K Ohm Resistor across R9 of BOOSTXL-BATPAKMKII Rev 1.0. This is fix for the charging issue. Place a jumper at JP6 BIN. If you are using 4 AA batteries as power supply skip this step.IMG_1216
  • Remove 5V and 3V3 jumpers. Move VSENSE jumper from XDS110 Power to External Power. IMG_1207 - Copy
  • BTN1 of Educational BoosterPack MKII is connected to TCK pin of TI CC2640R2F LP BP Connector. The TCK pin at CC2640R2F LP BP Connector is not connected to anything. So to make use of it short it to DIO15.IMG_1224 - Copy
  • BTN2 of Educational BoosterPack MKII is connected to TD0 DIO16 pin of TI CC2640R2F LP BP Connector. To connect DIO16 to CC2640R2F place a wire short at R48 pad. Remove TDO and TDI Jumper.IMG_1225 - Copy
  • Set Educational BoosterPack MKII J5 jumper to 2-3 position. This is so we can set the LCD Backlight to off.IMG_1226

Bluetooth Low Energy Game Controller Inputs:

  • Educational BoosterPack MKII Joystick, BTN1 and BTN2.
  • CC2640R2F Launchpad BTN1 = SELECT, BTN2 = START

The BTN inputs are mapped to HID commands that is for NES Online Games Website.

Software Requirements:

Sending HID Commands Periodically every 80 ms:

The usual format for keyboard reports is the following byte array:
[modifier, reserved, Key1, Key2, Key3, Key4, Key5, Key6]
Key1 = Joystick X
Key 2 = Joystick Y
Key 3 = Educational BoosterPack BTN1
Key 4 = Educational BoosterPack BTN2
Key 5 = CC2640R2F LP BTN1/BTN2

Program: TI CC2640R2F BLE Game Controller

Note: See, program link README.md for instructions.

I think, I learn, I create