Tuesday, May 12, 2015

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


No comments:

Post a Comment