sparkfun COM-15102 Скачать руководство пользователя страница 13

        delay(400); 
  } 

The 

get_relays_status

 function is of particular interest. Getting the status of the relays works like an I C buffer.

Depending on the number of bytes requested, you will get the status of that many relays. For example, if you
request the status of relay one and four bytes, then you’ll get the status of relay one plus the other three. If you
request relay one and two bytes, then you’ll get the status of relay one and two. If you request the status of relay
three and three bytes, then you’ll get the status of relay three, relay four, and relay one.

void get_relays_status(){ 
  int i = 1;  
  Wire.beginTransmission(RELAY_ADDR); 

  // Change the Wire.write statment below to the desired relay you want to check on. 
  Wire.write(RELAY_ONE_STATUS);  
  Wire.endTransmission(); 
  //  We want the states of all the relays so we're requesting four bytes, i.e. 
  //  four relays. If you request 2 bytes, it will give you the state of two relays!  
  Wire.requestFrom(RELAY_ADDR, 4);  
 
  // Print it out, 0 == OFF and 15 == ON.   
  while(Wire.available()){ 
    Serial.print("Relay ");  
    Serial.print(i);  
    Serial.print(": ");  
    Serial.println(Wire.read()); 
    i++; 
  } 
 

Now let's upload some code via the Arudino IDE. Before uploading, be sure to remove power to the load when
uploading to safely handle the relay. Then connect the Arduino to your computer to upload. Select the board (in
this case the 

Arduino/Genuino Uno

) and COM port that your Arduino has enumerated to. Click the upload button.

When the code has finished uploading, place the Arduino and relay on a non-conductive surface to test.
Remember to not touch the relay’s contacts when the system is powered.

Let There Be Light!

After we load up the code, and press the button we should see the relay one LED light up.

2

Содержание COM-15102

Страница 1: ...ed by an ATtiny84A Each channel has its own blue stat LED silk for easy identification and screw terminals for easy connection The product is Qwiic enabled allowing you to easily integrate the Quad Re...

Страница 2: ...at our IoT Power Relay It s not I C but the IoT Power Relay contains shielding to prevent accidental shock Required Materials For the example under Hardware Assembly I used the following materials to...

Страница 3: ...er if that suits your fancy and we have a number of Qwiic cable sizes to fit your needs SparkFun BlackBoard SPX 14669 Qwiic Cable 100mm PRT 14427 Breadboard Mini Modular Red PRT 12044 Wall Adapter Pow...

Страница 4: ...h and insulation from a cable A Phillips head screwdriver will be required to connect the load s to a screw terminal Qwiic Cable 500mm PRT 14429 Qwiic Cable 200mm PRT 14428 Qwiic Cable 50mm PRT 14426...

Страница 5: ...ll adapter then you can close the jumper on the underside of the product labeled 5V Wall Adapter see Jumpers section below and this will allow you to sidestep the on board regulator to power the 5V sy...

Страница 6: ...relays on the Qwiic Quad Relay Each relay is capable of 5 Amps at 250VAC or 30VDC These relays have an associated blue screw pin terminals that are aligned in order from left to right LEDs There is a...

Страница 7: ...ll power the on board ATtiny84A If you do not power the 3 3V power system this way you can still provide power through the four pin header Safety Considerations This product is designed to switch high...

Страница 8: ...he next channel is common or COM and the final is normally closed or NC The names explain the state of the channel with relation to the switch at rest The normally closed channel is where the switch s...

Страница 9: ...project we want our switch to act intuitively when you activate the switching mechanism the light switches on There could be a case where you want the switching mechanism activated as its rest state...

Страница 10: ...e Arduino IDE Let s take a look at some example code fort the Qwiic Quad Relay You can download all example codes from the GitHub repo by clicking the link below QWIIC QUAD RELAY EXAMPLE CODE ZIP Exam...

Страница 11: ...s the command to toggle every relay define TOGGLE_ALL 0xC Here are the commands to check on the status of the relay i e whether the relay is on or off define RELAY_ONE_STATUS 0x05 define RELAY_TWO_STA...

Страница 12: ...OW Serial println Yellow Button Wire beginTransmission RELAY_ADDR Wire write TOGGLE_RELAY_ONE Wire endTransmission delay 400 button two relay two if digitalRead blue_btn LOW Serial println Blue Button...

Страница 13: ...ire endTransmission We want the states of all the relays so we re requesting four bytes i e four relays If you request 2 bytes it will give you the state of two relays Wire requestFrom RELAY_ADDR 4 Pr...

Страница 14: ...ress Heads up The circuit used in this tutorial is a temporary connection so you will need to secure the circuit and place the relay in an enclosure For more ideas check out some of the projects in re...

Страница 15: ...how Nick Poole built a WiFi controlled fire cannon using the ESP8266 Thing Dev Board Blynk Board Bridge Widget Demo A Blynk project that demonstrates how to use the Bridge widget to get two or more B...

Страница 16: ...Using the ESP32 to make a web configured timed relay Get started switching those higher power loads around with the Qwiic Single Relay...

Отзывы: