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

Hi coockoos,

use google translate to translate this text

translate.google.de/?hl&ie=UTF-8&sl=de&tl=en

choose as target-language YOUR NATIVE LANGUAGE.

The following text is written in german to force you to use google-translate.

Dieser Text ist auf deutsch geschrieben um dich zu zwingen google-translate zu benutzen.
Ich verstehe dein posting nicht weil du zu wenig englisch kannst.
Es ist ehrenwert eine Fremdsprache mit seinem Hobby zu trainieren. Aber wenn man das geschriebene nicht versteht dann ist der falsche Platz um englisch zu üben.

Deshalb bitte ich dich deine Fragen in deiner Muttersprache zu schreiben und dann von google-translate übersetzen zu lassen. DIe Grammatik wird nicht brillant sein aber man wird es GUT verstehen können.

Ich schreibe jetzt in sehr klarer und deutlicher Sprache. Das ist nicht als schimpfen gemeint, sondern es ist gemeint als die Wahrheit sagen. Und dann Schlussfolgerungen für einen GUTEN Lernprozess daraus zu ziehen.

Du scheinst nur sehr wenig über Elektrotechnik und Elektronik zu wissen. Du scheinst noch nicht einmal die prinzipielle Funktion eines Relais zu kennen. Du wirst dein Projekt insgesamt schneller fertig stellen wenn du dir Zeit nimmst die Grundlagen zu lernen.

Auch wenn du ganz einfache Fragen über Elektrotechnik und Elektronik stellst werden diese Fragen freundlich beantwortet werden. Die beste Methode dazu ist zuerst SELBST mit google zu suchen und vielleicht einen Link den du mit google gefunden hast in das posting zu schreiben und dann eine möglichst konkrete Frage zu stellen.

Durch das zuerst SELBST Suchen kann man erkennen, das du EIGENE Mühe aufgewendet hast um zu lernen aber jetzt eine Frage aufgetaucht ist. Das LIEBEN die User in diesem Forum.

Fragen speziell zu Elektrotechnik und Elektronik postet man im passenden Forum "Allgemeine Elektronik
https://forum.arduino.cc/index.php?board=5.0

Hier ist ein Link zu einem Wikipedia-Video dass die prinzipielle Funktion eines Relais zeigt.
Ein Relais hat MECHANISCHE Kontakte. Kontakt geöffnet oder Kontakt geschlossen. An diese mechanischen Kontakte funktionieren auch mit ganz kleinen Spannungen. Es gibt EINEN Eingang und ZWEI Ausgänge.

Ohne Strom auf der Spule ist der Eingang mit einem Ausgang verbunden mit Strom auf der Spule mit dem anderen Kontakt. Welcher Anschlussstift der Eingang und welche Anschlusstifte die Ausgänge sind ist bei jedem Relais anders.

Du musst das durch Messen mit dem Multimeter herausfinden welcher Kontakt ist der EIngang und welche Kontakte sind der Ausgänge. Für den Arduino werden die Kontakte dann so benutzt wie ein Schalter.

Wenn du dir da unsicher bist, dann stelle dazu im Forum ALLGEMEINE ELEKTRONIK eine Frage.
Poste einen Link zum Datenblatt und poste ein Foto von der Unterseite des Relais bei dem jeder Kontakt mit einer
Nummer versehen ist. Dann wird es leicht zu erklären welcher Anschlusstsift wie angeschlossen werden muss.

Hier ist das Video das die prinzipielle Funktion des Relais zeigt

viele Grüße Stefan

Thank you. Your intelligence makes me feel completely naked. I am sorry for the hasty attempts to communicate despite my lack of English proficiency. I will definitely use a translator. From now on. From the link above I was very intuitive to see how this kind of relay works. -I haven't seen how it actually works-but I've been working for about 5 years in the electrical construction world in my country. But I don't think I learned much from there. Admit it. Nevertheless, it would be nice if there was anything to learn in terms of interaction with Arduino from the schematic I attached below. The relay I have, RT424524, is an AC relay. Arduino's digital input system is direct current. Are you saying that you can simply integrate these? So, is it simple even for beginners? I think AC 24v should be supplied through the coil of this relay. And, next, I believe that the second power should be supplied to the relay contact through vcc. -According to the schematic I posted-at least it makes me believe it is. So, does the power supply need to be supplied with 5 volts of DC in order for the Arduino to read the signal from this relay? It would be nice if I could understand a little simpler in this part. Thanks for the answers so far. I hope the translation works well.

(Below use another translator)

Thank you. Due to your point I feel completely be laid bare. Despite his lack of English communication attempted to jump about I'm sorry. I would use the translation must be. From now on, I was on the link from this kind of relay is how it works can be very intuitive. - That's actually - I haven't seen is how it works but its World at electrical work I had worked for about five years. But haven't learned very much there. admit it. Nevertheless, the Arduino from a schematic that I attach the interaction on the side would be great if there are lessons to learn. I have relays, or rt 424524 was alternating current relay. Arduino of digital typography is DC. May be simply integrating these things? So is it too simple? I got this exchange through the coils, 24 of the relay v is think it would have to be supplied. And, of the relay through the next time, vcc jeopjjeombu believe will have to be powered the second time. According to the scheme that has been posted - at least - I will believe that so. So, Arduino is this relay signals from the Ministry of the power to DC in the 5 volt supply? Any simple in this area would be great if you can understand. Thank you for your answer to now. translation is I wish well.

