Tuesday, May 12, 2015

TI CC3200 LaunchPad IoT using Jotiz RESTful Services

TI CC3200 LaunchPad IoT with Sharp LCD using Jotiz RESTful Services

I present here a series of blogs that are intended to enable the use of ‘things’ in the Internet of Things IoT complementing Jotiz.

The CC3200 Launchpad from Texas Instruments is new generation 32 bit MCU with SoC and WiFi built it. In this article, I present the CC3200 micro-controller and its ability to read the Jotiz web service which gives the Panchanga. The development board is the size of a credit card and comes as an attractive red PCB. I also attached a Sharp 96x96 LCD booster pack on the MCU board to display the results. All this, I put into an acrylic enclosure with spacers and screws.

The Simplelink WiFi CC3200 Launchpad was connected to a Windows 7 laptop through the USB port. Remember to download the drivers for CC3200 from TI website. To develop the program, the Open Source Energia based on the Arduino IDE was used.


1.      Energia - http://energia.nu/
2.      Arduino - http://www.arduino.cc/
3.      Texas Instruments CC3200 Launchpad - http://www.ti.com/tool/cc3200-launchxl

How the program works:

It uses the WiFi library, JSON and the Sharp booster pack libraries. It fetches the Panchanga data from the Jotiz REST service, extracts the relevant information from the encoded JSON and displays on the LCD.

Based on the quality of time as determined by the Panchanga many common day to day decisions like attending an interview, choosing the right moment to discuss an idea or a raise, travelling, buying property, investing can be done with less negative consequences.

Excerpts from the code

  // Initializing the LCD and WiFi
  LCD_SharpBoosterPack_SPI myScreen;
  uint8_t k = 0;
  WiFiClient client;
  char server[] = "jotiz.com";
  boolean offline = false;
  #elif defined(__CC3200R1M1RGC__)
// for __CC3200R1M1RGC__ DIV2 = 4 MHz !

  if (WiFi.status() == WL_NO_SHIELD) {
    myScreen.text(10, 25, "FAIL");

  while (wifiStatus != WL_CONNECTED) {
    wifiStatus = WiFi.begin(WIFI_SSID, WPA_PASSWORD);
    if (wifiStatus == WL_CONNECTED) {
      myScreen.text(10, 25, "Wifi: OK");

  if (!offline) {
    while (WiFi.localIP() == INADDR_NONE) {

    IPAddress ip = WiFi.localIP();

    if (client.connect(server, 80)) {
      client.println("GET /rest/resource.php?method=panch&format=json HTTP/1.1");
      client.println("Host: jotiz.com");
      client.println("Content-Type: application/json");
      client.println("Connection: close");

  if (!offline) {
    for (int i=0; i < 47; i++) {
      String jsonstr = "";
      while (client.available()) {
        char c = client.read();
        jsonstr += String(c);
      String js = jsonstr.substring(jsonstr.indexOf("{"));
      char* jstr = strcpy((char*)malloc(js.length()+1), js.c_str());

      aJsonObject* root = aJson.parse((char *)jstr);
      aJsonObject* dd = aJson.getObjectItem(root, "dd");
      aJsonObject* mm = aJson.getObjectItem(root, "mm");
      aJsonObject* yy = aJson.getObjectItem(root, "yy");
      aJsonObject* hh = aJson.getObjectItem(root, "hh");
      aJsonObject* mt = aJson.getObjectItem(root, "mt");
      aJsonObject* dw = aJson.getObjectItem(root, "dw");

      aJsonObject* ui = aJson.getObjectItem(root, "unodeInausp");
      aJsonObject* si = aJson.getObjectItem(root, "saturnInausp");
      aJsonObject* di = aJson.getObjectItem(root, "deathBearing");
      aJsonObject* da = aJson.getObjectItem(root, "directionInausp");

      char buf1[10] = "";
      strcat(buf1, yy->valuestring);
      strcat(buf1, "-");
      strcat(buf1, mm->valuestring);
      strcat(buf1,  "-");
      strcat(buf1, dd->valuestring);

      myScreen.text(10, 25, buf1);
      char buf2[5] = "";

      strcat(buf2, hh->valuestring);
      strcat(buf2,  ":");
      strcat(buf2, mt->valuestring);
      myScreen.text(10, 35, buf2);

      myScreen.text(10, 45, "Rahu");
      myScreen.text(70, 45, ui->valuestring);
      myScreen.text(10, 55, "Saturn");
      myScreen.text(70, 55, si->valuestring);
      myScreen.text(10, 65, "Death");
      myScreen.text(70, 65, di->valuestring);
      myScreen.text(10, 75, "Direction");
      myScreen.text(70, 75, da->valuestring);

      free (jstr);
      delay (500);


MyScreen is the LCD screen - SHARP 96x96 pixels. The board on startup initializes the WiFi client, sends the SSID and Password to authenticate as an user and obtains an IP address. After getting the IP address, it uses the internet to connect to Jotiz and make a RESTful request. The JSON string received is broken up into its elements and displayed. 

Read more about this in the upcoming book “Vedic Machine

No comments:

Post a Comment