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
charliesologuitar
 
Posts: 33
Joined: Thu Dec 15, 2022 11:55 am

HUZZAH Feather support for The Monk Capacitor Moisture Sensor?

Post by charliesologuitar »

Hi,

I just ordered two Monk Capacitor Moisture Sensors.....however, in prep, I am trying to compile the sample sketch, and getting this error message.....has anyone seen this before?
Cap_Moisture_Sensor_Error_message.docx
(39.28 KiB) Downloaded 3 times
MOD EDIT - adding image inline:
err_msg.png
err_msg.png (31.68 KiB) Viewed 117 times

Please help with suggestion!

Thank you,

Charlie T.



--------------------------------------------------------------------------------------------------------------------------------------------------

Code: Select all

#include "PlantMonitor.h"
PlantMonitor pm = PlantMonitor(10, 11); // RX, TX
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
char cmd = Serial.read();
if (cmd == 'l') {
pm.ledOff();
}
else if (cmd == 'L') {
pm.ledOn();
}
}
report();
delay(1000);
}
void report() {
Serial.print("Wetness: ");
Serial.print(pm.getWater());
Serial.print(" temp (C): ");
Serial.print(pm.getTemp());
Serial.print(" humidity: ");
Serial.println(pm.getHumidity());
}
Last edited by adafruit_support_carter on Tue Jan 17, 2023 3:01 pm, edited 1 time in total.

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

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

Post by adafruit_support_carter »

Please open an issue with MonkMakes. Here is the location of the Arduino library repo:
https://github.com/monkmakes/mm_plant_monitor

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,

Already did that. “Simon” suggested that I check with adafruit. This is a circle. Has anyone gotten this working before?

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

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

Post by adafruit_support_carter »

