Serial Monitor communication issue.

Hey there,

I've been working on a project that involves an ePIR motion sensor (SEN-09587) that supports a serial communication mode. This sensor has all kinds of configurable properties through the serial communication mode, so I figured the best way to calibrate it would be to create a debug environment using the serial monitor and send commands to it that way.

I connected the ePIR TX and RX pins to the respective RX and TX pins on the Arduino and began testing. I quickly found out that this method was not going to work. As an example, you can read the state of motion detection by sending the character command 'a' (0x61). The ePIR will then respond with a Y or an N to indicate whether it had detected motion or not. This works all fine and good in code, but not through the serial monitor.

What I was trying to do was send commands to the ePIR through the serial monitor instead of hard coding the messages in code to make for quick adjustments, as you can program sensitivity through the commands. When I tried sending 'a' through the serial monitor, I would get no response from the ePIR. This seemed to be because that the arduino was receiving the message instead (as indicated by a flashing RX light upon pressing send) but was not forwarding it on to the ePIR. If I coded Serial.write('a'); instead, I would see the response I was looking for, but the write command automatically prints to the serial monitor. So, I would get output that looked like aN or aY, combining the original write command and the response.

What would be really nice is if there was some kind of passive serial mode for the Arduino serial monitor that would not cause the messages to stop at the Arduino but would continue to be sent through the TX and RX pins instead. In addition, it would be cool if the Serial.write() command did not automatically print the input to the serial monitor unless it was read from the serial buffer and printed as such. This way you could employ methods to avoid the echo effect of sending a command and seeing it on the serial monitor output.

I pulled my hair out for a few hours trying to figure out what I was doing wrong, but after tearing things apart, I finally figured that it may not have been a result of my doing but a software limitation. Can anyone second me on this? I will admit, I am pretty new to serial communications on the Arduino, so if I missed something or if there is a way around this, please feel free to share.

TL;DR: It would be really awesome if I could interface the ePIR indirectly through the Arduino by using the serial monitor. Also, it would be cool to disable the echo in the serial monitor caused by Serial.write() commands.

Thanks in advance! :smiley:

Just so I'm clear ... you have the ePIR serial transmit connected to the Arduino serial recieve (RX)?

You then use Serial Monitor to try to communicate with the ePIR?

Yeah, the ePIR TX goes to the Arduino RX, and the ePIR RX goes to the Arduino TX. Like I said, when I send the command to the ePIR in code as Serial.write('a');, the serial monitor shows a response, like 'aN' or 'aY'. The 'a' being the echo from the serial write command and the 'Y'/'N' being the response, indicating motion or not.

But, if I type 'a' into the serial monitor and click send, I get nothing.

This is just an example, but my goal is to use the other available ePIR commands to program and modify the ePIR's sensitivity through the serial monitor on the fly by just typing in the necessary command and sending it.

Yeah, the ePIR TX goes to the Arduino RX, and the ePIR RX goes to the Arduino TX

A depiction of how data will flow...

  PC       Arduino       ePIR

  TX  -->  RX       <--  TX

  RX  <--  TX       -->  RX

There is no way the ePIR and PC can communicate to each other. If you change the wiring so the ePIR and PC can communicate then the Arduino and ePIR will not be able to communicate.

I suggest using second serial port on the Arduino to communicate to the ePIR. If you don't have a Mega, NewSoftSerial (or SoftSerial) should get you the second serial port. Add a "pass through" to your Sketch so that anything coming from the PC is sent on to the ePIR and vice-versa.

You know, I kinda feared as much when I started doing some more in-depth testing. I don't have a Mega, I've got the Duemilanove, so I will give NewSoftSerial a shot. It looks like the perfect alternative and looks really easy to use! I think that "pass through" suggestion will work like a charm. Thanks a million!