Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Humidity Soil Sensor
// YL-39 + YL-69 humidity sensor
byte humidity_sensor_pin = A1;
byte humidity_sensor_vcc = 6;
int value;
void setup() {
// Init the humidity sensor board
pinMode(humidity_sensor_vcc, OUTPUT);
digitalWrite(humidity_sensor_vcc, LOW);
pinMode(13, OUTPUT);
// Setup Serial
while (!Serial);
void loop() {
digitalWrite(humidity_sensor_vcc, HIGH);
value = analogRead(humidity_sensor_pin);
digitalWrite(humidity_sensor_vcc, LOW);
Serial.println(1023 - value);
Serial.print("Humidity Level (0-1023): ");
// Serial.println(read_humidity_sensor());
if ((1023 - value) < 255) {
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment