I'm trying to use an Arduino MKR wifi1010 to monitor soil moisture temperature, and I'd like to use the Amazon Alexa Arduino skill to send this data to my Alexa. After messing with it for a while, I've come to the realization that Alexa only plays nicely with certain devices and data types, and moisture sensors aren't one of them.
Is there a way I can get around this issue so that I can have my Alexa tell me my soil moisture percentage? I tried setting the percentage value as a long variable and then setting up the connection to Alexa using a temperature sensor value (which is listed as a long variable on the Alexa-compatible datatypes website) but this didn't work, and I ended up just getting no data sent to my Alexa. I'll paste my code here for reference:
/*
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
float 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
}