Using android phone to control remote dimmer

Hi all,
i am starting a project that i develop android apps to control a remote dimmer through arduino board.
however, the signal must pass through the arduino board, it also need a RS-232 port to connect a RS-232 wireless controller and the controller control the remote dimmer.

a few questions to wait any suggestions.

do i need to buy a arduino wifi shield?
could the board do the above opeartion at the same time?

actually i am new to arduino.

please give me any suggestions or ask more about the project. =(

To go from phone to Arduino, you could use Blue Tooth, wifi shield, or Ethernet shield with Cat 5 cable.

You can connect a Max232 chip to Arduino to get RS232 output.

The Arduino can most likely do what you need with time to spare. We need more specifics to give more specific information.

cyclegadget:
To go from phone to Arduino, you could use Blue Tooth, wifi shield, or Ethernet shield with Cat 5 cable.

You can connect a Max232 chip to Arduino to get RS232 output.

The Arduino can most likely do what you need with time to spare. We need more specifics to give more specific information.

origianlly the remotre dimmer can be controlled by a remote control(it transmits signal through zigbee),
the remote control need to link up with a remote dimmer before using a sort of functions.
it can set on/off and also the brightness of the light
now i want the android apps replace the functions of remote control.
if i need to do so, i suppose to use a set of devices (android phone >> arduino board as a platform to transmit the signal from wifi to RS-232 and send out to a RS-232 wireless controller>> remote dimmer
so how could i solve this problem?
or wt information you need to know abt this project?

suppose to use....android phone

Through a home network, or over the web?

transmit the signal from wifi

Do you have a wireless router hooked to a home network?

RS-232 and send out to a RS-232 wireless controller

Do you know what messages need to be sent for the wireless controller to work?

Just to let you know, this project requires a fair bit of work. The forum can help you but, you need to be the one to provide effort, show your code, show hardware information, and ask specific questions for you to make progress on your project.

Hi,

I just posted a way to do this using a windows phone, no app required, so it should work with the android. The Arduino doesn't need to be connected with a wifi shield. I used the wireless router in the house, just an ethernet shield and a cable. The Arduino serves up a webpage and then it runs the x10 which do the dimming. So, you access the web page from the android and click the buttons. I have put 'dim and brighten', along with a number of x10 on/off command buttons. The thing about x10, you have to select a specific address and then send an on, then you can dim/brighten. Here is the video link. I posted the code in a previous post.

Regards,
Walt,

waltsailing:
Hi,

I just posted a way to do this using a windows phone, no app required, so it should work with the android. The Arduino doesn't need to be connected with a wifi shield. I used the wireless router in the house, just an ethernet shield and a cable. The Arduino serves up a webpage and then it runs the x10 which do the dimming. So, you access the web page from the android and click the buttons. I have put 'dim and brighten', along with a number of x10 on/off command buttons. The thing about x10, you have to select a specific address and then send an on, then you can dim/brighten. Here is the video link. I posted the code in a previous post.

Arduino Webserver X10 Control - YouTube

Regards,
Walt,

i got your point, but i think it doest work in my project,
because i need to assume that there will have 2 or more lighting dimmer to connect my android phone through arduino board,
if i change the shield as Ethernet, capacities will be the problem.
in my project, i got some idea now,
i used the serial device tester,software, to send hex to the RS232 wireless controller, it's work!
i can turn the light on and off and also the brightness.
but some fuctions do not function. ( i will show it later)
so, in other word, i need the arduino board to send out hex(should it be byte?) through serial port.
i will keep trying my work.
all guys could share your ideas here :slight_smile:

ah... another question, is it possible to directly connect my arduino uno r3 board TX and RX and gnd pin to RS232 serial port pin 2,3 and 5?

ah... another question, is it possible to directly connect my arduino uno r3 board TX and RX and gnd pin to RS232 serial port pin 2,3 and 5?

You need a max232 chip for that.

A link for example: http://sodoityourself.com/max232-serial-level-converter/

cyclegadget:

ah... another question, is it possible to directly connect my arduino uno r3 board TX and RX and gnd pin to RS232 serial port pin 2,3 and 5?

You need a max232 chip for that.

A link for example: Loading...

so i cant directly wire up those of pins of TX, RX and GND?

cyclegadget:

ah... another question, is it possible to directly connect my arduino uno r3 board TX and RX and gnd pin to RS232 serial port pin 2,3 and 5?

You need a max232 chip for that.

A link for example: http://sodoityourself.com/max232-serial-level-converter/

so i cant directly wire up those of pins of TX, RX and GND? and why?

The voltages of RS232 are different and sometimes higher.

Look on this page about the middle area where it talks about voltages. RS-232 - Wikipedia

cyclegadget:
The voltages of RS232 are different and sometimes higher.

Look on this page about the middle area where it talks about voltages. RS-232 - Wikipedia

how abt the device has the input voltage of 5V?

Hi,
I made an android app to control your arduino over wifi / web. It has a few buttons that you can give a name and a string to send to the arduino.
the app can be found here: https://play.google.com/store/apps/details?id=com.marquesoft.ArduinoController&feature=search_result.
And the example sketch here: http://db.tt/GMoyi6hg.

how abt the device has the input voltage of 5V?

With no datasheet, I can not say much. However, I think the 5V part is referring to the charging voltage of the battery.

i tried to directly wire up from arduino to RS-232 ( yea seriously). and I try to write a program.

unsigned long = dimmerON = 0x02FF400D; // i tested those of hex (02 FF 40 0D) can be turned on the remote dimmer by serial device tester
unsigned long = dimmerODD = 0x02FF000D; // and this hex can turn off the remote dimmer

void setup()
{
Serial.begin(9600);
}

void loop()
{
if (Serial.available () == 0)
{
Serial.print ( dimmerOFF,HEX);
}

if ( Serial.available () == 1)
{
Serial.print (dimmerON, HEX);
}
}

i tested this program and i watched the status from the serial monitor, it kept print the value 2FF000D repeatedly
while i send 1 to the monitor, it changed the value to 2FF400D but still repeatedly
and i tried to send another num to monitor, it stopped.

how come the value keep looping, how can i send hex once only?

however i tried the above step after i connected between TX,RX and GND of arduino board and 232port 2,3,5 pin.
i sent 1 out , i could see the monitor that showed the hex of 2FF400D, but the remote dimmer didnt turn on.
what's the problem here?

011345687:
i tried to directly wire up from arduino to RS-232 ( yea seriously). and I try to write a program.

i tested this program and i watched the status from the serial monitor, it kept print the value 2FF000D repeatedly
while i send 1 to the monitor, it changed the value to 2FF400D but still repeatedly
and i tried to send another num to monitor, it stopped.

how come the value keep looping, how can i send hex once only?

however i tried the above step after i connected between TX,RX and GND of arduino board and 232port 2,3,5 pin.
i sent 1 out , i could see the monitor that showed the hex of 2FF400D, but the remote dimmer didnt turn on.
what's the problem here?

Reference the serial.available() function: Serial.available() - Arduino Reference .

Serial.available() returns the number of data bytes available. In your code the statement

 if (Serial.available () == 0)

means that every time there are 0 bytes available to read,

Serial.print ( dimmerOFF,HEX);

will be executed.

What you want to do is test for when Serial.available() > 0 and then read the byte from serial. You can then have an if statement, or switch statement to determine what should happen when a given byte is received.

TKHouse:

011345687:
i tried to directly wire up from arduino to RS-232 ( yea seriously). and I try to write a program.

i tested this program and i watched the status from the serial monitor, it kept print the value 2FF000D repeatedly
while i send 1 to the monitor, it changed the value to 2FF400D but still repeatedly
and i tried to send another num to monitor, it stopped.

how come the value keep looping, how can i send hex once only?

however i tried the above step after i connected between TX,RX and GND of arduino board and 232port 2,3,5 pin.
i sent 1 out , i could see the monitor that showed the hex of 2FF400D, but the remote dimmer didnt turn on.
what's the problem here?

Reference the serial.available() function: Serial.available() - Arduino Reference .

Serial.available() returns the number of data bytes available. In your code the statement

 if (Serial.available () == 0)

means that every time there are 0 bytes available to read,

Serial.print ( dimmerOFF,HEX);

will be executed.

What you want to do is test for when Serial.available() > 0 and then read the byte from serial. You can then have an if statement, or switch statement to determine what should happen when a given byte is received.

ok, i have just tested with a very simple program
the code are as following:

unsigned long dimmerON = 0x02ff400d;

void setup()
{
Serial.begin(9600);
}

void loop()
{
if (Serial.available() >0)
{
Serial.print(dimmerON,HEX);
delay(5000);
}
}

the program is just to test if i can send hex number through serial communication
if it is work, i think the lighting dimmer could turn on by the hex number.
but it doesnt work.
in the above program.
do i really send a hex number out through serial port?

Two things,

Firstly, there are three different functions to write out serial data:

serial.print(), serial.println(), and serial.write() .

Looking at the reference for serial.print(), what actually happens is that the data is sent to the serial port in a human-readable format, but in the format specified by the second parameter.

So the number 65 sent with serial.print(65, HEX) would write 0x41 (65 in HEX) to the serial port, but using human readable characters. So in actuality, the binary values 0x34 and 0x31 would be sent (producing ASCII characters '4' and '1' on the serial monitor). This function is primarily intended to make monitoring and debugging easier, while not being what you need in your case.

So in your case, Serial.print(dimmerON,HEX) is actually writing the following bytes to the serial port:
0x30
0x32
0x66
0x66
0x34
0x30
0x30
0x64

You need to use the serial.write() that will actually write the binary value for 0x02ff400d to the serial port. You will probably want to use the method using an array of bytes.

Secondly, it will likely not be quite that simple. RS-232 has more to its protocol than simply writing serial data on the lines. I am not certain, but it does not appear that you are using any type of RS-232 driver chip. I've never implemented anything using RS-232, so I'm definitely not experienced in working with it.

There is an Arduino Software RS-232 tutorial: http://www.arduino.cc/en/Tutorial/ArduinoSoftwareRS232

There are also Arduino RS-232 shields available.

Either the software version with a driver chip, or the shield version are probably your best options. If you're working on an UNO, the shield will probably use the available serial port, so if you'll be reprogramming a lot it might be in your interest to look at the version using software serial.

TKHouse:
Two things,

Firstly, there are three different functions to write out serial data:

serial.print(), serial.println(), and serial.write() .

Looking at the reference for serial.print(), what actually happens is that the data is sent to the serial port in a human-readable format, but in the format specified by the second parameter.

So the number 65 sent with serial.print(65, HEX) would write 0x41 (65 in HEX) to the serial port, but using human readable characters. So in actuality, the binary values 0x34 and 0x31 would be sent (producing ASCII characters '4' and '1' on the serial monitor). This function is primarily intended to make monitoring and debugging easier, while not being what you need in your case.

So in your case, Serial.print(dimmerON,HEX) is actually writing the following bytes to the serial port:
0x30
0x32
0x66
0x66
0x34
0x30
0x30
0x64

You need to use the serial.write() that will actually write the binary value for 0x02ff400d to the serial port. You will probably want to use the method using an array of bytes.

Secondly, it will likely not be quite that simple. RS-232 has more to its protocol than simply writing serial data on the lines. I am not certain, but it does not appear that you are using any type of RS-232 driver chip. I've never implemented anything using RS-232, so I'm definitely not experienced in working with it.

There is an Arduino Software RS-232 tutorial: http://www.arduino.cc/en/Tutorial/ArduinoSoftwareRS232

There are also Arduino RS-232 shields available.

Either the software version with a driver chip, or the shield version are probably your best options. If you're working on an UNO, the shield will probably use the available serial port, so if you'll be reprogramming a lot it might be in your interest to look at the version using software serial.

i tried Serial.write() , and this actually send 02 FF 40 0D to the serial port, i used a software to check it
but it still cannot turn on the dimmer.but i cant use the array of byte, it's because when i use the array , it will have an error with overload with stuff

and i know that the dimmer has the following setting
baud rate : 9600
parity : none
data bits: 8
stop bits : 1
handshaking : none

in fact, does it any library need in my case? or sample??