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:

Advertisements

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.

Bluetooth Low Energy Power Bank

BLE Power Bank

This project features the Texas Instruments SimpleLink Bluetooth Low Energy CC2640R2F Launchpad interfaced to a BOOSTXL-BATPAKMKII to function as Bluetooth Low Energy Power Bank.

With a Bluetooth Low Energy Power Bank you can use a Smart Phone App to see how much charge it has and receive notifications if its charge level has reached a set critical or high level. See, video below.

Bluetooth Low Energy Services:

  1. LiPo Batt Service – Custom Bluetooth Service.
  • Battery Level Critical and High Notifications.

 

Hardware Block Diagram:

BLE Power Bank Block Diagram

Hardware Setup:

IMG_1203

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. Remove 5V and 3V3 jumpers. Move VSENSE jumper from XDS110 Power to External Power.

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.

IMG_1216

Project Software Requirements.

  1. Simplelink CC2640R2 SDK: SDK v1.50.
  2. TI Code Composer Studio 8.0.
  3. SmartRF Flash Programmer 2.
  4. SmartPhone LightBlue IOS App.

Program: TI CC2640R2F BLE Power Bank

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

Project Photos:

IMG_1210
CC2640R2F Launchpad, BOOSTXL-BATPAKMKII, 430BOOST-SHARP96
IMG_1209
MOSFET Switch Board

 

 

 

Secure Internet Of Things Humidifier

Secure IOT Humidifier System
Device Connection to WiFi Network

This project features the Texas Instruments SimpleLink™ Wi-Fi® CC3220SF LaunchPad™ with Integrated Security Features as shown below.

Overall Project Features:

  1. Easy connection to CC3220SF Launchpad using SimpleLink™ Wi-Fi® Starter application.
  2. Direct connection to CC3220SF Launchpad set as Access Point.
  3. Easy access to CC3220SF Launchpad using its internal web server.
  4. Demonstrates reading Sensors Booster Pack BME280 humidity and temperature.
  5. Demonstrates setting of desired humidity. If desired humidity is greater than actual humidity, the humidifier will turn on.
  6. Neopixel Ring RGB Led Lights Show upon internet connection.

Hardware Block Diagram:

Secure IOT Humidifier HW Block Diagram
Enter a caption

CC3220SF Launchpad connection to Sensors Booster Pack:

The I2C pins of Sensors Booster Pack is in conflict with the TDO and TDI of CC3220SF Launchpad. Set CC3220SF Launchpad SOP Jumper to 001, to change from 4-wire JTAG Connection to 2-wire JTAG Connection. Remove the CC3200SF Launchpad I2C jumper connection to on-board sensors.

IMG_1130mod1

Overall Pin Compatibility:

pin compatibility

Project Photos:

IMG_1140
NeoPixel Ring 16 RGB Leds
IMG_1132
SeedStudio Grove Water Atomization
IMG_1138
Ultrasonic Transducer Disc
IMG_1135
MSP430FR5969 Launchpad and CC3220SF Launchpad

Program: TI CC3220SF IOT Humidifier

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

Program Details:

The program firmware and internal web pages are modified version of the CC3220SF Launchpad Out of Box Demo.

Provisioning Process:

  1. When there is no network profile previously saved at TI CC3220SF Launchpad it will start the provisioning process. If the TI CC3220SF Launchpad is connected to your PC you can see the output at Tera Term that provisioning has been started.teraterm1
  2. Open SimpleLink™ Wi-Fi® Starter application and set your WiFi Network Details.IMG_1128
  3. After successful provisioning your device IP address will be shown.

teraterm2

 

Internal Web Pages:

index
index.html
demo
demo.html
status
settings.html Status Tab
profiles
settings.html Profiles Tab
device
settings.html Device Tab
network
settings.html Network Tab

Project Demo:

 

 

I think, I learn, I create