Interfacing 12V logical "1" signal to arduino - how?


I have wind sensor with NMEA serial output.
Logical interface - not problem, i use NMEA library.

But i have trouble with physical interface:

Output from sensor is serial, but this is nor ordinary RS232 or RS422/485.
This is "high voltage" logical.

So. I have 12 V for logical "1" and i have 0V for logical "0" from this device.

And how i see on oscilloscope - if i change supply voltage of sensor - output logical "1" change equal as supply.

Voltage change in my system from 8.5 to 15 V (lead - acid bat with charger) and not possible to use any stabilization.

How i can connect this sensor output with variable logical "1" level to my RX pin of ATMEGA328P on my board?

Please help.

Sorry my bad English.

I assume the wind sensor is outside and the Arduino is inside. In which case you need isolation from lightning. An appropriate optical isolator will both protect your Arduino (and you) as well as translate from any voltage to 5V.

If i understand right - i connect pin 1 to my signal source (sensor output) with resistor on serial, pin 2 to ground.
Pin 3 connected to ATMEGA pin and this pin configured with pull - up enable and pin 4 connect to ground. Right?

So in this case - signal was inverted! If i have "1" on sensor side - i have "0" on input side...

i try - may be it work... If not - i reply here...





Thanks very much!

You are welcome.

Wow. That was quick. Did you have any trouble with the signal being inverted?

I don't have any troubles with signal inversion. I think, this schematic be in mind of sensor designers :slight_smile: And sensor make inversion of output signal inside. And i make inversion second time...

I was on my local supplier's website yesterday and dropped a pack of 4N25s in my basket.

I notice, looking at this, that the 4N25 also brings the base out to a pin. I was wondering why? I imagine it would be useful for testing for example, where the base is controlled manually without having to energise the HV side of things. Any thoughts?

(My link also shows that the OP is exactly right: a series resistor on the input and a pull-up on the signal.)

I have seen phototransistors with a connection to the base. The datasheets indicated it was to bias the transistor: make it more or less sensitive to light. I suspect the same is true for the 4N25. (By I could easily be wrong.)

Chris Savage agrees...

More references...

What's odd is none of the half-dozen datasheets for 4N25 mention what to do with base. Where is the "typical applications" section?

I guess the safest way is to use an isolator... but equally, a couple of transistors could have done the same job with little worry about reverse current ...

But, yeah an opto is a quick way, i generally think of using it with higher voltage apps.

I use this scheme without any problems with this sonic wind sensor:

SMD opto: SFH6156 VISHAY

What difference does 0.3" and 4000 volts against lightning sparcgap of 1 mile and a million volts.
It's better place a overvoltage protection on the cable from the weatherstation and keep the aurdino as isolated as possible (no grounding)


It is not so much protection against lightning, that immunity to radio-frequency interference for long lengths of cable. Indeed, with an optocoupler, we are in the presence of a symmetrical connection with a strong current. NMEA provides a current of 4 mA.
The other important point is the elimination of problems potencial differences between the sensor and the micro-pross. For example, the sensors can have a different power supply from the power supply Micropross.

In the case of a short length of cable between the sensor and the Micropross we allow our sensors to connect the NMEA signal OUT - to the UART Rx Micropross.


CV7SF-RaspBerry_Pi-ENG 200314.pdf (151 KB)