I've got an energy monitor with an RS232 output (with an RJ45 connector). I've managed to track down ground/vcc/transmit and receive and tried connecting it up to the Arduino.
Transmit pin from device is hooked up to receive pin (0). Ground pin from the device is hooked up to ground pin (14). AFAIK I think I've got the connections right, but I don't seem to be able to read anything:
void useEthernet()
{
digitalWrite(resetPin, LOW); // put reset pin to low ==> reset the
delay(200);
digitalWrite(resetPin, HIGH); // put reset pin to low ==> reset the
delay(2000);
Ethernet.begin(mac, ip);
}
The transmit pin on the device is outputting 3V. I then tried connecting the transmit pin to pin 2 on the arduino and using the Button program to turn the led on pin 13 whenever the pin state is low. I can then see the led blink on every 6 seconds (I know this is the frequency the energy monitor outputs data). Is the voltage on the transmit not high enough for the serial interface to deal with it? Have I screwed up the wiring afterall? Help! ;D
RS232 is inverted with respect to TTL.
Also, the negative-going voltages are not really recommended for connection to an Arduino.
Get a Max232 or similar.
Thanks for your response - though I'm now even more confused
The transmit pin is outputting positive 3V, appearing to vary between 0V and 3V whilst sending data (I hooked it up to the analog pins and saw the value move between 0 and 640). I think I might be wrong in having said its RS232 output since I thought RS232 output 12V on those pins.
There is a cable which comes with the monitor that goes from its RJ45 output to a DB9 and has a MAX3221 on the DB9. I can successfully connect that to my machine and see the data being output. Is that supposed to be translating RS232 levels to TTL levels?
Ah - fair enough. I've had a bit more of a read up and think I understand it now - the MAX232 turns positive voltage down to zero and negative voltage up to 5V. With that in place the serial pins should hopefully read from the device.
As for the MAX3221 in the cable - it appears to be some kind of power saving device that cuts off all voltage if it doesn't see anything going through it. Or at least that's what I can make of the page on Maxim's website.
As for the MAX3221 in the cable - it appears to be some kind of power saving device
Nope: it's a MAX232-like chip that can run off 3V, with some special battery-saving features.
Your thermostat is not RS-232: it's a 3V (roughly) CMOS device that's getting interfaced to RS-232 by that cable. It may, or may not, have 5V-tolerant inputs that you can directly connect to the Arduino. To be safe, you should hook it up through a 3V-to-5V buffer circuit (there are lots of options for doing this), or, if it's more than a few feet away, by using that MAX3221 cable and adding a MAX232 to the Arduino side.
OK - making more sense now. The MAX3221 is doing the translation from 3V back to normal RS232 levels (I'm presuming the idle 3V output would translate to -12V and a transmitting 0V output would translate to 12V on the RS232 interface on my PC).
Based on what I've read, I think my problem is:
The UART on the Arduino expects either 0V (transmit) or 5V (idle)
My device outputs a 3V when idle - insufficient for the UART to recognise an idle state
Putting a 3V to 5V level converter would boost the idle voltage to 5V whilst preserving the transmit voltage of 0V
That would enable the UART to recognise the idle state vs transmit state
If that's the case, would I be right to say that a board like this would work?
The device has a seperate VCC which runs at 3V. Connections to make:
LV - VCC on device (3V)
LV GRD - GRD on device
LV TXI - Transmit on device
LV RXO - Receive on device
HV - 5V on Arduino
HV GRD - GRD on Arduino
HV TXO - RX on Arduino
HV RXI - TX on Arduino
OK - Horrendously stupid question coming now. I'm using the USB cable to power my arduino (just hooked up to a mains/usb adapter). Whilst I'm doing that, is the USB interface on the arduino providing power on the serial receive line at all times? Would I be right to suggest that whilst I'm using the USB cable I'm not going to be able to use the onboard serial pins? I'm guessing thats the case. And that I'm a complete dumbass
Update: It seems that way afterall. Tested the voltage coming out of the receive pin on the Arduino whilst powered over USB. It's already running 5V. Even if I connect something to the serial controller on the Arduino it isn't going to be able to determine what its sending. Need to try with a normal DC adapter.
Update 2: Now even more confused. Hooked board up to a battery and found voltage coming out on the receive pin. Surely a serial connection from another device is supposed to provide power to that pin, not receive it?