BC996B8A-424D-4589-AA6D-1EDCB25B17B9.png

BC996B8A-424D-4589-AA6D-1EDCB25B17B9.png

optoisolator! how can i genarate 5vdc for digitalread?

Look into INPUT_PULLUP, on the input pin.

To drive the opto input from 24V, use a voltage divider. 5:1 will give approx 4.8V when 24V is present.

Remember the current limit resistor for ANY LEDs including the opto.

Hi coockoos,

congratulations!
yes the translation worked very well. I did not even recognize that it is a machine-translation for most of the sentences.

If I remember right there is a 24V AC-voltage switched ON or switched OFF and this beeing

"24V AC switched ON" or "24V AC switched OFF" should be recognized by the Arduino:

So I attach a picture how it can be connected to the Arduino-IO-pin.
I added a current-limiting-resistor for protection-reasons. Such current-limiting resistors are rarely seen in any schematics but very useful. The functionality stays the same as long as you don't need really highspeed-signals with more than 100 kHz frequency.

The Arduino-IO-Pin will be fonfigured as INPUT_PULLUP.
This means the IO-pin itself does "applicate" 5V to the relais-contact.
With contact opened the IO-pin reports "HIGH" with contact closed the IO-PIN reports LOW.

The current-limiting resistor does what its name says. In case the IO-pin is configured accidently as an OUTput and switched HIGH and then the relay-conact gets closed a too high current would flow from IO-in to ground destroing minimum this IO-pin most likely to whole chip. ANd the current-limiting resistor prevents from that.
The current will be limited to 5V / 250 Ohm = 20 mA. Which an ArduinoIO-pin can stand.

best regards Stefan

24V_AC-Relay-to-Arduino-IO-Pin.jpg

24V_AC-Relay-to-Arduino-IO-Pin.jpg

I did a google-search for the datasheet of your relay

www.google.de/search?lr=&newwindow=1&as_qdr=all&ei=wuACYKT0LsL7kwWBl5uADg&q=Schrack+RT424524+datsheet&oq=Schrack+RT424524+datsheet&

and found this

inside such datasheets you can find a pin-out and often an example-schematics

So here is a picture how the inner circuitry looks like.
It is a relay with a changing-switch two contacts normally closed (with coil unpowered)
two contacts normally opened (with coil unpowered)
The same principle as shown in the wikipedia-video

best regards Stefan

Once successful, the coil is significantly slower to attach. And in the second and third attempts, they didn't even succeed. The relay measurement voltage is approximately 26v. Is the supply current too low?

Do you have a digital multimeter?

yes i have. but DC, AC voltage, ohm measuring only.

What is the Hioki model number?

3244- 60 CARD Hitester

** **HIOKI 2020** **

"200801919"

made in japan

I improved the insulation and tested again and it works fine. However, the value read from the logic analyzer is always HIGH. So I was confused.

int E0 = 3;
const int E1 = 6;

int switchOneState = 0;         // current state of the switch
int lastSwitchOneState = 0;     // previous state of the switch

void setup()
{
  pinMode(E0, INPUT_PULLUP);
  pinMode(E1, INPUT_PULLUP);

  int switchOneState = 0;         // current state of the switch
  int lastSwitchOneState = 0;     // previous state of the switch

  //we need to specify 2x the desired baud rate
  //as the Arduino lib assumes 16MHz
  //so for 150bps spec 300
  Serial.begin(300);     //we need to spec 2x the desired freq

  noInterrupts();
  CLKPR = (1 << CLKPCE);  //enable prescaler write
  CLKPR = (1 << CLKPS0);  //write CLKPS0 to give 0001 or /2
  interrupts();

}//setup

void loop()
{
  switchOneState   = digitalRead(E1);
  if (switchOneState != lastSwitchOneState) {
    if (digitalRead(E0) == HIGH) // && digitalRead(11)==HIGH)// wait for android send data to serial, and give HIGH status for pin 10
    {

      //write 0x55 and check w/scope
      Serial.write( 0x55 );
    }
    else {
      Serial.write( 0x88 );




    }
    if (digitalRead(E1) == HIGH) // && digitalRead(11)==HIGH)// wait for android send data to serial, and give HIGH status for pin 10
    {
      Serial.write( 0x01 );
    }
    else {
      Serial.write( 0x02 );
    }

    //500mS delay between chars (delay works at half-speed now...)

    delay(1500);


  }
}//loop


The picture above is what I coded. 0x01, 0x 55 are output when this board is high. And in practice these still only give out the same value, whether the relay just worked or not.

You could get yourself a current shunt and measure current that way. But it might cost you more than a new DMM.

