Just getting to grips with EasyIoT.
Im running it on a Raspi v2 and intend to use ESP8266 boards as the basis of the devices over http. Im using the Arduino IDE for now to program the ESP boards directly.
Ive got one running with a DHT22 Temp and humidity sensor posting the temperature to EasyIoT without any issues.
After connecting to the server the Http post and response looks like this:
POST data to URL: POST /Api/EasyIoT/Control/Module/Virtual/N5S0/ControlLevel/23.80 HTTP/1.1
Host: 192.168.0.52
Connection: close
Authorization: Basic xxxxxxxxxxxxxxx
Content-Length: 0
HTTP/1.1 200 OK
Server: HttpGateway
Content-Type: application/json; charset=utf-8
Date: Tue, 15 Sep 2015 16:35:58 GMT
Content-Length: 27
Connection: close
[{ "ResponseValue" : "1" }]
Connection closed
All well and good and the values are getting logged and appearing in the graph.
But how do I post multiple sensor values in the same http post?
For example Id like to also post up the humidity at the same time.
Or do I have to make multiple connections and http posts for each separate value?
Sorry couldnt find an answer in the forum or website.
Also it seems a virtual module can have more than one parameter but the http post string doesnt specify which parameter the value is for.
If the virtual module im using has 2 parameters.
Humidity and temperature how would i specify which parameter the value goes in to?
At some point ill need to add the battery level to each module as well so i have a need to post multiple parameters for each module. Am i using the wrong module for this in the virtual module?
Bit quiet on here init?
Anybody able to point me in the right direction?
This is bit of a show stopper for me not being able to find any documentation on the http post stuff for the virtual driver.
EasyIoT seemed a good choice as it seemed to have a good balance between simplicity and too many features.
Yes it is possible to send as many variables as you want form your sketch, I have found that I have learned most of what I need to know about EasyIOT by looking at the diffrent projects that others are doing as well as reading about other peoples problems.
Here is my code for an ESP connected to a DHT11.....same as DHT22 just not as accurate. You will notice that I only update to the EasyIOT server when something changes....
// DHT Sensor Setup
#define DHTPIN 2 // We have connected the DHT to Digital Pin 2
#define DHTTYPE DHT11 // This is the type of DHT Sensor (Change it to DHT11 if you're using that model)
DHT dht(DHTPIN, DHTTYPE, 15); // Initialize DHT object
void startWiFi(){
Serial.print("Connecting to ");
Serial.println(ssid);
do {
t = dht.readTemperature();
h = dht.readHumidity();
Serial.print("Temperature: ");
Serial.println(t);
Serial.print("Humidity: ");
Serial.println(h);
} while (t == 85.0 || t == (-127.0));
if (t != oldTemp)
{
sendTemp(t);
oldTemp = t;
}
if (h != oldHumid)
{
sendHumidity(h);
oldHumid = h;
}
Thanks for that.
Its pretty much what Ive already got.
Im trying to find out if I can do it in one http transaction.
You have 2 separate http posts.
You open a connection to the server.
Post one value to the first node and close the connection.
Then open a connection post the next value to the second node and close the connection again.
If thats the only way to do it Ill have to.
But also you have 2 separate nodes rather than a single node able to hold 2 values.
Id like a single node to hold multiple related values.
For example Temp, humidity and voltage.
To hold each of these in a separate node for each value would make a dozen sensors very difficult to manage.
Is there any documentation ive missed that might help me with this?
Theres a query on esp8266.com as well asking how its possible to do this.
So the info is needed by more than just me.
www.esp8266.com/viewtopic.php?f=29&t=5629
Can you help us out.
Once i have the answers about multiple fields per node and multiple values in an http post i can write it up for others to use.