Go Down

Topic: Wemos D1 R2 UPS fault indicator (Read 1 time) previous topic - next topic

petfy

I have an UPS for a land line phone, required for possible medical emergencies. It can communicate its status via several of its pins.
Pin 3 alarm signal return
Pin 4 on battery
Pin 5 replace battery
Pin 6 battery missing
Pin 7 low battery

I would like to monitor these pins by a Wemos D1 R2 and wifi the current status to an (onboard) web browser on the home network and eventually accessed remotely via the internet.

The pin high is probably 12v DC so I know I will have to buck convert them to 3.3v. What pins are available on the Wemos D1 R2 to connect the UPS alarm pins to? And do I only have to test if these pins go high?

PieterP

#1
Dec 29, 2017, 02:13 pm Last Edit: Dec 29, 2017, 02:14 pm by PieterP
The pin high is probably 12v DC
I doubt that. Measure it to be sure, and post the UPS datasheet.
so I know I will have to buck convert them to 3.3v.
Of course not. Buck converters convert power supply voltages, not signal voltages. You just need a voltage divider, or maybe an opto-isolator if you want to be really safe.
What pins are available on the Wemos D1 R2 to connect the UPS alarm pins to? And do I only have to test if these pins go high?
You can use any digital pin.

petfy

"You can use any digital pin" is not very useful to a beginner. The UPS data sheet is not specific on what a high digital signal is (in volts). Opto-isolators only seem to be used for noisy signals.

As far as I can research some, if not, most of the digital pins have an intrinsic function attached to them.


D2 and D1 are the SDA (serial data) and SLC (serial clock) of the I2C bus.
D5 to D8 are SPI bus, MISO (Master In Slave Out), MOSI (Master Out Slave In),
                                SCK (Serial Clock), and SS (Slave Select).
D7 to D5 appear to be duplicate pins of the SPI bus.
D4 is the LED which I wish to light when the IoT has power.

This appears to leave only D0 and D3 as the only clear pins.

So the question remains, what digital pins (or what is the best pins) can I use to monitor the four UPS wires?

Furthermore, I assume I connect alarm signal return to the GND pin?

PS cant get the Wemos forum moderator to answer/approve my registration so I am on this more active forum.

PieterP

#3
Jan 07, 2018, 11:02 am Last Edit: Jan 07, 2018, 11:08 am by PieterP
The UPS data sheet is not specific on what a high digital signal is (in volts).
Then you have to measure it yourself.
Please post a link to the data sheet.
Opto-isolators only seem to be used for noisy signals.
What makes you think that? They are used when galvanic isolation between two devices is required. The UPS and the WeMos can be at different potentials, they can use different signal voltages, and if for some reason the signal voltage of the UPS gets too high, it will blow up the opto-isolator, not the WeMos.

As far as I can research some, if not, most of the digital pins have an intrinsic function attached to them.
That doesn't matter. A digital GPIO pin is just that: a digital GPIO pin. While it is true that you can disconnect some pins from the GPIO registers and connect them to hardware peripherals (SPI, UART, I²S, ...) instead, that doesn't matter if you don't want to use these peripherals.
D2 and D1 are the SDA (serial data) and SLC (serial clock) of the I2C bus.
No, the ESP8266 doesn't have a hardware TWI (a hardware peripheral that's used for I²C), so it is bit-banged in software using normal GPIO pins. You can use I²C on any two pins. (But again, it doesn't matter if you're not going to use I²C.)

If you don't need SPI, don't enable it, and the "SPI" pins will just be normal GPIO pins.

If you're going to use D4 for an LED, select different pins for the signal inputs, obviously.

You have to keep in mind that GPIO0 and GPIO2 should be high at boot time, GPIO15 should be low at boot time. GPIO0 has a pull-up resistor, GPIO15 has a pull-down resistor. GPIO2 has an internal pull-up resistor that's enabled at boot time, but it probably has an LED connected to it.


https://tttapa.github.io/ESP8266/Chap04%20-%20Microcontroller.html

Furthermore, I assume I connect alarm signal return to the GND pin?
Measure the polarity first. Return seems to imply that it sinks current, so that it's indeed ground, but you have to check it.

Pieter

petfy

#4
Jan 08, 2018, 01:22 am Last Edit: Jan 08, 2018, 05:01 am by petfy
Thanks for the pointers.

http://dcpower.eaton.com/Customer-Premises-info.asp
but no alarm line specs
Eaton does not reply to emails (holidays?)

Primary pin selection by me:
Gnd
Gpio12
Gpio13
Gpio14
Gpio04
Comments?

petfy

Researched opto-isolators, but only had real success when searched for opto-couplers.
There are no hi to lo modules available so it looks like I'll have to build my own on a protoshield.

PieterP

http://dcpower.eaton.com/Customer-Premises-info.asp
but no alarm line specs
Eaton does not reply to emails (holidays?)
That's a shame ... Do you have a multimeter to measure it yourself?

