i have a litle problem , i use mysensor gateway usb arduino uno and nano arduino for node , i try soil moister sensor as a humidity sensor it's work very well , this the sketch for convert 0-1023 like a 0-100% but when i want put some blocky for send me alert , i click on show current states and my sensor is alway 2 or 3 .
the sketch :
Code: Select all
#include <SPI.h>
#include <MySensor.h>
#define ANALOG_INPUT_SOIL_SENSOR A0
#define CHILD_ID 0 // Id of the sensor child
MySensor gw;
MyMessage msg(CHILD_ID, V_HUM);
int lastSoilValue = -1;
void setup()
{
gw.begin();
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Soil Moisture Sensor - analog", "1.0");
// sets the soil sensor analog pin as input
pinMode(ANALOG_INPUT_SOIL_SENSOR, INPUT);
// Register all sensors to gw (they will be created as child devices)
gw.present(CHILD_ID, S_HUM);
}
void loop()
{
// Read analog soil value
int soilValue = analogRead(ANALOG_INPUT_SOIL_SENSOR);
if (soilValue != lastSoilValue) {
Serial.println(soilValue);
gw.send(msg.set(constrain(map(soilValue, 1023, 250, 0, 100),0,100)));
lastSoilValue = soilValue;
}
// Power down the radio and arduino until analog input changes.
gw.sleep(1000);
}
Code: Select all
ID Name Current state Last updated sValues
1 Memory Usage 2015-05-24 23:00:00 17.17
2 HDD /boot 2015-05-24 23:00:00 25.69
3 HDD / 2015-05-24 23:00:00 42.62
4 Internal Temperature 2015-05-24 23:00:00 39.0
13 temp humid dht 22 2015-05-24 22:56:06 21.5;56;1
25 sol 2015-05-24 22:59:50 3
the json request just for see all parameters , i have this from http://192.168.0.41:8080/json.htm?type=devices&rid=25
Code: Select all
{
"ActTime" : 1432500584,
"ServerTime" : "May 24 2015 22:49:44",
"Sunrise" : "05:59:00",
"Sunset" : "21:35:00",
"result" : [
{
"BatteryLevel" : 100,
"CustomImage" : 0,
"Data" : "Humidity 19 %",
"Favorite" : 0,
"HardwareID" : 2,
"HardwareName" : "tt",
"HaveTimeout" : false,
"Humidity" : 19,
"HumidityStatus" : "Dry",
"ID" : "0200",
"LastUpdate" : "2015-05-24 22:49:43",
"Name" : "sol",
"Notifications" : "false",
"PlanID" : "0",
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : 12,
"SubType" : "LaCrosse TX3",
"Timers" : "false",
"Type" : "Humidity",
"TypeImg" : "temperature",
"Unit" : 1,
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "25"
}
],
"status" : "OK",
"title" : "Devices"
}[code]