EDIT!!
I found a tutorial from sparkfun! And read the documents about analog and publishing.
But still no data showing.
With this code:
/* SparkFun Inventor's Kit for Photon
Experiment 3 - Part 2: Internet Houseplant Monitor
This sketch was written by SparkFun Electronics
Joel Bartlett <joel@sparkfun.com>
August 31, 2015
https://github.com/sparkfun/Inventors_Kit_For_Photon_Experiments
This application monitors the moisture level of your houseplant
and exposes that data to be monitored via the Internet.
Development environment specifics:
Particle Build environment (https://www.particle.io/build)
Particle Photon RedBoard
Released under the MIT License(http://opensource.org/licenses/MIT)
*/
int val = 0;//variable to store soil value
int soil = A2;//Declare a variable for the soil moisture sensor
int soilPower = D6;//Variable for Soil moisture Power
//Rather than powering the sensor through the V-USB or 3.3V pins,
//we'll use a digital pin to power the sensor. This will
//prevent oxidation of the sensor as it sits in the corrosive soil.
void setup()
{
Serial.begin(9600); // open serial over USB
pinMode(soilPower, OUTPUT);//Set D7 as an OUTPUT
digitalWrite(soilPower, LOW);//Set to LOW so no power is flowing through the sensor
//This line creates a variable that is exposed through the cloud.
//You can request its value using a variety of methods
Spark.variable("soil", &val, INT);
}
void loop()
{
Serial.print("Soil Moisture = ");
//get soil moisture value from the function below and print it
Serial.println(readSoil());
delay(1000);//take a reading every second
//This time is used so you can test the sensor and see it change in real-time.
//For in-plant applications, you will want to take readings much less frequently.
//If your soil is too dry, turn on Red LED to notify you
//This value will vary depending on your soil and plant
if(readSoil() < 200)
{
// take control of the RGB LED
RGB.control(true);
RGB.color(255, 0, 0);//set RGB LED to Red
}
else
{
// resume normal operation
RGB.control(false);
}
}
//This is a function used to get the soil moisture content
int readSoil()
{
digitalWrite(soilPower, HIGH);//turn D6 "On"
delay(10);//wait 10 milliseconds
val = analogRead(soil);
digitalWrite(soilPower, LOW);//turn D6 "Off"
return val;
}
I then go look at my dashboard where it says it goes online.
=> {“data”:“online”,“ttl”:“60”,“published_at”:“2016-03-29T22:30:03.051Z”,“coreid”:“mycoreid”,“name”:“spark/status”
and then when I look where the Json is showed I get
=> [
{
“id”: “myid”,
“name”: “beetlgeuze”,
“last_app”: null,
“last_ip_address”: “MyIp!!”,
“last_heard”: “2016-03-29T22:30:48.895Z”,
“product_id”: 0,
“connected”: true,
“platform_id”: 0,
“cellular”: false
}
]
with id and acces token
{
“ok”: false,
“error”: “Variable not found”
}
I don’t see what I did wrong? I hope I am specific enough now! (no condescending on the reply whatsoever!!)
FYI= I changed the real ID’s with the myid or similar because I don’t know if it is vulnerable to security.
And I’m not using a Sparkphoton but a real particle photon (maybe for the powering of the sensor) and this with this sensor but except for a rain I use a Soil. In the future I want the rain module as well.