MQTT/IBM Bluemix/ Node-Red Demo

This demo utilizes the CC3100 Wifi BoosterPack with the MSP432 LaunchPad. Although we will not be using the MSP432 in the final coin counter project, the demo is proof of concept meant to test the CC3100 BoosterPack with MQTT to see if data can be displayed on the cloud. This specific demo uses a potentiometer as the means of changing values that is displayed on Node-Red. The same idea will be constructed with the final coin counter in order to show the monetary value and score online.

Below is a video of the MQTT Demo running.

Below is the source code for the demo constructed (Note: the text in green are comments added in).

#include <WiFi.h>
#include <PubSubClient.h>
#include <SPI.h> //only required if using an MCU LaunchPad + CC3100 BoosterPack. Not needed for CC3200 LaunchPad
WiFiClient wclient;

byte server[] = { 198, 41, 30, 241 }; // Public MQTT Brokers:
byte ip[] = { 172, 16, 0, 100 };

char sensorRead[4];

#define WIFI_SSID "//Put Wifi name here"
#define WIFI_PWD "//Put Wifi password here"

PubSubClient client(server, 1883, callback, wclient);

void callback(char* inTopic, byte* payload, unsigned int length){
// Handle callback here

void setup()
 //Initialize serial and wait for port to open:

 Serial.println("Start WiFi");
 while(WiFi.localIP() == INADDR_NONE) {



void loop()
 // read the input on analog pin:
 int sensorValue = analogRead (12);
 Serial.println (sensorValue);

 // convert into to char array
 String str = (String)sensorValue; 
 int str_len = str.length() + 1; // Length (with one extra character for the null terminator)
 char char_array[str_len]; // Prepare the character array (the buffer) 
 str.toCharArray(char_array, str_len); // Copy it over 
 // publish data to MQTT broker
 if (client.connect ("LaunchPadClient")) {
 client.publish ("Potentiometer", char_array);
 Serial.println("Publishing successful!");
 client.disconnect ();


void printWifiStatus() {
 // print the SSID of the network you're attached to:
 Serial.print("SSID: ");

 // print your WiFi shield's IP address:
 IPAddress ip = WiFi.localIP();
 Serial.print("IP Address: ");