Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Capacitive soil moisture sensor
#include <SPI.h>
#include <Wire.h>
#include <SFE_MicroOLED.h>
#define PIN_RESET 255
#define DC_JUMPER 0
int i;
int moi = 0;
MicroOLED oled(PIN_RESET, DC_JUMPER); // Example I2C declaration
void setup()
{
oled.begin();
oled.clear(ALL); //will clear out the OLED's graphic memory.
oled.clear(PAGE); //will clear the Arduino's display buffer.
}
void loop()
{
oled.clear(PAGE);
moi = analogRead(0);
oled.setFontType(0);
oled.setCursor(7, 0);
oled.print("Moisture: ");
oled.setFontType(2);
oled.setCursor(14, 15);
oled.print(moi); // Print an integer
oled.display();
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment