Tutorial advanced 2:
Web Server: read a Sensor
Content of the tutorial:
Dear User, in the former tutorial we have seen how to use a Web Server to set the
status of a device using your browser directly connected to the same local
network as your control system.
A sensor is a device connected to your controller. Normally it is used to
know the value some entities belonging to the environment around. For instance a
temperature sensor give us the temperature value, the umidity sensor the value
of umidity, and so on.
There are mainly two kind of sensors: analog sensors and digital sensor. Analog sensor are for instance: temperature, pressure, umidity, light, gas, liquid flow, wind and movement sensor. Digital sensor are counters, switches, buttons, triggers, proximity, security sensor.
We can manage both kind of sensor. The only attention we have to pay is to connect analog sensor to analog pins of our controller and digital sensors to digital pins as well.
Note that when an analog sensor is connected to an analog pin of the controller, the read value is converted in a value that is in a range that depends on how many bits are used for the A/D conversion (10 bits corresponds to 0-1023 range ov integer values). However the read value will be automatically remapped to the range we really need, simply by configuring the new range (normally the range for a correct remapping is provided by the sensor documentation/datasheet).
If you want a better accuracy to represent the read value, you can use an external A/D converter, but this is out of the scope of this tutorial.
Refer to Web Server section in Devise Home User Manual to see how to configure our Web Server to read values provided by our sensors.
A this point of this tutorial we have understood how to build a simple system that allows you to move one or more switches and/or read the value of one or more sensors. There is still one important thing that has not been explained yet: how to get the control of your system through your mobile.
What I'm going to describe to you is one of the most powerful features of Devise Home. As a matter of facts, you will soon discover that this operation is very simple, despite all the complex configurations (IP, Router, DNS etc.) that other systems normally require.
So, let's assume that, as preliminary actions, you have:
Well, it's now time to take in your hands your mobile, open your preferred browser (chrome and firefox are the most recommended), go to Devise Home website: www.devisehome.com and execute log in with your personal credentials.
At this point, if any of the previous steps have been done correctly, you can see a web page, named 'Control Panel', containing one (or more if you have connected more projects to internet) push button with the name of your Project (this button disappeares when your system is switched off or disconnected from internet). This button will lets you have access to the page of your system, where you can control everything is included in your project. Try it and see it is simpler than talk about it!