Skip to content

Instantly share code, notes, and snippets.

@xxlukas42
Created July 16, 2018 18:58
Show Gist options
  • Save xxlukas42/e8250cb0e414fbd00fa75e59ae3527e7 to your computer and use it in GitHub Desktop.
Save xxlukas42/e8250cb0e414fbd00fa75e59ae3527e7 to your computer and use it in GitHub Desktop.
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