Separate-Ground voltage measurement

Hi,

I got a problem - I am sending telemetry data to my RC with arduino, and it worked. Until I added a voltage divider to measure battery voltage - I learned in a fiery way that RC motor ESC has no common ground on battery and RC receiver side, and connecting them results in burning cables and smoking ESC. So, I now need to find a solution how to separate the Voltage measurement of battery voltage and the telemetry sending. I thought of following solutions:

  1. (Opto-) Decoupled voltage measurement sensor - I cant find such thing, but maybe someone could suggest me a solution?
  2. Decoupling telemetry comm. It is a duplex serial comm, so not too easy to decouple. Maybe there is a simple solution how to decouple a bidirectional serial wire?
  3. Using two arduinos (I use dirt cheap pro minis from china, and I have alot of them), one in voltage measurement ("Measurement"), fed with a DC-DC stepdown buck from the LiFePo4 battery (9.9V), and another fed from the telemetry/receiver circuit ("Telemetry"). Using optocoupler for one-way communication between them. Actually I just need to shove 1 integer every second only one way. Which way of comm would you prefer here? I2C is bidirectional, and probably complex to isolate, would you use simple RX/TX? Would it work just connecting RX of Telemetry Arduino with TX of Measurement Arduino via optocoupler?

I checked my inventory, I have a plenty of simple optos around.

Do you think if I will build 2 simple optocoupler (PC817) conns (sender side - opto in between ground and digital pin, with 330k current limiter in series, receiver side - opto out between the digital pin and gnd, pin side with pullup 10k) would be sufficient? And running this with software serial to communicate between arduinos?

Do post schematic (not Fritzing, proper circuit diagram please) of your complete setup as I can't follow your description.

I cant draw in while in office, but exactly as the schematics here:

GND left and right are of course different ones.

MAP_SIGNAL would be TX, OUTPUT_TO_ARDUINO - RX

Doing 2 such "channels" for software serial comm, one going from Arduino1 to Arduino2, and one in the other direction. Or would just one such "channel" suffice for one way communication?

If you need only one way, this should work fine for a Serial connection (it’s asynchronous anyway). You don’t need both lines connected for Serial.

One thing to consider: the idle state of Serial is high, so your opto is on all the time. That’s not good for battery life. You better add a transistor to switch the optocoupler and reverse the signals, so the opto is active when the line goes low. Then also reverse the output side and you transfer your signal just like that.

You may also consider to use an ATtiny25/45/85 for the voltage measuring job. Much smaller, and even the ATtiny25 should have enough memory to do this job just fine.
schematic.png

Thanks!

My problem is I have to be running my ship at the show this sunday, so have to improvise a bit.

Compared to 20 Ampere DC motor and several servos, I think in the first version I can neglect the effect of the current loss. I have seen people using PC817 with 1.3k resistor, which means less then 5 milliamps extra do not make much weather (I will need to experiment with the resistors a bit). A good mod to consider later however!
I have a 4200mAh battery, so in average runtime would be around an hour. My goal is just make sure I am back to shore when its voltage starts sinking rapidly, meaning end of capacity. Later, I might get an Ammeter added too.

As for ATTiny - I think I even have one, but no programmer for it (I had a selfmade parallel port one, but no parallel port any more on my pc). A few milliamps are not decisive in my case. I have a ton of ProMinis here, so its the easiest way. Wires for the probe and from DC buck soldered directly in the board, and when done, just stuck in a plastic box and epoxied watertight.

Both circuits should work just fine - build it on a breadboard and try it out with two Pro Minis. Your circuit is indeed a bit simpler, and if power is not a concern, go for it (battery power usually means it is a concern).

The value of the resistor in for the opto is indeed not critical, especially in this case as you only need small signals. 1k3 will work, 2k2 may even still work. Whatever you have on hand.

To program a tiny (for the future maybe), you can use an Arduino as ISP. That’s my current method for programming them.

Thanks! I will try the simple one today. Will also check which resistor is the maximum - will breadboard 1k resistor and a 10k potentiometer in series, and see how far I can turn the potentiometer until the comm breaks up. Will probably initially try the setup with Unos, as its easier to use them for breadboard due to full size usb and also connectors for prototype wires, and I can use two of them same time, while I will need to swap ProMinis, as I have only one programmer for them.

Is there a guide how to program ATTiny with Arduino?

PetrOsipov:
Thanks! I will try the simple one today. Will also check which resistor is the maximum - will breadboard 1k resistor and a 10k potentiometer in series, and see how far I can turn the potentiometer until the comm breaks up.

Then your final design should have no more than half that value - you don't want to start losing bits in the heat of battle!

Is there a guide how to program ATTiny with Arduino?

Arduino ISP tutorial
ATTinyCore

Yeah, definitely. Safety reserves are a must. Just want to have the feature in my new big ship, as I had to swim last weekend to fetch my little test boat from a lake, when its battery failed... 16 degrees water, 100 meters offshore... brr... No fun to get such problems with the bigger and much more expensive boat, it would also be much harder to bring back to shore as a swimmer, and often no tugs at hand.

Just prototyped the thing. It did not work at first, when there was a pulldown resistor. I changed it to the pullup variant as here:

it worked. I tried both PC817 and EL357, they went fine. AFH610 refused to make link.

I set it to 300 baud, hardware serial.

As for the resistor, I had a 100x bag of 1.3k and they worked well for input, and 10k for pullup.

That's interesting, as when the output of the source Arduino is high, the LED of the opto is on, pulling down the input of the destination Arduino. In other words: you're reversing the signal here.

Unless, that is, you have the source wired so the Arduino switches it on when low. That's of course also possible, without the extra transistor, by connecting the opto with resistor between Vcc and the Tx pin.

Yes, I was very surprised to see it work, too. I have opto between GND and OUT (TX), so it is not inverted there.

Even funnier - with pulldown resistor, it worked without a problem when just alternating the D13 once a second. LEDs were sinchronous. But not when doing TX/RX…

With no oscilloscope, I cant investigate closer, but the data are ok…

I assembled the circuit as planned, but it seems the values are wrong.... apparently the inversion is making problems there. I tried to send values as strings for the test, but instead of "11.1" I am receiving values like 6x[-

Would check in the evening, if the too high resistor value affects that. If not, will try to hang the opto in normal off, between pin and +5V then... (by shifting the GND wire to signal, and Signal wire to +5 of arduino)

This would be the simplest non-inverting, active low circuit:
schematic.png
TX high: opto off, output pulled high.
TX low: opto on, output pulled low.

Yeah, exactly like this. Will try it tonight. Opto (I used EL357N SMD) is fast enough, raise/fall times are 3 microseconds, compared to 3.3 millisecond impulse by 300 baud.

Worked fine after doing inversion on entrance, too. Now I have the entire sensor up and running. Tomorrow some new Iso Tape and bigger Shrink Tubing, and here we go, will pack it all into a small plastic box and use as a module. Thanks alot for helping me, wvmarle!

Great, good luck with the event!