- ✓ Understanding which libraries OceanRemote needs
- ✓ Installing the ArduinoJson library (required for all boards)
- ✓ Installing DHT sensor library (for DHT22/DHT11)
- ✓ Installing OneWire and DallasTemperature (for DS18B20)
- ✓ Verifying correct library installation
- ✓ Troubleshooting common library issues
Why Do We Need Libraries?
Libraries are pre-written code that make it easier to work with sensors and components. Instead of writing complex low-level code yourself, you can use libraries that handle the hard work.
OceanRemote firmware uses three main libraries depending on your sensor choice:
- ArduinoJson - Required for ALL boards. Parses the data from OceanRemote servers.
- DHT sensor library - Required if you're using a DHT22 or DHT11 temperature/humidity sensor.
- OneWire + DallasTemperature - Required if you're using a DS18B20 digital temperature sensor.
If you're not using any temperature sensor, you don't need to install DHT or OneWire/DallasTemperature libraries. Only ArduinoJson is required for all devices.
Library 1: ArduinoJson (Required for All Boards)
ArduinoJson is the most important library. It parses the JSON data sent by OceanRemote servers to control your relays and sensors.
Installation Steps:
- Open Arduino IDE
- Go to Sketch → Include Library → Manage Libraries
- In the search box, type "ArduinoJson"
- Look for "ArduinoJson by Benoit Blanchon"
- Click Install (version 6.21.0 or newer)
- Wait for installation to complete
OceanRemote firmware works with ArduinoJson version 6.x. Version 7.x may have breaking changes. Install version 6.21.0 for guaranteed compatibility.
Verifying ArduinoJson Installation:
- Go to File → Examples
- Look for "ArduinoJson" in the list
- If you see it, the library is installed correctly
// Test code to verify ArduinoJson
#include <ArduinoJson.h>
void setup() {
Serial.begin(115200);
Serial.println("ArduinoJson version: ");
Serial.println(ARDUINOJSON_VERSION);
}
void loop() {}
Upload this test code. If you see a version number in Serial Monitor, it's working!
Library 2: DHT Sensor Library (For DHT22/DHT11)
The DHT22 and DHT11 are popular temperature and humidity sensors. This library makes reading them simple.
| Feature | DHT22 | DHT11 |
|---|---|---|
| Temperature Range | -40°C to +80°C | 0°C to +50°C |
| Accuracy | ±0.5°C | ±2°C |
| Humidity Range | 0-100% | 20-80% |
| Sampling Rate | Every 2 seconds | Every 1 second |
| Price | $4-6 | $2-3 |
Installation Steps:
- In Library Manager, search for "DHT sensor library"
- Look for "DHT sensor library by Adafruit"
- Click Install
- It will ask to install dependencies. Click Install All (this includes "Adafruit Unified Sensor")
Verifying DHT Installation:
// Test code for DHT22/DHT11
#include <DHT.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
dht.begin();
Serial.println("DHT library working!");
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Sensor not connected");
} else {
Serial.print("Temp: "); Serial.print(t); Serial.print("°C, ");
Serial.print("Humidity: "); Serial.print(h); Serial.println("%");
}
delay(2000);
}
The DHT22 can only be read every 2 seconds. Reading faster may give errors. OceanRemote firmware handles this automatically.
Library 3: OneWire and DallasTemperature (For DS18B20)
The DS18B20 is a digital temperature sensor that uses the 1-Wire protocol. It's very accurate (±0.5°C) and multiple sensors can share the same pin.
- Very accurate (±0.5°C from -10°C to +85°C)
- Waterproof versions available (great for aquariums, outdoors)
- Multiple sensors on one pin (each has a unique 64-bit address)
- Range: -55°C to +125°C
Installation Steps:
- In Library Manager, search for "OneWire"
- Find "OneWire by Jim Studt" (or Paul Stoffregen version)
- Click Install
- Search for "DallasTemperature"
- Find "DallasTemperature by Miles Burton"
- Click Install
Verifying DS18B20 Installation:
// Test code for DS18B20
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(115200);
sensors.begin();
Serial.println("DS18B20 library working!");
}
void loop() {
sensors.requestTemperatures();
float temp = sensors.getTempCByIndex(0);
if (temp == -127.0) {
Serial.println("Sensor not connected");
} else {
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println("°C");
}
delay(1000);
}
DS18B20 requires a 4.7kΩ pull-up resistor between DATA and VCC. Without it, readings will fail or be erratic.
Library Installation Summary
| Library | Required For | Install? |
|---|---|---|
| ArduinoJson | ALL BOARDS | ✅ YES (required) |
| DHT sensor library | DHT22 or DHT11 sensor | ⚠️ Only if using DHT |
| Adafruit Unified Sensor | Dependency for DHT | ⚠️ Auto-installed with DHT |
| OneWire | DS18B20 sensor | ⚠️ Only if using DS18B20 |
| DallasTemperature | DS18B20 sensor | ⚠️ Only if using DS18B20 |
The NTC thermistor doesn't need any special library! It uses the built-in analogRead() function. No additional installation required.
Troubleshooting Library Issues
Problem: "ArduinoJson.h: No such file or directory"
- Solution: ArduinoJson is not installed. Go to Library Manager and install it.
Problem: "DHT.h: No such file or directory"
- Solution: DHT library not installed. Install "DHT sensor library by Adafruit".
Problem: "OneWire.h: No such file or directory"
- Solution: OneWire library not installed. Install "OneWire by Jim Studt".
Problem: Multiple library versions conflict
- Solution: Go to Documents/Arduino/libraries (Windows) or ~/Arduino/libraries (Mac/Linux) and delete old versions manually.
- Windows: C:\Users\[YourUser]\Documents\Arduino\libraries
- Mac: ~/Documents/Arduino/libraries
- Linux: ~/Arduino/libraries
Next Steps
Now that your libraries are installed, continue with:
- Tutorial 09: Configuring Board Settings
- Tutorial 10-15: Wiring diagrams for your specific board
- Tutorial 16-20: Working with sensors (DHT22, DS18B20, NTC)
- Return to Tutorial 02: Generate and flash your firmware!
All required libraries are now installed. Your Arduino IDE is fully configured for OceanRemote firmware.