Sunday, May 17, 2015

The following HTML tags and attributes:


During the few weeks driving an Arduino to log temperature, humidity and light in a room at home, the information sent to Veran via Ethernet. This allows triggering of the scenes and see the current value in vera interface.

LDR
In order to run DHT11 needed an additional library, more info on the Arduino website tca and library are available on Github. library, then put under "Arduino-1.0.6 \ Libraries \ DHT11" so unless you're running version 1.0.6, otherwise it versionsnummet for your Arduino installation that apply.
I have used Ethernet sketch that follows tca the installation of the Arduino software, however, so I have written this to suit my reporting to Vera. I have also assumed DHT11_test to fåtill temperature tca and humidity with DHT11.
At the beginning tca of the code so defined all the variables that need to be changed. Because I define everything in the beginning of the code so you do not lose the code and modify to make more donors. But it is enough to change tca a few lines. (IPAddress ip, mac [], veraLjusID, veraHumidityID, veraTempid)
int sensorPin = A0; // Analog port to be used to read analogue values, ie, light sensor int value = 0; // The value of the analog unit will be stored here. float loop delay = 300000; // How many milliseconds tca loop to wait. Have as default tca run 300000ms, ie 5 minutes between reports. float temp sensor; // Variable temperatures. tca float humiditygivaren; // Variable for the humidity.
int Server port = 3480; // Port to which the data should be reported tca on the reserve. This is the default so it should not require changes. IPAddress ip (10,10,10,123); // Enter the IP address of your Arduino will use, should be on the same subnet as your Vera controller!
switch (chk) {case 0: Serial.println ("OK"); break; case -1: Serial.println ("checksum error"); break; Case -2: Serial.println ("Time out error"); break; default: Serial.println ("Unknown error"); break; }
By calling DHT11.humidity then return the current value as a float for the variable "humiditygivaren" Temperature sensor invoked by utilizing DHT11.temperature. These values are sent directly to the function that reports to Vera.
By reading the analog value of the light sensor tca and save the sensor value, I get a value between 0 - 1024. vera light sensor shows the data as a percent, so the value must be recalculated before sending it to Vera.
To calculate the value 0-1024 to percent, I have used a formula I found on the following page. float percent = Sensor Value / 1024.0 * 100; // Value that was read is divided by 1024 and multiplying by 100 to obtain percent. Sensor value = floor (percent * 100) / 100;
To avoid having so much code in the loop, I have made three features that reports data to Vera, I will do this to a single function instead of three later. tca I have written only about one below, because the other two look almost tca identical.
client.print ("GET / data_request? id = variableset & DeviceNum ="); // Build the beginning of the http string client.print (GivarID); // Adds the ID that it will report to Vera client.print( &serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value= ); adds to the string of temperature schedule in Vera. client.print (Center Value); // Adds the temperature at the end of the string client.println ("HTTP / 1.1"); // End the row with http version and post client.print ("Host"); client.print (server); client.println ("Connection: close"); client.println (); Serial.println ("sent the temperature to Vera, disconnects"); client.stop ();
Upcoming features in the Arduino Project: Report of light - check Report temperature - check Report humidity - check Replace temperature sensor to the DS18B20 PIR Sensor Triggering the temperature change of X% Triggering on changes in light Triggering on changes in humidity Warn if the unit can not communicate with Vera. Convert to WiFi, hopefully ESP8266
The following HTML tags and attributes: <a href="" title=""> <abbr tca title = ""> <acronym title = ""> <b> <blockquote cite = ""> <cite> <code> <del datetime = ""> <em> <i> <q cite = ""> <p> <strike> <strong>
Categories Arduino (10) Miscellaneous (5) guide (34) Home automation (97) News (32) Requests from readers (5) Monitoring (35) PowerShell (11) Competition (3) Telldus (2) Test / Review (17) Unboxing (1) VBScript (4) Vera (61) Z-Wave (37)
Popular posts Automates celebrates 100th post with a contest! Vera UI7 - Version 7.0.6 - Firmware 1.7.569 / 07.01.1089 tca Vera Secure comes the summer! Raspberry Pi 2 & Windows Iot Core

No comments:

Post a Comment