Saturday, March 2, 2013

Arduino-based Greenhouse Controller Walkthrough


All of the documentation(circuit schematics, source code, project parts and costing) will be available shortly, for now, here's a walk through our project.


Arduino-based Greenhouse Controller: On site visit

For our Design Project(Thesis II) subject, we developed a system that automates the irrigation, ventilation and lighting of a greenhouse based on readings such as temperature, relative humidity, soil moisture and current time. The readings are displayed on a 20x4 LCD and logged every minute to the on-board SD card.
The user can input threshold values for temperature, soil moisture and time. The values act as a limit, once the limit is reached, an actuator will be triggered. For example, if the user set a threshold value of 30 °C, and the current temperature reading is above 30 °C, say 33 °C, the ventilation system will be activated. Same goes to the soil moisture sensor. Once the soil moisture corresponds to a "dry" reading, the solenoid valve will be activated and the drip irrigation will start to water the plants. For the lighting system, the user can specify the exact hour on which the bulb will be switched on.




C# Programming: Sending SMS using AT Commands

Here's the C# Windows Form version of my SMS sender program originally created in Python 2.7



 Here's the text message from the modem


The code is on my Github page.


Sunday, February 17, 2013

C# Programming: Basic Paint Program

I've created this program last semester, it's just a proof of concept for now. I plan to refine this code and add new features to it. As of  now, it has only two features, paint and erase. Left click to paint and right click to erase. Here's a video demonstration



Feel free to copy the code here.

Python Programming: Sending SMS using AT Commands

Introduction
 
In these project,  will be using Python 2.7 as our programming language. In my opinion, Python is the most elegant programming language (C is my second pick). Its syntax is so concise and readable that it's like writing a pseudo-code that actually runs on a machine. The first programming language that I've learned from school (during my freshmen year) is Java but I was lost because I felt like it's so verbose and complex. I was new to programming back then and OOP was way  out of my league. During the summer, I followed my older sister's advice to study C first before jumping into Java and I was not disappointed. It helps to first understand a procedural language before diving into OOP languages such as Java or C#. C is a good language but I felt like I would need to write dozen lines of code just to accomplish a simple task (like sending SMS). Then I researched about scripting languages that are easy to learn and scalable and Python was always popping out on the list. I was surprised on how easy it is to learn the language and perform so many tasks in only a few lines of code. It doesn't have a steep learning curve unlike Java or C++. Its syntax is so clear that it's like writing an imperative statement rather than programming a code.

AT Commands 
To communicate with the USB Modem, we'll be using AT Commands. Don't worry, it's easy to use these commands and only a few will be needed here. Here's a tutorial to help you.

Materials

USB Modem
For this project, I used my SmartBro broadband, but any USB broadband should work. I've also tested this on a Globe broadband and the results are just the same.



PC or Laptop
The PC/ laptop should have Python 2.7 installed and the PySerial library to enable serial communication.

Cellphone
To test the program, we'll send it to a recipient phone

Determining the COM Port number of the USB Modem

Go to device managers, find modems and you should see your usb modem there. Right click on properties



On the USB Modem Properties, click on the Modem tab, the Port here should be the same as the one written in the program


Here's a sample run



As always, the code is available in my Github page, feel free to build upon it and add new features to it.
I hope this article helped you. In the next post, I'll be combining this capability to my previous project, the Arduino-based Temperature Monitor, so that we'll be able to get the readings through SMS.

Arduino-Based Temperature Monitor


Here's a simple hardware project that I've done last semester based on my Arduino Uno board. It uses an LM35 temperature sensor as an input device and a 2x16 LCD as its output device.

LM35 Configuration

If you're new to Arduino or programming in general, I suggest that you first read their tutorials to be familiar with the syntax and semantics. To interface the LCD to the Arduino, here's an LCD Tutorial. The LM35 temperature sensor produces an analog voltage directly proportional to temperature with an output of 1 mV per 0.1°C (10 mV per degree). The sensor accuracy is around 0.5°C, and in many cases you can use integer math instead of floating point.


Schematic and breadboard prototype using fritzing.


The code is in my Github page.


Saturday, February 16, 2013

Java Programming: Palindrome

Description:
A string is a palindrome if it reads the same forward and backward.The words “mom,” “dad,”
and “noon,” for instance, are all palindromes.

Problem:
Write a program that prompts the user to enter a string and reports whether the string is a palindrome.

Solution:
One solution is to check whether the first character in the string is the same as the last character. If so, check whether the second character is the same as the second-to-last character. This process continues until a mismatch is found or all the characters in the string are checked, except for the middle character if the string has an odd number of characters.

To implement this idea, use two variables, say low and high, to denote the position of two characters at the beginning and the end in a string inputString. Initially, low is 0 and high is inputString.length() – 1. If the two characters at these positions match, increment low by 1and decrement high by 1. This process continues until (low >= high) or a mismatch is found.

The solution is in my Github page.

Here's a test run