La Uno R4, Arduino introduit en standard le connecteur Qwiic. Qwiic vient de SparkFun, un fournisseur de composants et de capteurs bien connus du monde IoT et maker.
Jusqu'alors, pour faciliter la connexion des capteurs, on utilisait plutôt le format Grove, de SeeedStudio.
| Grove | Qwiic | |
| Protocoles | I2C, I/O numérique, UAT | I2C |
| Voltage | 3,3 - 5V | 3,3V |
| Taille du connecteur | 2 mm | 1 mm |
Un des avantages du Qwiic est la compacité du connecteur, permettant de l'inclure dans le hardware sans prendre trop de place. Mais Grove offre un voltage plus large (3,3-5V) et plus de protocoles. Qwiic ne peut pas utiliser des capteurs 5V directement.
Un avantage du Qwiic est sa capacité à chaîner plusieurs capteurs I2C en minimisant les fils. Il existe des hubs pour utiliser des capteurs Qwiic depuis une connectique Grove.
Exemple d'utilisation d'un LED Stick Qwiic :
/*
An I2C based LED Stick
By: Ciara Jekel
SparkFun Electronics
Date: June 11th, 2018
License: This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
Feel like supporting our work? Buy a board from SparkFun!
https://www.sparkfun.com/products/14783
This example blinks the entire LED Stick.
*/
#include <Wire.h>
#include "Qwiic_LED_Stick.h" // Click here to get the library: http://librarymanager/All#SparkFun_Qwiic_LED_Stick
LED LEDStick; //Create an object of the LED class
void setup() {
Wire.begin();
Serial.begin(115200);
//Start up communication with the LED Stick
if (LEDStick.begin() == false){
Serial.println("Qwiic LED Stick failed to begin. Please check wiring and try again!");
while(1);
}
Serial.println("Qwiic LED Stick ready!");
}
void loop() {
//Set all LEDs the same color (white)
LEDStick.setLEDColor(50, 50, 50);
delay(1000);
//Turn off all LEDs
LEDStick.LEDOff();
delay(1000);
}Exemple avec une LED Stick au format Grove :
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
#include "Adafruit_NeoPixel.h"
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 6
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 10
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 500; // delay for half a second
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.setBrightness(255);
pixels.begin(); // This initializes the NeoPixel library.
}
void loop() {
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}On constate par exemple qu'avec Qwiic, il n'est pas utile de faire un #Define Pin car l'interface Qwiic est intégrée par défaut sur la UNO avec wire / wire1. Les capteurs sont identifiés par l'adresse I2C et non par la broche. Dans l'exemple, le code déclare Wire.begin(). En Grove, on indique la broche sur laquelle le capteur est connecté.