all of digitalread always high when it double ' if ' statement

coockoos:


I will change the relay. There seems to be hope. and can you explain 24v relay wiring for me ?

Do you see the relay labeled "Required Relay" in your diagram? Do it like that. One end of each relay coil goes to C (Common or Ground). The other end of each relay coil goes to a thermostat output: W (Heating) or Y (Cooling). The contacts of the relay, instead of going to HUM1 and HUM2, go to Ground and an INPUT_PULLUP pin of the Arduino. When the contacts are open, the INPUT_PULLUP pin reads HIGH because of the pull-up. When the contacts are closed, the INPUT_PULLUP pin reads LOW because it is connected to Ground.

The parts will arrive the day after tomorrow. It can be controlled by the this Ac relay, right?

Thanks.

if you mean the 24V AC smart-relay. It is probably not well suited.

your smart-relay switches on/off 24V AC.

A relay has a coil and one or multiple switching contacts.
The coil can be seen as the input-side. The contacts can be seen as the output-side.

If the coil is connected to a "power-supply" with an apropriate voltage the coil creates a magnetfield which makes the contact switch from switched off = no power into coil
to
switched ON = power into the coil

In most cases you want to use the 5V of an IO-pin to switch a higher load. This means the IO-pin is connected to the inputside. This means The inputside has to react on 5V DC And the Outputside (the contact is connected to a higher voltage.

In your case it is the opposite. Your smart-realy "delivers 24V AC and the Smart-relay 24V must be connected to the inputside of the relay. So the inputside must be suited for 24 AC.

The link you have posted show a relay module with 5V DC-input which has an additional transistor on the inputside because the current of the relay is too big to drive the relay diectly.

So connecting 24V AC to the inputside of the linked relay-modul just creates the "magic" smoke and the modul will be destroid.

As you can see from this explanation: trying to do things real quick turn out to slow down things a lot.
The microcontroller-wolrd is NOT superstandardized like USB-devices. You have to take care of a lot more things than just does the plug fit into the socket?

the additional things are:

  • do both sides have the same voltage type AC or DC?
  • do both sides that shall be connected have the same voltage-range?
    -can the outputside deal with the amperage of the inputside?
  • in case of inductive loads do I need to add antiparallel diodes to supress voltage-spikes?
  • in case of data-communication do both sides have the same kind of bus? (I2C, SPI or serial)

So to use the linked relay-module with 24V AV you additionaly need some parts to make it work:

a bridge-rectifier to convert the 24V AC to 24*1,41 = 34V DC
an additional resistor. The value of this resistor depends on the current measured at "normal" supplying the input with 5V and must be measured before the value of the additional resistor can be calculated.
So pretty much things to to.

So it might be much easier to just use a relay where the coilside is specified for driving the coil with 24V AC
This is one example from a german electronic-parts-shop.

look at the specs: coil 24V AC

best regards Stefan

An optoisolator is another good way to sense the 24VAC.

An optoisolator is another good way to sense the 24VAC.

optoisolator! how can i genarate 5vdc for digitalread?

So it might be much easier to just use a relay where the coilside is specified for driving the coil with 24V AC

RT424524 - Schrack - Te Connectivity - Power Relay, DPDT, 24 VAC | element14 Korea

is this enough?

coockoos:
optoisolator! how can i genarate 5vdc for digitalread?

If you connect the opto output to a digital input and use INPUT_PULLUP, the 5V will automatically be supplied to the Arduino pin through an internal resistor.

The relay you linked to should also work.

Thank you!

And

May I refer to this case?
Will Pc817 is fitting?

coockoos:
May I refer to this case?
Will Pc817 is fitting?

Can you see the difference in the schematic

what is your guessing? Does the PC817 fit?

If you don't know it is really about time to learn the basics of electronics or to ask about **any **detail and for **any **component with describing any detail of your project.

best regards Stefa

I think what @StefanL38 is trying to communicate, is that the question you have asked, is possible to answer by doing a bit of internet research. But the key is to know where to look. Forums are full of people with opinions. It is often just as easy, and more informative and reliable, to pursue source documentation and application notes from genuine engineering sources.

If I needed the answer to this question, I would first google, "H11AA1" because that is obviously the "heart" of the circuit. Knowing what it is exactly, I can compare the specifications with others that I can find, once I know what it is, an optocoupler. I could then compare specifications one-to-one with any other opto, such as your "PC817".

If had doubts about any part of the spec, or wanted to know which specifications are most important for my application, I could find out with a bit more internet research.

After doing all that, if I still didn't know, I would at least have a specific, detailed "case" to accompany a forum question. This has advantages:

  • it shows that you care enough to do some work
  • it provides helpers with much needed background information
  • with this information in hand, it will be much easier to understand and utilize the replies

guys, thank you very much. It was an good advice. I will do everything I can.

sorry guys, it's didn't work.
optocoupler H11AA1, stuck with below (picture2) hex number that mean wrong value digital read and i can find very few voltage at output endpoint of H11AA1.

coockoos,

how many attempts of quick guessings mounting things quickly together doing a quick test with your complete code and then posting a quick & dirty picture of a only half connected wiring you need to understand:

That investing time into basic testings will save time

  • That taking time to make reliable connections which means soldering wires to the condensator

  • Which means inserting a digital multimeter into the AC-24V side to measure the current flowing through the internal LED of the optocoupler

if this works

connect the condensator to a 20K-resistor (simulating the internal pullup-resistor) then to +5V and ground and then to use a digital multimeter for measuring the voltage in case 24AC is on is off?

collector of optocoupler-transistor-------20K-Resistor-------- +5V

emitter of optocoupler-transistor-------GND

removing the 20k-resistor insering a 1k-resistor for current-limiting purposes connect this to the Arduino-IO-pin.

collector of optocoupler-transistor-------1K-Resistor-------- Arduino-IO-pin

Then do a small testprogram that does nothing more than reading and printout the status of the IO-pin
When you switch on/off your AC24V

etc.
For future pictures take the pictures from vertically above with everything wired close to the hardware so that it is easy to see where is it connected to.

best regards Stefan

thanks.

Start at 26vac before passing the resistor element. After passing the resistor, the input voltage is 0.06 mv. The output voltage(DC) is rarely found when measuring and removing the condenser.

i have two of test set

measuring voltage is completely different to measuring current.

As a general question how m uch do you know about electricity / electronics?
I was assuming you know how to measure current and voltage.
Now I'm not sure.

best regards Stefan

it doesn't seem like I can handle it at my level right now. plus, My multimeter has no current measurement function. Just a simple card tester. We're going to re-test with the second alternative, the RT424524 AC relay.
If this method fails, I will go back to square one and review it one by one. thanks and sorry.

For tinkering with microcontrollers a digital multimeter is very helpful.

I recomend this one

very good price/perfomance ratio. Can measure capacity, temperature, duty-cycle, frequency and has a bluetooth app for slow-speed recording measurings

if you want to stay low-cost with less functions something like that:

Tinkering with microcontrollers and connecting hardware to it cries for a digital multimeter and a 8 channel logic analyser
like this one for just $10

I bought one recently. It works with the opensource-software pulseview which can be downloaded here
https://sigrok.org/wiki/Windows

pulseView can even analyse the bitbanging of Serial I2C. SPI amd CAN-Bus to show you the bytevalues that have been transmitted

best regards Stefan

Thank you for your kindness. stefan,
Now I'm Pull it out the second card, this DPDT relay : RT424524
for digitalread 24vac to. i firstly, wiring below. but there is no voltage.( pink & gray to arduino line )
but it seemed.. i was wrong. right? what should i do? thanks always.

The drawing does not show how the inner contacts of the relay are wired.

Please post a high resolution picture of the relay TOP-view and bottom-view

You have to analyse which contacts are open and which contacts are closed
with coil unpowered / coil powered

best regards Stefan

https://forum.arduino.cc/index.php?topic=20102.0

this forum similar with my topic. i learned about a pin of DPDT. but now, firstly i don't understand how it possible 24vac generate signal for arduino digitalread at the end. The coil will be connected to 24vac. Then what about COM and the contact? Isn't it connected to 250v? How to make up digital read signal? thanks for help.

((below, my 24vac tranceformer and DPDT (coil:24vac | 250v ). ))