This basic example teaches you how to create a circuit that uses two Grove modules and requires no soldering. The MKR board you choose may be anyone of the MKR family because the connection is managed through the MKR Connector Carrier.
The connection to the Carrier board requires two standard Grove cables. The DHT humidity and temperature sensor goes to the D0 connector. The OLED screen is connected to the TWI connector.
We did not put a MKR board on the Carrier, but it is required to get the circuit to work, as specified in the bill of materials.
The DHT module uses a specific pin to communicate with the MKR board and it is mapped on D0. This happens because the Grove standard for digital connections follows this rule:
Pin | Functrion | Notes |
---|---|---|
pin1 | Dn | Primary digital i/o |
pin2 | Dn+1 | Secondary digital i/o |
pin3 | VCC | Power to module 5V/3.3V |
pin4 | GND | Ground |
and the module sends SIG on pin 1 that is mapped on the primary digital I/O.
In the picture, the OLED module is shown from component side to let you see the Grove connector. It goes into the TWI male on the MKR Connector Carrier that follows this pin mapping:
Pin | Functrion | Notes |
---|---|---|
pin1 | SCL | I2C Clock |
pin2 | SDA | I2C Data |
pin3 | VCC | Power to module 5V/3.3V |
pin4 | GND | Ground |
To drive the modules you need to load four separate libraries:
#include <DHT.h>
#include <DHT_U.h>
#include <Wire.h>
#include <SeeedOLED.h>
The DHT module is mapped on D0 when the object dht is instantiated:
DHT dht(0, DHT22);
The rest of the code is straightforward and keeps reading the hum
and temp
values to be printed on the OLED screen.
Here is the complete sketch
Getting started with MKR Connector Carrier
Last revision 2018/08/08 by SM