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.


Links:

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__)
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV2); 
// for __CC3200R1M1RGC__ DIV2 = 4 MHz !
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE0);
  #endif

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

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

  if (!offline) {
    while (WiFi.localIP() == INADDR_NONE) {
      delay(300);
    }

    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");
      client.println();
    } 

  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);
      blinkLed(LED1);
      myScreen.text(10, 55, "Saturn");
      myScreen.text(70, 55, si->valuestring);
      blinkLed(LED2);
      myScreen.text(10, 65, "Death");
      myScreen.text(70, 65, di->valuestring);
      blinkLed(LED3);
      myScreen.text(10, 75, "Direction");
      myScreen.text(70, 75, da->valuestring);
      myScreen.flush();

      free(dw);
      ..
      ..
      free (jstr);
      delay (500);

      free(mm);
      .. 
      ..
    }


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”

DIY - MSP430 Launchpad with BMP180 (A farmer's Almanac) complementing Jotiz

Do it Yourself - MSP430 Launchpad with BMP180 complementing Jotiz

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

To start with, I have used a MSP430FR5969(c) Launchpad(c)(r) from Texas Instruments. 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 and a Bosch BMP180 pressure and temperature sensor from Adafruit. All this, I put into an acrylic enclosure with hex spacers and M3 screws.


Links: 

1. Energia - http://energia.nu/
2. Guide to MSP430FR5969 - http://energia.nu/pin-maps/guide_msp430fr5969launchpad/
3. Arduino - http://www.arduino.cc/
4. Adafruit - https://www.adafruit.com/

How the program works:


It uses the wire library, the bmp085 and the Sharp booster pack libraries. It computes the Rahu Kaala, Gullika Kaala, Yamaghantaka and Shoola directions along with the sensors collecting pressure and temperature data from the ambient surroundings.

Based on the quality of time as determined by the Kaala and the pressure and temperature readings, house plants, green house plants and outdoor plants can be watered or checked for damages.

Excerpts from the code

  // Setting the pin modes of the pins connected to the BMP Sensor
  pinMode(P1_6, OUTPUT);
  pinMode(P1_7, OUTPUT);
  digitalWrite(P1_7, LOW);

  // Barometer Sensor
  digitalWrite(P1_7, HIGH);
  …
  …
  // After initializing the sensor, show the pressure and temperature
  showPressureTemp();
  …
  // display the results on the LCD
  myScreen.begin();
  myScreen.setFont(1);
  myScreen.text(10, 5, "Vedic");
  myScreen.setFont(0);
  myScreen.text(10, 30, "Jotiz Clock");
  myScreen.text(10, 40, "(c)devb inc");
  myScreen.flush();  

  delay(2000);
  myScreen.clearBuffer();

  // check for quality of time 
  doTime();
  …
  …

  // compute time
void doTime() {
  float h1;
  nMin++;
  if (nMin > 59) {
      nHour++;
      nMin = 0;
  }
  if (nHour > 23) {
      nDay++;
      nHour = 0;
  }
  if (nDay > 6) nDay = 0;
  h1 = nHour + (nMin / 60);

  switch (nDay) {
  case 0:
    if ((h1 >= 16.5) && (h1 <= 18)) showTime("Rahu  ","W","Sun");
    else if (h1 >= 15 && h1 < 16.5) showTime("Gulika","W","Sun");
    else if ((h1 >= 12 && h1 <= 13.5) || (h1 >= 18 && h1 <= 19.5)) 
showTime("Yama  ","W","Sun");
    else showTimeOnly("Sun");
    break;
  case 1:
    if (h1 >= 7.5 && h1 <= 9) showTime("Rahu  ","E","Mon");
    else if (h1 >= 13.5 && h1 < 15) showTime("Gulika","E","Mon");
    else if ((h1 >= 10.5 && h1 <= 12) || (h1 >= 3 && h1 <= 4.5)) 
showTime("Yama  ","E","Mon");
    else showTimeOnly("Mon");
    break;
  case 2:
    if (h1 >= 15 && h1 <= 16.5) showTime("Rahu  ","N","Tue");
    else if (h1 >= 12 && h1 < 13.5) showTime("Gulika","N","Tue");
    else if ((h1 >= 9 && h1 <= 10.5) || (h1 >= 1.5 && h1 <= 3)) 
showTime("Yama  ","N","Tue");
    else showTimeOnly("Tue");
    break;
  case 3:
    if (h1 >= 12 && h1 <= 13.5) showTime("Rahu  ","N","Wed");
    else if (h1 >= 10.5 && h1 < 12) showTime("Gulika","N","Wed");
    else if (h1 >= 7.5 && h1 <= 9) showTime("Yama  ","N","Wed");
    else showTimeOnly("Wed");
    break;
  case 4:
    if (h1 >= 13.5 && h1 <= 15) showTime("Rahu  ","S","Thu");
    else if (h1 >= 9 && h1 < 10.5) showTime("Gulika","S","Thu");
    else if ((h1 >= 6 && h1 <= 7.5) || (h1 >= 22 && h1 <= 24)) 
showTime("Yama  ","S","Thu");
    else showTimeOnly("Thu");
    break;
  case 5:
    if (h1 >= 10.5 && h1 <= 12) showTime("Rahu  ","W","Fri");
    else if (h1 >= 7.5 && h1 < 9) showTime("Gulika","W","Fri");
    else if ((h1 >= 15 && h1 <= 16.5) || (h1 >= 19.5 && h1 <= 21)) 
showTime("Yama  ","W","Fri");
    else showTimeOnly("Fri");
    break;
  case 6:
    if (h1 >= 9 && h1 <= 10.5) showTime("Rahu  ","E","Sat");
    else if (h1 >= 6 && h1 < 7.5) showTime("Gulika","E","Sat");
    else if ((h1 >= 13.5 && h1 <= 15) || (h1 >= 19.5 && h1 <= 21)) 
showTime("Yama  ","E","Sat");
    else showTimeOnly("Sat");
    break;
  default: 
    break;
  }
}

ShowTime has three parameters - the Kaala event, direction to avoid and the weekday.
Read more about this in the upcoming book “Vedic Machine”


Friday, March 21, 2014

 Ballad DivineMy book 'Ballad Divine - Bhagavad-Gita' is now available at Amazon. It took a few painstaking years to get there, but every moment was worth it. 

The printed book and Kindle editions are available at Amazon - http://www.amazon.com/Ballad-Divine-Bhagavad-Gita-Dev-Bhattacharyya/dp/1495969835/
You may also review the book. Would love to hear about your reactions to the book. 

Several years back, I spoke to a child about Krishna. The child was so delighted even though she could not pronounce the name properly. I felt if just the lord's name could have such a profound effect, his ballad needed to be re-visited. I went through innumerable books spanning nearly 150 years from Annie Besant, Max Mueller, to Swami Vivekananda, Swami Parmananda, Swami Nikhilananda, S. Radhakrishnan, Srila Prabhupada and Swami Dayananda Saraswati to name a few. Of course, inspired by Chaitanya's Kirtans, I spent many-a-day on Sri Aurobindo's Essays on the Gita, Bankim Chandra's - Krishna Charitra -- and Ballad Divine is the final rendition.

Ballad Divine brings back the Bhagavad-Gita in a very easy to read composition; minus the rhetoric. It is an accurate reference of the original and observed facts and uses the same systemic method to divinity. 

Ballad-Divine is organized around the mainstays of Krishna's doctrines, those of philosophy, action, discipline, concentration, knowledge, meditation, devotion and surrender. These pillars are in turn expounded from smaller building blocks. The theme in the sentences are repeated throughout reinforcing the subject. It is styled mostly as a ballad expressing eighteen different chapters by short stanzas; of which some are metrical.

Excerpt from Chapter 4, Lines 7 and 8


When there is fading of dharma 
And increase in infamy and sloth
Then into birth, 
I loose myself going forth. 

For deliverance of good
For destruction of terror
For enthroning of rights 
I am born from one age to another.

Chapter 18, Lines 69 and 70


No mortal performs 
Service that I value more
No other on earth
Is dear to me than the one I adore.

Judge I will 
Those who study
This sacred discourse of ours
Who offer me sacrifice
By knowledge of course. 

Sunday, September 22, 2013

Mithra - forgotten phenomenon

Rev. Martin Luther King wrote a paper on Mithraism in 1949. He also received an A grade on the essay on his presentation skills on an otherwise difficult concept.


I witnessed Mithraism (worship of Mitra) when I was in Rome, Italy. Mithra (AKA Mitra) is Vedic and Zoroaster's view of the powerful phenomenon that guided Sun to spring.

Yes, from winter to spring - a resurrection, a rebirth of the Sun - the procreator, the God of the yesteryears.  

The Vatican Museums and Basilica of San Clemente offered me direct insights into Mithra worship - a likely predecessor to Christianity - a long forgotten history of reconciliation of a prevailing system to the great spiritual movement that was gaining sturdy influence with its purer conception of God.

You can witness the mercy, the power of the Sol-God only in darkness of the labyrinths in the dungeons at San Clemente.

Mithra is the phenomenon that symbolizes the movement of the Sun away from a Taurus culmination of summer solstice. The slaying of the bull - "taurobolium", is so evident in the sculptures in the dungeons in Saint Clemente's basilica. The presence of Ashvins in the rock sculpture; could also be Gemini twins; Saturn giving out the weapon to destroy the bull; Sol and Luna blessing the act; Sirius the dog, the Lunar nodes shown as a serpent and Scorpion (scorpio) all active participants marked the new epoch - the birth of a new era. 

Sunday, August 4, 2013

Venus, Jupiter and Saturn

A new look at Venus, Jupiter and Saturn.

Sukracharya (related to Venus), son of Brighu was vengeful of Vishnu – Vishnu having destroyed their haven and having killed his mother and the ashuras who she had given shelter to. Besides, Brihaspati was the favored one both from his earlier teacher and Brihaspati's father Angiras and the Devas who eventually elected Brihaspati as their own Guru.

Sukracharya, therefore, chose the ashuras (the dark side, if the name permits) as his disciples and being stronger and more powerfully learned than Brihaspati quickly led Ashuras to victory over the Devas.

That was quite a mouthful!

Sukracharya’s progeny became the clan of Purus – Pauravas, the family that fought in the Mahabharata and also Yadus – the dynasty that Lord Krishna belonged to.

Those of us endowed with Venus like features that Sukracharya relates to are – Highly informed and knowledgeable; much better than the competitor but are not always recognized by our managers and tribal leaders, easily capable of winning (victory),  egotist and plagued with vanity and vengeance. The Sukra endowed persons give rise to progenitors that become strong clans. 

Those that fall in line with Jupiter (Brihaspati) get recognition much beyond their worth. Status, favors and recognition come easy compared to other folks who actually deserve it. However, the shortcuts to success only create holes in security; and eventually the downtrend begins to re-instate folks aligned to Sukra (Venus) (who are more hardworking and zealous in their efforts) to take over or rule.

Some victories won by the Venus-driven may also get counteracted by Saturn who is Venus’ friend. It is not unusual to see a strong Venus-Saturn combination leading to Financial and Health problems in a person’s life. It’s a clear indication for those born with strong Venus and Saturn to witness a complete reversal of their fortunes and health two to three times in their lifetime. But, having Sukra as their Guru, these reversals are short-lived and eventually bring forth the victory they deserve.


On the other hand, without a notion of a down trend, Jupiter (Brihaspati) driven persons eventually lose out – either overconfident or too lazy to fight the battles. Jupiter gains in the beginning, the end may be okay with a good Moon combination; but not anywhere close to how it began. Obesity and laziness are Jupiterial trends that can destroy the otherwise spiritually inclined. 

Saturday, June 22, 2013

Super-Moon and Summer Solstice

What a day! What a night! 

The Sun fiercely crossed the Summer Solstice or was it this planet. Never mind the relative motions; the sun was certainly fierce today. 

The moon on the seventh house rose immediately after a deep sunset - was it the moon? It was the Supermoon!

The celestial gods blessed us with quite a sight - the day and the night.

The Sun and the Moon have so many differences - so many conflicts and yet many areas of agreement. This was not their best moments; it was a mere feast for mortal eyes only.

The moon and sun are in constant tensions when they are a quadrant away. The moon in positions 1, 4,7,10 from the sun are never without tensions. Though Varaha Mihira states Full Moon (180 degrees between the sun and moon are good), I tend to differ. 

The Kendrasthans are not good between sun and moon. Neither is the 5th position. Only 3rd, 6th, 8th, 9th and 11th are good combinations between the two fast moving celestial planets. If the moon is blessed by aspects from Jupiter and Venus; the yoga combinations above and the aspects are extremely important indications for happiness and wealth.

Sunday, May 20, 2012

Solar Eclipse


What an irony,
The god that illuminated the day,
Died
The mortals are alive


Wish god remained a little longer
The darkness of the night
Lesser
Evil while god was being reborn


Do gods die?
Was he not at nether-worlds?
Traveling
Perhaps to a neighboring planet


Now comes the worst,
The maiden casts her dark shadows
Sunday Eclipse
Will there be another reprise



Enjoy the Solar Eclipse. Remember - Never look at the sun-god directly; wear appropriate eye glasses and eye protection.