HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
adafruit_support_carter
 
Posts: 29466
Joined: Tue Nov 29, 2016 2:45 pm

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by adafruit_support_carter »

OK, give it a go when you can and reply back here with what happens. Even it doesn't work right away, it shouldn't take much tweaking to get it to work. May need to iterate a few times.

User avatar
charliesologuitar
 
Posts: 33
Joined: Thu Dec 15, 2022 11:55 am

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by charliesologuitar »

Will do, I will hopefully receive the Sensor in a few days.....again, Thank You for all your time, and help, Carter....

User avatar
charliesologuitar
 
Posts: 33
Joined: Thu Dec 15, 2022 11:55 am

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by charliesologuitar »

Hi Carter,

I have the sensor hooked up to the HUZZAH, but not getting any data from it.....the sensor LED is on, and varies in color when I touch it, so it (the sensor) definitely has power, but HUZZAH is not seeing data....should the pins be changed (I am using 13 and 15 for rx and tx)?

Charlie

User avatar
adafruit_support_carter
 
Posts: 29466
Joined: Tue Nov 29, 2016 2:45 pm

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by adafruit_support_carter »

Please paste here what is showing up in the Serial Monitor when you run the sketch.

User avatar
charliesologuitar
 
Posts: 33
Joined: Thu Dec 15, 2022 11:55 am

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by charliesologuitar »

Carter,