thanks to your advice.

[color=#202124]Nevertheless, now the relay starts working fine again.

The problem is that the digitalread value is not read correctly again. Attach the current connection status.[/color]
[color=#202124]One more problem: even if I unplug the 24VAC power source, the relay shows 5VDC status for a few minutes.
When I removed the digital pin and GND pin from the Arduino, the voltage was completely gone.
Again, it is correct that the voltage is not measured on the relay side.

More: The coil seems to be working. When 24 VAC is applied, 
it can be seen that the white line connected to the coil side of the relay is fluttering. 
It is repeated every time you turn on the power.
[/color]

Hi coockoos,

very good that you already provided a picture of your wiring.
You connected one wire on the left side. The other wire on the right side.
But there is never contact between left and right.

If the datasheet is correct there is contact from left-middle (21) to left inner pin (22) and if coil is powered the there is contact from left middle (21) to left-outer-contact (24)

or alternatively there is contact from right-middle (11) to inner-right (12) with coil unpowered
and with coil powered there is contact from right-middle pin (11) to right-outer pin (14)

Take a close look at the white schematic.

You did a quick wiring and loaded a program into your arduino.
And it did not work. You should do always basic and simple pre-tests
In this case this means:

first check:
only connect the 24AC to the coil
connect / disconnect the 230V / to 24V transformer checking can you hear the relais click ?

second check
if you connect your digital multimeter measuring resistance or better the "beeping-mode" for good conductance
connect / disconnect the 230V / to 24V transformer checking does the resistance change between infinity and 0,x Ohm
or in beeping-mode does it beep / not beep?

With this basic checking you know 230/24V AC-transformer and the relay work

next pre-test:
connect a jumper-wire (WHITE) from your arduino-input-pin to the 250 Ohm resistor and connect a second jumper-wire
(BLACKor BLUE) from resistor to ground

change the if-conditions in your program to print out text instead of just one byte-number

    if (digitalRead(E0) == HIGH) // && digitalRead(11)==HIGH)// wait for android send data to serial, and give HIGH status for pin 10
    {
      //write 0x55 and check w/scope
      Serial.println(" digitalRead(E0) is HIGH" );
    }
    else {
      Serial.println(" digitalRead(E0) is LOW" );
    }

the test tells it directly what is.

run the program and connect / disconnect the BACL/BLUE jumper-wire towards ground
then your program should report self-explaining text

Al these pre-tests reduce the number of possible bug-sources to a minimum and you will find the error quicker

Of course as a first test you can put it all together - if everything works well done. If it does not work as expected
change to basic simple pretests

best regards Stefan

thermostat power issue

Ohhhh...Thanks! The relay is now functioning correctly.
This time, let's run through two relays in a row with a thermostat. Refer to the temperature controller runoff diagram that you drew last time. But there's another problem.
When the relay goes from hot to cool, a power-related problem occurs, and the thermostat turns off and an error occurs. The error contents are the link above.

Power related error. Perhaps it's because they put GND in one place...??

(But Thermostat wire voltage is good)

ooops !!! The wires connected to the 24V AC must be completely isolated from the Arduino ground.
If I remember right you have one 230V/24V AC-converter for heating and a second 230V/24V AC-converter for cooling.

You should connect separated wires from each

converter "Heating"----->----------- Relay-coil 1
converter "Heating"----->----------- Relay-coil 1

two different wires with no other connection

converter "Cooling"----->----------- Relay-coil 2
converter "Cooling"----->----------- Relay-coil 2

and no connection to the arduino.
The "connection" happens through the elektro-magnet that pulls the inner switch of the relay

If you connect the AC-wires to ground this can cause EMV or even damaging.
In my pictures there is no connection between AC and the arduino

If you connect the two AC-wires the wrong way together it is possible that one transformator is plus and the other minus
AC means alternating current. The current is alternating but to any moment there is on one end plus and the other end is minus and after 1/50 second it is vice versa minus/plus always alternating.

So keep the wires appart as shown above.

you are a lucky guy if nothing is damaged yet!

best regards Stefan

The nest is safe! I finally found a problem, and I expect it to be a voltage problem.
GND; although they are united, alternating current and direct current are safely separated each other.

In the picture below, the nest showed the input voltage in real time.
I wonder how 35 VACs can be created in a 24 VAC converter.
So I cut the voltage of the transducer down one notch and as a result, the nest is no longer a problem. However, as expected, the relay is chatted. It's also very noisy. Everything worked well except that.

anyway, This definitely didn't happen until then. Why?

add: seperate GND line from breadboard, or seperate cooling wire, heat wire from thermostat, even restart, Not getting better.

Despite the fact it ‘all works’, please get someone that understands what’s being done to check your wiring.
Even low voltage AC or DC can make sparks & fire.

Your homeowner’s insurance is likely to decline your cover if it finds this contraption in the rubble.

Before the house burns, this chattering relay will be an alarm.

Hmm But if you remove all the joints, the symptoms won't go away.

Tomorrow, I have to investigate everything. This includes replacing relays with lower voltages.