Skip to content

6. Extra Libraries

Ioannis Charalampidis edited this page Jan 16, 2019 · 3 revisions

6.1. Software I²C on GPIO Expansion

Since the native I²C pins on the ESP8266 module is use for other purposes, the only way you could use an I²C peripheral is to use Soft-I²C over the GPIO expansion chip.

To mitigate this issue, the uNode library comes with a built-in override to the Wire.h header, that uses the software implementation capable to operate both on native and extended pins.

Usage

To use the custom Wire.h library you should include it before including other libraries that depend on it. For example:

#include <uNode.hpp>
#include <Wire.h> // This will be sourced from the uNode library

void setup() {
   uNode.setup();
   Wire.begin(
     D2, // SDA Pin
     D3  // SCL pin
   );
   ...
}

6.2. DHT on GPIO expansion

If are using a DHT sensor in your project, you can use the built-in DHT library that can be used seamlessly either for built-in pins (D0, D1), or over GPIO (D2 to D9).

Usage

To use the DHT library use the uNode/libraries/DHT.hpp header right after sourcing the uNode.hpp header:

#include <uNode.hpp>
#include <uNode/libraries/DHT.hpp>

// You can use either a built-in pin or an extended GPIO pin as
// the sensor pin
DHT dht(D2, DHT22);

void setup() {
   uNode.setup();
   dht.begin():
   ...
}

This is a customised clone of the upstream Adafruit DHT Library. Refer to it for the API reference.

Clone this wiki locally