Also, the large LED on the sensor does respond to ledOff() and ledOn() functions (I type in a, "L" for ledOn, and, "l" for ledOff, but I am not getting any sensor data. This is the current sketch (I modified you sketch slightly)...

Code: Select all

// This is, Charlie_Code_Rev1 - 1/19/23

#include <SoftwareSerial.h>

#define BUFMAX 20

// Set pins used here
#define rxPin 13
#define txPin 15

SoftwareSerial ss =  SoftwareSerial(rxPin, txPin);


//------------------------------------------------------------
// Monk Makes Plant Monitor helper functions
//------------------------------------------------------------

int parseInt() {
  char buf[BUFMAX];
  for (uint8_t i=0; i<BUFMAX; i++) {
    buf[i] = ss.read();
    if (buf[i]=='\n') break;
  }
  return atoi(buf);
}

float parseFloat() {
  char buf[BUFMAX];
  for (uint8_t i=0; i<BUFMAX; i++) {
    buf[i] = ss.read();
    if (buf[i]=='\n') break;
  }
  return atof(buf);  
}

float getWater() {
  ss.write("w");
  while (!ss.read() == '=') {};
  return parseFloat();
}

float getTemp() {
  ss.write("t");
  while (!ss.read() == '=') {};
  return parseFloat();  
}

float getHumidity() {
  ss.write("h");
  while (!ss.read() == '=') {};
  return parseFloat();   
}


// I beleive these "ledOn" and "ledOff" functions, simply send either an L, or l, to the Moisture Sensor, via the "SoftwareSerial protcol" 

void ledOn() {
  ss.write("L");
}

void ledOff() {
  ss.write("l");
}

//--------------------------------------
// End of Plant Monitor functions
//--------------------------------------


//--------------------------------------
// Setup function 
//--------------------------------------

void setup() {
  Serial.begin(9600);

  // initialize software serial
  ss.begin(9600);

 // Initialize the built-in LED as an output, and initially off
  pinMode(LED_BUILTIN, OUTPUT);     
  digitalWrite(LED_BUILTIN, HIGH);


  // blink LED at start...not sure which LED this refers to -CT
  for (uint8_t i=0; i<5; i++) {
    delay(200);
    ledOn();
    delay(200);
    ledOff();
  }
}

//--------------------------------------
// End of Setup function
//--------------------------------------



//--------------------------------------
// Main Loop function
//--------------------------------------

void loop() {
//  int water;
  float temperature, humidity, water;

  water = getWater();
  temperature = getTemp();
  humidity = getHumidity();

  Serial.print("Soil Moisture level (in percent %) = "); Serial.println(water);
  Serial.print("Ambiant Temperature (in degrees C) = "); Serial.println(temperature);
  Serial.print("Ambiant Relative Humidity level (in percent %) = "); Serial.println(humidity);
  Serial.print("  \n"); 
 
 
 // This "if", custom statement (my idea), will looks at the serial monitor message for an, L or l, input, and react as such //

  if (Serial.available()) {
    char cmd = Serial.read();
    if (cmd == 'L') {
      ledOn();
      Serial.print("L received;  LED should be on  \n"); 
      digitalWrite(LED_BUILTIN, LOW);
    }
    else if (cmd == 'l') {
       ledOff();
       Serial.print("l received; LED should be off  \n"); 
       digitalWrite(LED_BUILTIN, HIGH);
    }
    
  }
 
  
 delay(7000);

}


//-------------------------------
// End of Main Loop and sketch
//-------------------------------

User avatar
adafruit_support_carter
 
Posts: 29466
Joined: Tue Nov 29, 2016 2:45 pm

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by adafruit_support_carter »

Is this stuff showing up in the Serial Monitor at all?

Code: Select all

  Serial.print("Soil Moisture level (in percent %) = "); Serial.println(water);
  Serial.print("Ambiant Temperature (in degrees C) = "); Serial.println(temperature);
  Serial.print("Ambiant Relative Humidity level (in percent %) = "); Serial.println(humidity);
  Serial.print("  \n"); 

User avatar
charliesologuitar
 
Posts: 33
Joined: Thu Dec 15, 2022 11:55 am

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by charliesologuitar »

HI Carter,

Yes, this is the serial output:
Attachments
HUZZAH_Moisture_Sensor_Code_Output_1_20_23.docx
(54.54 KiB) Downloaded 11 times

User avatar
adafruit_support_carter
 
Posts: 29466
Joined: Tue Nov 29, 2016 2:45 pm

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by adafruit_support_carter »

Try this:

Code: Select all

#include <SoftwareSerial.h>

#define BUFMAX 20

// Set pins used here
#define rxPin 13
#define txPin 15

SoftwareSerial ss =  SoftwareSerial(rxPin, txPin);

//------------------------------------------------------------
// Monk Makes Plant Monitor helper functions
//------------------------------------------------------------
int parseInt() {
  char buf[BUFMAX];
  for (uint8_t i=0; i<BUFMAX; i++) {
    buf[i] = ss.read();
    if (buf[i]=='\n') break;
  }
  return atoi(buf);
}

float parseFloat() {
  char buf[BUFMAX];
  for (uint8_t i=0; i<BUFMAX; i++) {
    buf[i] = ss.read();
    if (buf[i]=='\n') break;
  }
  return atof(buf);  
}

int getWater() {
  ss.write("w");
  while (!(ss.read() == '=')) {};
  return parseInt();
}

float getTemp() {
  ss.write("t");
  while (!(ss.read() == '=')) {};
  return parseFloat();  
}

float getHumidity() {
  ss.write("h");
  while (!(ss.read() == '=')) {};
  return parseFloat();   
}

void ledOn() {
  ss.write("L");
}

void ledOff() {
  ss.write("l");
}



void setup() {
  Serial.begin(9600);

  // initialize software serial
  ss.begin(9600);

  // blink LED at start
  for (uint8_t i=0; i<5; i++) {
    delay(200);
    ledOn();
    delay(200);
    ledOff();
  }
}

void loop() {
  int water;
  float temperature, humidity;

  water = getWater();
  temperature = getTemp();
  humidity = getHumidity();

  Serial.print("Water = "); Serial.println(water);
  Serial.print("Temperature = "); Serial.println(temperature);
  Serial.print("Humidity = "); Serial.println(humidity);

  delay(1000);
}

User avatar
charliesologuitar
 
Posts: 33
Joined: Thu Dec 15, 2022 11:55 am

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by charliesologuitar »

Same output basically.......no data...

User avatar
adafruit_support_carter
 
Posts: 29466
Joined: Tue Nov 29, 2016 2:45 pm

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by adafruit_support_carter »

Yah, don't know. It's probably something simple, but I think iterating here is going to be too painful. Guessing you still want a refund?

User avatar
charliesologuitar
 
Posts: 33
Joined: Thu Dec 15, 2022 11:55 am

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by charliesologuitar »

Carter,

Check this out...getting data now, but not sure if it is accurate.....think I am real close...

Code: Select all

// This is, Charlie_Code_Rev3 - 1/20/23

#include <SoftwareSerial.h>

#define BUFMAX 20

// Set pins used here
#define rxPin 13
#define txPin 15

SoftwareSerial ss =  SoftwareSerial(rxPin, txPin);


//------------------------------------------------------------
// Monk Makes Plant Monitor helper functions
//------------------------------------------------------------

int parseInt() {
  char buf[BUFMAX];
  for (uint8_t i=0; i<BUFMAX; i++) {
    buf[i] = ss.read();
    if (buf[i]=='\n') break;
  }
  return atoi(buf);
}

float parseFloat() {
  char buf[BUFMAX];
  for (uint8_t i=0; i<BUFMAX; i++) {
    buf[i] = ss.read();
    if (buf[i]=='\n') break;
  }
  return atof(buf);  
}

float getWater() {
  ss.write("w");
  while (!ss.read() == '=') {};
  return parseFloat();
}

float getTemp() {
  ss.write("t");
  while (!ss.read() == '=') {};
  return parseFloat();  
}

float getHumidity() {
  ss.write("h");
  while (!ss.read() == '=') {};
  return parseFloat();   
}


// I beleive these "ledOn" and "ledOff" functions, simply send either an L, or l, to the Moisture Sensor, via the "SoftwareSerial protcol" 

void ledOn() {
  ss.write("L");
}

void ledOff() {
  ss.write("l");
}

//--------------------------------------
// End of Plant Monitor functions
//--------------------------------------


//--------------------------------------
// Setup function 
//--------------------------------------

void setup() {
  Serial.begin(9600);

  // initialize software serial
  ss.begin(9600);

 // Initialize the built-in LED as an output, and initially off
  pinMode(LED_BUILTIN, OUTPUT);     
  digitalWrite(LED_BUILTIN, HIGH);


  // blink LED at start...not sure which LED this refers to -CT
  for (uint8_t i=0; i<5; i++) {
    delay(200);
    ledOn();
    delay(200);
    ledOff();
  }
}

//--------------------------------------
// End of Setup function
//--------------------------------------



//--------------------------------------
// Main Loop function
//--------------------------------------

void loop() {
//  int water;
  float temperature, humidity, water;

  water = getWater();
  temperature = getTemp();
  humidity = getHumidity();

  Serial.print(" \n");
  ss.write("w");
  ss.read();
  Serial.print("Soil Moisture level (in percent %) = "); Serial.print(ss.read());
  Serial.print(" \n");

  ss.write("t");
  ss.read();
  Serial.print("Ambiant Temperature (in degrees C) = "); Serial.print(ss.read());
  Serial.print(ss.read());
  Serial.print(" \n");

  ss.write("h");
  ss.read();
  Serial.print("Ambiant Relative Humidity level (in percent %) "); Serial.print(ss.read());
  Serial.print(ss.read());
  Serial.print(" \n");
  Serial.print(" \n"); 


 // This "if", custom statement (my idea), will looks at the serial monitor message for an, L or l, input, and react as such //

  if (Serial.available()) {
    char cmd = Serial.read();
    if (cmd == 'L') {
      ledOn();
      Serial.print("L received;  LED should be on  \n"); 
      digitalWrite(LED_BUILTIN, LOW);
    }
    else if (cmd == 'l') {
       ledOff();
       Serial.print("l received; LED should be off  \n"); 
       digitalWrite(LED_BUILTIN, HIGH);
    }
    else if (cmd == 'v') {
       Serial.print("v received; this is version  \n");
       ss.write("v");
       ss.read();
       Serial.print(ss.read());
       Serial.print(" \n");
    }
  }
 
  
 delay(7000);

}


//-------------------------------
// End of Main Loop and sketch
//-------------------------------
Attachments
HUZZAH_Moisture_Sensor_Code_Output_1_20_23_R3.docx
(50.73 KiB) Downloaded 10 times

User avatar
charliesologuitar
 
Posts: 33
Joined: Thu Dec 15, 2022 11:55 am

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by charliesologuitar »

Hi Carter,

I think I got it working!!!

See attached (note: probe was not in soil at the time of reading, therefore 0 moisture reading)

Charlie

User avatar
adafruit_support_carter
 
Posts: 29466
Joined: Tue Nov 29, 2016 2:45 pm

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by adafruit_support_carter »

Neat. The values are changing and do look reasonable.

The temperature and humidity is coming from the sensor in the red box. Can try breathing on that to see if temperature and humidity go up.

The soil moisture is based on a capacitance reading of the "blade" part of the board (green arrow). Try grabbing that and pressing between fingers to see if moisture reading changes.
sens.png
sens.png (149.46 KiB) Viewed 79 times

User avatar
charliesologuitar
 
Posts: 33
Joined: Thu Dec 15, 2022 11:55 am

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by charliesologuitar »

Hi Carter,

This is another output, with the sensor sitting in approx 2 " of water in a coup....

Charlie...
Attachments
Capacitive_Moisture_Sensor_Output_working!.docx
(35.76 KiB) Downloaded 11 times

User avatar
charliesologuitar
 
Posts: 33
Joined: Thu Dec 15, 2022 11:55 am

Re: HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by charliesologuitar »

Carter,

For some weird reason, I am no longer getting any data from Moisture sensor.....Version is coming back as, "0"....it was, "1", when working...

Sensor on board large LED lights and changes color when I touch it....seems to be a comm issue...

(same sketch...no code changes)..

Any idea what might have happened?  I tried power cycling but no change...any ideas? If bad, how do I return for a replacement?

Charlie...

Locked
Please be positive and constructive with your questions and comments.

Return to “Feather - Adafruit's lightweight platform”