Serial communication via optocouplers

Hi!
I am trying to recreate a circuit, that works just fine using my Arduino Nano, using a NodeMCU (to get wifi connectivity).

That is working is a circuit that sends requests from the microcontroller to another device (Rego 600 heatpump) and recieves responses back. It is a serial communication via a couple of optocouplers.

The working circuit looks like this (see nano circuit drawing attachment).

There are a few peculiar things about this circuit:

  1. The responses from the Rego 600 seems to be inverted (since the working circuit inverts TX from the Rego when passing them on to RX on the Nano)
  2. When recieving data the Rego seems to interpret a voltage betveen 0,7V and 1,7V as a logical "1" (since it only works using a 1-2 kOhm resistor before the optocoupler on the sending Nano side. Normally you apparently use a much smaller resistor, but then the circuit doesn´t work. (see simulation attachment)

So far everything is well, but when I replace the Nano with a ESP8266-based NodeMCU and adjust the circuit to the 3.3V world of ESP8266 the circuit does not work any more (see NodeMCU circuit drawing attachment).

I tried adding a led on the Rego TX line to see if it seems to send something to the NodeMCU, and that led does light up just after the NodeMCU has sent its request to the Rego. However nothing seems to end up in the serial in buffer of the NodeMCU.

I also tried different size pull up resistors in the RX line on the NodeMCU RX (4.7, 10 and 100 kOhm).

Does anyone see what I am doing wrong here.
Please explain in simple terms, since i am quite the noob and have pretty much just copied the original Arduino based circuit.

If there is a way of getting this to work without changing anything on the Rego side of the optocouplers it would much appreciated. I would prefer not to tinker to much on that side since I am a bit afraid of frying the Rego that heats our home and hot water :slight_smile:

One additional note; I use software serial for the communication. The "usual" software serial on the Nano and the ESP8266-specific software serial on the NodeMCU. These libraries have been working fine on the boards in other projects. In all other respects the code is the same on the Nano and the NoceMCU.

copied the original Arduino based circuit

Link please?

Link please?

http://rago600.sourceforge.net/

oh, and one more thing; the simulation is not made with exactly the same optocoupler as I use in my circuit.

According tointerface instructions, it should be RS232, not TTL (0-5V logic)

NOTE: DON'T FORGET TO CLICK the blue "TRANSLATE" button

ivt_serial.pdf (16.7 KB)

raschemmel:
According tointerface instructions, it should be RS232, not TTL (0-5V logic

I think it states that the Rego communicates using..:

"Communication allways using 19200 bps, 8 bit, no parity, 1 stop bit (19200/8N1). This is 5V CMOS 4000 (TTL) signals"

I think the talk about RS232 on that page is about creating an interface that can translate from the Regos CMOS TTL to an RS232 interface

And I do get it to work on my Arduino Nano

But perhaps I misunderstood something

raschemmel:
NOTE: DON'T FORGET TO CLICK the blue "TRANSLATE" button

Sorry, I don't understand. What do you mean by that?

Where did you get the REGO600 connector pinout info ? (why are you using the DB9 pins you chose ?

Where did you get your interface info ?
It doesn't look like you are using JP1 shown in the second screenshot I posted. Also you are using different pins.

Sorry, I don't understand. What do you mean by that?

That page comes up in a non-english language.
I used Google Translate to read it.
Are you in an English speaking country ?

  1. I got the pins from this image (on the page I linked to):http://rago600.sourceforge.net/generic_com.gif

  2. The page I linked to is divided into two parallell columns, the left side is in Czech I think, and the right hand side is in English.

  3. And I am in a country where we speak netiher Czech nor English :slight_smile:

raschemmel:
It doesn’t look like you are using JP1 shown in the second screenshot I posted. Also you are using different pins.

JP1 is replaced by the arduino nano :slight_smile:

JP1 is replaced by the arduino nano :slight_smile:

Ok, got it.

The added led in the NodeMCU circuit is the reverse polarity of the opto led. both leds should have cathode
facing GND.

Can you add component designator labels in your schematic that match the schematic I posted from the
link you posted here ?

If you can't get it working you can try a level converter. You would need two CD4050BE ICs.
One with Vcc = 3.3V to convert 5V logic to 3.3v.
and
one with Vcc= 5V to convert 3.3V logic to 5V.

The output voltage is set by the Vcc .
Inputs can exceed Vcc.m
This chip has a 100% success rate for any kind of
circuit requiring level conversion. There are other
level converters but this has always worked for
me. Just duplicate tge circuit you used for the
Nano and use level converters.

It is sometimes wise to add a 10k-100k base discharge resistor on opto isolators to get faster edges.

It is so annoying that I don´t get it to work using the nodemcu, when I get it to work using the nano.
I even seems to work if I let the nodemcu send the request to the rego, and have the nano read the response

'"It is so annoying that I don´t get it to work using the nodemcu, w"

You know that saying "Patience is a virtue' ?
In electronics you have to be very 'virtuous'.

You can connect two uart if they are compatible electrically.
Otherwise you must use RS232 to TTL converter (max232).
Rgrds

Doesn’t look like you’ve adjusted both resistor values on the NodeMCU side to compensate for the lower voltage.

  • For the NodeMCU, try changing the 4.7K to 3.3K to maintain the 1mA max collector current.
  • For the IRLED resistor, 2K worked on the 5V Arduino, so the current was (5-1.2)/2K = 1.9mA.
    So … for the NodeMCU, try 1K, the current will be (3.3-1.2)/1K = 2.1mA

NodeMCU D1 and D2 aren't UART pins.
Are you trying to implement SoftwareSerial (using D1 and D2)?

NodeMCU hardware UART [Serial] is available on GPIO1, GPIO3 or (D7 and D8 by using Serial.swap(); ). The other UART (TX only) is on D4 [Serial1].

https://arduino-esp8266.readthedocs.io/en/latest/reference.html#serial

runaway_pancake:
NodeMCU D1 and D2 aren't UART pins.
Are you trying to implement SoftwareSerial (using D1 and D2)?

Yes, exactly.

What if you use NodeMCU's 5V instead the Dsub_pin4?
(Assuming you're powering the NodeMCU via USB.)