how to sense small current on DC line

Irving

Joined Jan 30, 2016
5,146
hello @Irving
sorry was trying to complete another 2 project that i have opened in different threads - almost done and time to that one.

May i ask what exactly are :

Local_out
Remote_out

What battery cell is used ie how many volts/capacity mah?

also what exactly is meant by battery manager? and usb-c?


Other components i am going to order in meanwhile.

Thanks!
The two 'out' signals are feeds to signal loss of power, building (remote) or apartment (local), to whatever MCU you plan to use, could be a simple single chip MCU, ATtiny or a PIC or something bigger such as a Nano or a Seeed. Probably not a Pi or similar as need to keep battery use to a minimum. My preference would be an ATtiny84 single chip MCU or similar, but that assumes you have the necessary programming environment (easy to set up though).

Battery is a single 3.7v LiPo, biggest capacity you can accommodate. Could be a single 18650 cell, say 1800mAh, or a pouch or prismatic cell. Depends how long you want it to hold up during an outage, which will depend to some extent on the MCU you choose and how sophisticated your programming is (ie do you use 'deep sleep' to conserve power or not). The GSM card consumes 10 - 20mA idling and up to 2A during a transmit, though only for a few mS. Again you can put it into a deep sleep mode but that means re-establishing the 'phone connection each time you want to send a message; not a big issue but again more complex programming.

The battery manager is an off the shelf module that controls charging and discharging of the battery. In this environment we're only using the charge control as the point where it cuts off the battery to prevent deep discharge (2.7v or so) is well below when the GSM card will stop working (3.5v), so we'll handle that in software (or not!). It's available on Amazon/Aliexpress typically listed as "USB Type C TP4056 Lithium Battery Charger Module". Some come with a JST connector for the battery too, which makes it even easier to plug and play. Note, the type you want, unless your battery contains overcharge/discharge protection, has three chips on it, like this:

1763387910820.png
Typically cylindrical cells have no protection, whereas pouch batteries usually do have, in which case the one chip chargers are ok (but beware as not always true).

The reference to USB C is just the connector style for the source of power to charge the battery, you can find the same charger modules with microUSB too. You'll need a suitable USB phone charger/wall-wart, doesn't need to be anything sophisticated and could be just an old 1Amp Type A charger as long as it has the right connector for the board connector on the end of the cable.
 

Thread Starter

thor21

Joined Sep 29, 2024
435
hi @Irving
thanks for the details

Remote out -> sends signal when "doorbell dies" (ie no voltage on HZ...)
Local out -> sends signal when USB-C adapter dies ?


The two 'out' signals are feeds to signal loss of power, building (remote) or apartment (local), to whatever MCU you plan to use, could be a simple single chip MCU, ATtiny or a PIC or something bigger such as a Nano or a Seeed.
Just odd question here -> i dont know these modules have to check, hope nothing fancy,
but for a simplicity i cant control some Relay directly from Local/Remote out?
The reason why i am asking is i can power that relay module from my central backup battery and once there is signal, relay can easily talk to my alarm which comes with sim card and contact me immediately (ajax alarm system)


Thanks!
 

Irving

Joined Jan 30, 2016
5,146
hi @Irving
thanks for the details

Remote out -> sends signal when "doorbell dies" (ie no voltage on HZ...)
Local out -> sends signal when USB-C adapter dies ?
Correct. They go low when fault occurs.

Just odd question here -> i dont know these modules have to check, hope nothing fancy,
but for a simplicity i cant control some Relay directly from Local/Remote out?
The reason why i am asking is i can power that relay module from my central backup battery and once there is signal, relay can easily talk to my alarm which comes with sim card and contact me immediately (ajax alarm system)


Thanks!
Not odd at all, in fact a perfectly reasonable one. Yes, you could power a relay module, but not a relay directly. Unless I missed it, you didn't previously mention you already had a comms arrangement in place; that simplifies the whole solution.

The only issue I can see is that the /remote_out will trigger every time the doorbell is pressed. That is the main reason for the added 'intelligence' following; to differentiate between the doorbell being pressed and a power failure, based on the duration of the 'outage' (and also to generate the outbound SMS text). But the timing issue can be resolved another way I think.
 

Thread Starter

thor21

Joined Sep 29, 2024
435
The only issue I can see is that the /remote_out will trigger every time the doorbell is pressed. That is the main reason for the added 'intelligence' following; to differentiate between the doorbell being pressed and a power failure, based on the duration of the 'outage' (and also to generate the outbound SMS text). But the timing issue can be resolved another way I think.
i dont have to power relay, relay is powered by my own ups,
i need to send signal to that relay

well i thought that original design had somehow that intelligence inside, ie ignore short "pressing of the doorbell", maybe i was wrong?

thanks
 

Irving