Primary pin selection by me:
Gnd
Gpio12
Gpio13
Gpio14
Gpio04
Comments?
Looks good.

Researched opto-isolators, but only had real success when searched for opto-couplers.
They are the same.
There are no hi to lo modules available so it looks like I'll have to build my own on a protoshield.
What's a 'hi to lo module'? What do you mean?

petfy

Wanted a module so I didn't have to create my own circuit board (sort of electronic lego building).

No multimeter. Will have to buy or borrow one.

Most optocouplers (if not all) use an input low voltage to output a high voltage. I want to go the opposite way (12 or 5v to 3.3v).

The previous attached circuit diagram is very important to me as it is the only one the shows 12v to 3.3v (and also the resistor capacities).

Thanks very much for your help. After many revisions, this is what I've come up with as the physical layout of the ProtoShield.

PieterP

Most optocouplers (if not all) use an input low voltage to output a high voltage. I want to go the opposite way (12 or 5v to 3.3v).
That's a misconception. The input side voltage can be anything from around 1.2 V. It's just an infrared LED. Use the forward voltage and operating current from the datasheet of the optocoupler to calculate the input resistance. E.g. if the forward voltage is 1.2V and the current is 10mA, and let's assume the signal voltage is 5V: the voltage across the LED is 1.2V, so the voltage across the resistor is 5V-1.2V = 3.8V. The current through the resistor is the same as the current through the LED = 10mA = 0.01A. Then use Ohm's law to calculate the resistance: R = V/I = 3.8V / 0.01A = 380 ohm < 390 ohm.

The output of the optocoupler is open-collector. It can be any voltage you want, as long as it's lower than the maximum C-E voltage of the optocoupler's output transistor (again, check datasheet). 3.3V is not a problem at all.
Reading open-collector outputs is a very common task for a microcontroller, that's why it has pull-up resistors built-in. This means that you don't have to add them externally, just enable them in software using pinMode(pin, INPUT_PULLUP).

The output will be inverted (i.e. the optocoupler's output will be low when the input is high) but that's not a problem, you can easily invert it in software.

petfy

The project is abandoned.

Managed to get a simple multimeter for free that someone was throwing out. Was tested at the time of the exchange and worked.

Testing on the alarm pins on the UPS, when the UPS was on battery, showed no voltage on any of the pins using the alarm signal return pin as -. Tested again using alarm signal return pin as +. Still nothing. Tested the 12v output of the UPS and the multimeter showed 12v at the correct polarity, which shows that the multimeter was working.

As a side note, as a beginner, if the output signal was found to be reversed I would correct it with hardware (see attached).

Again thanks for your assistance which I found invaluable.

petfy

#10
Jan 09, 2018, 01:38 am Last Edit: Jan 09, 2018, 03:29 am by petfy
Photo that will be emailed to Eaton.

Edit: they are back from holidays.
"The alarm contacts on the Eaton MPS12-30 unit are open collectors with a component such as a transistor or similar as part of the integrated circuit."

So I assume I have to supply volts/current and see which pins flows rather than test for a high state pin (the UPS supplying the volts)?

PieterP

That makes it even easier. Just connect it to ground and an IO pin, and enable the internal pull-up resistor.

petfy

It is advised that the interrogation of the alarm pins be done in 5v DC. So I have to reduce the power supply voltage of 12v DC to 5v, interrogate the UPS, and reduce the resulting voltage to 3.3v for the Wemos.

Since I've been researching optocouplers so much I've decided to reduce the voltage that way.


I need to calculate to input resistor values. The output resistors are just pullup resistors and can be 10kΏ.

Now I have trouble with the input resistors. Vi-Vo/A is the equation. The 4N35 has a forward current of 50ma, but using that value produces nonsense values were as using 0.015 produces what appears to be correct answers. Refer attached circuit diagram.

Thus :
12-5v = 465Ώ
5-3.3v = 115Ώ
are these correct?

Wawa

So I have to reduce the power supply voltage of 12v DC to 5v,

The output resistors are just pullup resistors and can be 10kΏ.

The 4N35 has a forward current of 50ma...
No, you light the LED of the opto with a CURRENT, set by value of the LED's current limiting resistor.
The opto transistor pulls the voltage supplied by the pull up resistor of the pin (3.3volt) to ground.

You don't need pull up resistors if you use the internal ones in the processor (read post#8 again).

That's an absolute max value. You don't want to go anywhere near that.
1-2mA LED current is usually more than enough to pull a pin with weak internal pull up low with the opto transistor.
Leo..

petfy

This project is starting to become very complicated for a beginner.

In the physical layout there is no 5v supply to the board. It is put there may for later suppling something else. The blue blocks are screw type terminals accepting external wires.

If it is not a big ask, could someone check the project so far?

Go Up