Show Posts
Pages: [1]
1  Topics / Home Automation and Networked Objects / Re: Using android phone to control remote dimmer on: November 16, 2012, 03:59:12 am
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??
 
2  Topics / Home Automation and Networked Objects / Re: Using android phone to control remote dimmer on: October 27, 2012, 12:19:38 pm
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: http://www.arduino.cc/en/Serial/Available .

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?
3  Topics / Home Automation and Networked Objects / Re: Using android phone to control remote dimmer on: October 22, 2012, 10:13:33 am
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?


   
4  Topics / Home Automation and Networked Objects / Re: Using android phone to control remote dimmer on: October 15, 2012, 01:46:06 am

 The voltages of RS232 are different and sometimes higher.

Look on this page about the middle area where it talks about voltages. http://en.wikipedia.org/wiki/RS-232
how abt the device has the input voltage of 5V?

5  Topics / Home Automation and Networked Objects / Re: Using android phone to control remote dimmer on: October 14, 2012, 09:56:31 pm
Quote
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?
6  Topics / Home Automation and Networked Objects / Re: Using android phone to control remote dimmer on: October 14, 2012, 09:56:03 pm
Quote
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?
7  Topics / Home Automation and Networked Objects / Re: Using android phone to control remote dimmer on: October 14, 2012, 09:44:50 am
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.

http://youtu.be/0a1vkSB2LQY

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 smiley

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?
8  Topics / Home Automation and Networked Objects / Re: Using android phone to control remote dimmer on: October 01, 2012, 12:16:57 am

 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?
9  Topics / Home Automation and Networked Objects / Using android phone to control remote dimmer on: September 30, 2012, 03:07:46 pm
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. smiley-cry
Pages: [1]