Joined Jan 30, 2016
5,146
i dont have to power relay, relay is powered by my own ups,
i need to send signal to that relay
What is the signal you require, and over what distance/wiring/etc?

well i thought that original design had somehow that intelligence inside, ie ignore short "pressing of the doorbell", maybe i was wrong?

thanks
Not in the interface, but we can add that in...
 

Thread Starter

thor21

Joined Sep 29, 2024
435
That's what i get from the company producing doorbell, not sure if that helps

The SA and GND outputs are for an auxiliary ringer; when the monitor rings during a call, that output provides 12Vdc.


The BUS terminal is 30Vdc without polarity, the cable can be connected in any position.




Regarding what signal i need, hard to say. I used relay module which has control line hig/low. Will share link to it in couple of hours.

Thx
 

Irving

Joined Jan 30, 2016
5,146
Nearly done, but I do have one concern. Can you measure, both DC and AC, the voltage between each of the HZ connections and the ground of your UPS, if we are to power it from that and not its own battery.
 

Thread Starter

thor21

Joined Sep 29, 2024
435
Nearly done, but I do have one concern. Can you measure, both DC and AC, the voltage between each of the HZ connections and the ground of your UPS, if we are to power it from that and not its own battery.
for a simplicity it can be also own battery

the UPS i have is 230V
 

Thread Starter

thor21

Joined Sep 29, 2024
435
its okay than, in case we can send signal to external relay or just Switch external relay with relay board which u proposed.

thanks!
 

Irving

Joined Jan 30, 2016
5,146
I've built the relay into the interface, so you'll have a set of zero-volt isolated contacts to use, no external devices/modules needed
 

Irving

Joined Jan 30, 2016
5,146
Here you go....

1763660699296.png

How it works:

Diodes D1-D4 ensure whichever way round the unit is connected to the doorbell, it will still sense the correct polarity. Resistors R1 - R3 present a high impedance to the doorbell unit, allowing us to sense the voltage without drawing any significant current and protecting us from any noise spikes; R3 will have a voltage of approx 1v across it when the doorbell unit is idle dropping to 0v when the doorbell is pressed, or when the power goes off. The comparator U1A compares the voltage across R3 with a 0.5v reference provided by R5 & R6 and if the voltage across R3 falls to 0v so does U1A's output. This 'falling edge' is transmitted by C2 to the trigger input of the timer U2A, whose output immediately goes to 5v and stays there till it times out; the time is set by R10, RV1 & C4 between 6 and 30sec approx. When U2A times out the 'falling edge' is transmitted to the trigger input of U2B. If, at that time the doorbell push has been released then the output of U1A will be at 5v again and, through R8 and Q1, U2B's reset input is held at 0v and so the trigger is ignored. If, however, U1A's output is still at 0v, due to a loss of doorbell power then the trigger will set U2B output to 5v and Q2 will turn the relay on. When the doorbell power is restored, U1A's output will again return to 5v, resetting U2B and turning off the relay.

There are 2 possible issues with this design, due to its 'simplistic' nature. The first is of course, being battery powered, when the battery runs out the relay will go off. The circuit takes about 100mA when triggered, 90% of that being the relay coil. Even so, an 1800mAh 3.7v battery boosted to 5v @ 90% efficiency will still last 8 -10 hours. The second issue is that should the doorbell be pressed when U2A times out a false 'power off' will occur, only lasting until the push-button is released. Choosing the timeout therefore is critical; too short and it'll trigger on a repeated push. Of course there is no guarantee that any timeout won't fall foul of a second push.

The solution is to have repeated random timeouts and only signal a power failure after, say 3 or 4 have all returned the same result. But that requires more intelligence... the following is my solution to that, which is to remove all the timing hardware and replace with software using a tiny single chip micro-controller. Not only is it more reliable, but simpler and cheaper as well. Of course an Arduino Nano or other single board microcomputer could be used but at more cost.

1763665113059.png

It just dawned on me that there is a even simpler solution, using the comparator in the ATtiny85! This is about as simple as it gets!

1763666651555.png
 

sghioto

Joined Dec 31, 2017
8,634
Is it possible use some circuit that can send signal to some other circuit with a relay assuming if the doorbell is working there is (30V) the relay is on,
in case there is no electricity the relay gets disconnected.
Does it need to be that complicated?
Getting back to using the module in post #1, would this work?
Requires a 12 volt power source for the module.
In this configuration the relay is activated when the 30VDC is lost or disconnected.
This will save power when the system is functioning normal.
PC814 provides isolation from the 30VDC supply.
1763670595628.png
 
Last edited:

Irving

Joined Jan 30, 2016
5,146
The 30v isn't just a DC supply, it's a signalling system running at several Mbps. Anything that unbalances that or affects the S/N ratio could have serious consequences, and being a distributed bus the impact may not be local.That's why we rejected touching that as we have no way of assessing that impact.
 
Top