Mehcanical relay controlled with Attiny85 and NRF24

I am working in the circuit shown in the picture, where I have the 3 pin solution for the Attiny85+NRF24 receiving a radio signal, and activating/deactivating the coil of a 3V mechanical relay. As shown in the picture.

I have another transmitter NRF24 sending either a 0 or a 1 by pushing a button. If the Attiny85+NRF24 receives a 1, it turns the ATtiny85’s digital pins HIGH on the octocoupler, and allows current to flow through the galvanically isolated relay circuit.

After much trying with the radio signals, I came to the empirical evidence that the Attiny85+NRF24 only were able to receive a radio signal in the voltage range of around 2.75-2.95V between the + and the - (wrongly depicted as “a” in the drawing) of the Attiny85+NRF24 compound . That made me play around with the two resistances depicted in the circuit.

And it works fine! the voltage between the + and - of the Attiny85+NRF24 is of 2.91 when the PB2 or PB1 are LOW, and of 2.81 when HIGH, and the relay coil is on. This makes it possible to receive the radio signal flawlessly.

But then I plug the relay to the mains and use it to turn, e.g., and iPhone charger ON and OFF through the radio signal, it works fine for many cycles of pushing the button on the transmitter …

UNTIL suddenly the 2.81-2.91 voltage raises to 3.15!!, stopping the Attiny85+NRF24 from receiving more bytes. I don’t really know how that is happening? Therefore I start by asking help with this simplified drawing, before going into details.

Anyone has any idea of what could be going wrong?

ivino:
...and allows current to flow through the galvanically isolated relay circuit.

The ATtiny circuit is directly connected to the relay circuit through the power supply, so no galvanic isolation there.

You probably need some decoupling on the ATtiny power supply pins to stop this weirdness.
Try 100uF+100n ceramic, close to the NRF/ATtiny pins.
Leo..

The kickback diode across the relay coil is drawn backwards, is it connected that way?
BTW: Why the resistor on tiny85 Vcc? That will cause voltage fluctuation with load (opto LED).
Why NO base resistor on NPN? That will really cause a load.

Better remove that useless opto, and replace it with a (270ohm) base current limiting resistor (pin to base).
The diode is indeed drawn backwards.
Leo..

You CANNOT use resistor for regulating voltage of a digital circuit. If I understand it correctly you are trying to do so.

I've done numerous projects with nRF24L01s powered with the 3.3V pin on a Nano or UNO as well as external 3.3V power and never had the problem you describe. What distance is between the radios and do you have the power level set to MAX while working on your project?

Wawa:
The ATtiny circuit is directly connected to the relay circuit through the power supply, so no galvanic isolation there.

You probably need some decoupling on the ATtiny power supply pins to stop this weirdness.
Try 100uF+100n ceramic, close to the NRF/ATtiny pins.
Leo…

Also, I removed the octocoupler and only used the base resistance of the NPN. I got the illusion of galvanic isolation from a relay video from Great Scott on Youtube…

Wawa:
Better remove that useless opto, and replace it with a (270ohm) base current limiting resistor (pin to base).
The diode is indeed drawn backwards.
Leo…

Yes the diode was drawn backwards. My circuit now looks like:

In relation to:

Smajdalf:
You CANNOT use resistor for regulating voltage of a digital circuit. If I understand it correctly you are trying to do so.

I am SO MUCH open to suggestions!

Regarding the narrow voltage range my radio is working on:

outsider:
I’ve done numerous projects with nRF24L01s powered with the 3.3V pin on a Nano or UNO as well as external 3.3V power and never had the problem you describe. What distance is between the radios and do you have the power level set to MAX while working on your project?

Yes my radio power is set to MAX in both transmitter and receiver, and the distance is really small between, though they offer a good range now. It might be something to do with the 3pin solution. I do not know if you have also worked with Attiny85 plus radio for digital control?

Cheers and thanks again,

/Ivan

Do I see 5.17k as base resistor? I said 270ohm (for a good reason).
When a transistor is used as a switch, base current needs to be 5-10% of the collector current for full saturation.
A 3volt sugarcube relay draws 100-120mA. So ~10mA base current is needed (Hfe does not apply for saturation).
~3.3volt(suply) - 0.7volt(BE junction) = 2.6volt across the resistor, so 270ohm is close enough for 10mA.

Remove R1, and also add some ceramic capacitance across the supply of the NRF (I said 100uF+100n).
Leo..

Your circuit should work well from 3V3. Some PS supply higher voltage than rated when load is too light. But I don't think this explains your problem. If you need to reduce the voltage you should use a LDO. Or at least resistor + Zener diode. But resistor alone is not able to provide voltage regulation for digital circuits and only the fact you do not need voltage regulation saved your circuit from damage.

Wawa:
Do I see 5.17k as base resistor? I said 270ohm (for a good reason).
When a transistor is used as a switch, base current needs to be 5-10% of the collector current for full saturation.
A 3volt sugarcube relay draws 100-120mA. So ~10mA base current is needed (Hfe does not apply for saturation).
~3.3volt(suply) - 0.7volt(BE junction) = 2.6volt across the resistor, so 270ohm is close enough for 10mA.

Remove R1, and also add some ceramic capacitance across the supply of the NRF (I said 100uF+100n).
Leo…

Thanks for your patience Leo! Everything seems to be up and running now

Smajdalf:
Your circuit should work well from 3V3. Some PS supply higher voltage than rated when load is too light. But I don’t think this explains your problem. If you need to reduce the voltage you should use a LDO. Or at least resistor + Zener diode. But resistor alone is not able to provide voltage regulation for digital circuits and only the fact you do not need voltage regulation saved your circuit from damage.

Well I was lucky my ciruit did not need it. I got the idea from people using an LED for getting 3.3V from the 5V Arduino power supply pin.

/Ivan