Did you create an issue in that repo? Not seeing one and it would help to be able to read the issue thread to see the discussion. The Arduino output is indicating an issue with that library code. And the same issue can be generated compiling for a "Generic ESP8266 Module", so it's not specific to the Adafruit Feather HUZZAH.

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 actually emailed Monk tech support directly.....(not sure how to create an issue in the repo).....this was his (Simon's) response (see below dashed line):

(and yes, the, "Software Serial" example sketches that are included with the Arduino IDE ESP 8266 compile fine)....there seems to be in issue with the PlantMonitor.h library.

Again, have any other Adafruit HUZZAH ESP 8266 customer reported similar issues?

Thank you for your help!

Charlie T.

--------------------------------------------------------------------------------------------------------------------------------------
"Hi Charlie,
The error you are getting points either to an incompatibility with the ESP8266 SoftwareSerial library, or some problem with the SoftwareSerial library and your Arduino environment. Do the Software Serial example sketches that are included with the Arduino IDE compile on your machine for the ESP8266?

This post, that uses SoftwareSerial on an SP8266 implies Software Serial should compile and work ok.
https://forum.arduino.cc/t/software-ser ... zah/644962

I'd also suggest posting on the Arduino or Adafruit forums to see if anyone else can shed some light on the problem.

Let me know how it goes.

Kind Regards,

Simon"

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

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

Post by adafruit_support_carter »

Thanks for sharing that. The generic example here compiles fine for ESP8266:
https://docs.arduino.cc/learn/built-in- ... are-serial

The usage being done in that Arduino forum thread is a little different. The GPS library takes in a reference to a serial instance created external to the library:
https://github.com/adafruit/Adafruit_GP ... _GPS.h#L89
The mm_plant_monitor library is trying to create its own instance:
https://github.com/monkmakes/mm_plant_m ... tor.cpp#L5

I still feel like this is an issue with the mm_plant_monitor library code. I've opened an issue here you can monitor:
https://github.com/monkmakes/mm_plant_monitor/issues/1

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 received this repsonse from Simon of Monk.....I am totally confused, what do you suggest please?
(again, ...I just ordered two of these Moisture sensors, however, if they are incompatible with the HUZZAH Feather, the Adafruit site should indicate this fact, and refund my money)
--------------------------------------------------------------------------------------------------------------------------------------

Hi Charlie,
In hardware terms, there is no compatibility problem. The PlantMonitor uses a serial interface at 9600 baud.
Because most Arduino-programable boards have only one serial port that is tied up with the USB port, The Plant Monitor library uses the SoftwareSerial library that emulates a serial port in software on pins of your choice. The problem you are seeing seems to be in how the PlantMonitor uses the ESP8266 implementation of SoftwareSerial. This may be subtly different to the SoftwareSerial implementation of 'regular' Arduino boards.
As you have got a basic SoftwareSerial example working, you might like to try ditching the PlantMonitor extension entirely and send serial commands directly to the PlantMonitor. For example if you send serial 'w' to the PlantMonitor, it will respond over serial with 'w=23' or whatever the wetness reading is. This is documented in the PlantMonitor's datasheet here: https://monkmakes.com/downloads/datashe ... onitor.pdf
I hope this helps,
Simon.

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

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

Post by adafruit_support_carter »

This may be subtly different to the SoftwareSerial implementation of 'regular' Arduino boards.
This is confusing semantics. I'm also not sure what a "regular" Arduino board is. If I had to guess, I'd guess they mean an Arduino UNO. Or perhaps only the boards one would find on Arduino's Hardware page:
https://www.arduino.cc/en/hardware
But this sort of goes against the general concept of Arduino. Ideally, an Arduino library should work on any Arduino board, where "Arduino board" means there is an Arduino Board Support Package for the given board/platform, like there is for AVR (what the first Arduino boards were, ex: UNO), ARM (much more powerful processor), ESP32 (cousin to ESP8266), ESP8266 (what you have), etc. So there is no "regular".

However, that's the ideal. Since all these hardware platforms have their specifics, actually achieving that for everything that needs to be done can be tricky. So there can be libraries that end up just not working on certain platforms. But that should be called out in the library - "ESP8266 not supported", etc. Or on the hardware product page that uses the library.
you might like to try ditching the PlantMonitor extension entirely and send serial commands directly to the PlantMonitor.
What they are suggesting here is to just not use the mm_plant_monitor library, which is this:
https://github.com/monkmakes/mm_plant_monitor
Instead, create a SoftwareSerial interface as done in the basic example:
https://docs.arduino.cc/learn/built-in- ... are-serial
and then *you* would write the necessary code to talk to the PlantMonitor via that SoftwareSerial interface, using the various read() and write() commands. Essentially, this means you'd be writing what the library code should be doing. The protocol is very simple and documented in the datasheet PDF they link:
proto.png
proto.png (78.29 KiB) Viewed 102 times
But still, you'd be writing the code to do the reading/writing in your user 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 »

Hi Carter,

Would this work?

(it seems to compile, and load ok, but I have not received the actual Moisture Sensor yet, from Adafruit...(it shipped yesterday)...maybe you can try on your end?

----------------------------------------------------------------------------------------------------------------------------------

Code: Select all

#include "SoftwareSerial.h"

#define RX (13)
#define TX (15)
char L=0;
char l=0;
int w=0;
int t=0;
int h=0;



SoftwareSerial swSer;

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


void loop() {
  if (Serial.available()) {
    char cmd = Serial.read();
    if (cmd == 'L') {
      L;
      Serial.println(" L Received ");
    }
    else if (cmd == 'l') {
      l;
      Serial.println(" l Received ");
    }
  }
  report();
  delay(1000);
}

void report() {
  Serial.print("Wetness: ");
  Serial.print(w);
  Serial.print(" temp (C): ");
  Serial.print(t);
  Serial.print(" humidity: ");
  Serial.println(h);
}

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

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

Post by adafruit_support_carter »

"Serial" is not the SoftwareSerial interface. It's "swSer". You need to use the SoftwareSerial instance to talk to the PlantMonitor:

Code: Select all

SoftwareSerial swSer;
You need to also call begin() on the instance in setup() (see example in SoftwareSerial library reference)

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,

Will this work?

--------------------------------------------------------------------------------------------------------------------------------------

Code: Select all

#include "SoftwareSerial.h"
#define RX (13)
#define TX (15)
char L=0;
char l=0;
int w=0;
int t=0;
int h=0;

SoftwareSerial swSer;

void setup() {
  Serial.begin(9600);
  swSer.begin(w);
  swSer.begin(t);
  swSer.begin(h);
	
}

void loop() {
  if (Serial.available()) {
    char cmd = swSer.read();
    if (cmd == 'L') {
      L;
      Serial.println(" L Received ");
    }
    else if (cmd == 'l') {
      l;
      Serial.println(" l Received ");
    }
  }
  report();
  delay(1000);
}

void report() {
  Serial.println("Wetness: ");
  Serial.print(w);
  Serial.println(" Temp: ");
  Serial.print(t);
  Serial.print(" Humidity: ");
  Serial.println(h);
  delay(5000);
  }
  

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

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

Post by adafruit_support_carter »

Sorry, but no.

Adafruit is just a reseller of that board, so the Adafruit product page description follows the one from Monk Make's shop:
https://monkmakes.com/pmon

The description says:
Compatible with micro:bit, Raspberry Pi, Arduino, Pico and most microcontroller boards.
I think the short answer here is that ESP8266 is not included in "most".

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,

If that is the case, the sensors that I just purchased from Adafruit are useless to me (I only own HUZZAH ESP8266 units). Please issue an rma for these two units: the order number is: 2998091-0805532297.

Thank you for your help, Carter.

Charlie T.

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

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

Post by adafruit_support_carter »

Before giving up, please try the sketch below. I don't have one of the plant monitors on hand to test directly, so was only able to confirm this compiles for a Feather ESP8266 HUZZAH.

Be sure to change these lines to whatever pins your are using (if different from what's shown above):

Code: Select all

// Set pins used here
#define rxPin 13
#define txPin 15
Here's the sketch:

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 »

Hi Carter,

I had a feeling you would come through! Well, it compiles, and seems to run, however, I have not received the sensor from Adafruit yet....will hook it up as soon as I get it....and let you know!!
Again, Thank you for your help, Carter!

Charlie T.

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

Return to “Feather - Adafruit's lightweight platform”