Passing Alexa Moisture Sensor Data

I'm trying to make a system where Alexa can tell me what moisture percentage my plants are at, but I'm not sure how to pass the data through IOT and the Arduino Alexa skill.

I receive data from a moisture sensor and map it to 0-100 (representing moisture percent) as an int. From there I'm not sure how to pass it to Alexa, as ints aren't an accepted data type, and the closest accepted data type seems to be a temperature sensor reading.

Any help is appreciated.

Here is my code:

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/e4b4ee50-b7e5-4f2e-bae5-17fb775cbdb5 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  CloudTemperatureSensor percentageHumidity;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/


#include "thingProperties.h"
#define moistIn A0

const long wet = 300;
const long dry = 780;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  while(!Serial);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here
  
long moisture= analogRead(moistIn); //Read sensor Val

int percentageHumidity = map(moisture, wet, dry, 100, 0); //Map to a percentage value

Serial.println(moisture);
Serial.print("Soil is at ");
Serial.print((percentageHumidity));
Serial.print("% moisture");
Serial.println();
delay(3000);       //Print soil moisture % every 3 seconds

}

Try here

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.