While dashboard software can be crafted in almost any language, the use of a browser-based interface comes with a massive advantage: cross-platform capabilities. Websites, by their very nature, need to be able to serve any device with an internet browser, and any web browser that wants to be popular needs to be able to view any website. This is why HTTP is a very useful descriptive language, as it is always (or, at least, should be) interpreted the same way by any browser.
But HTTP is just the client side of a web system; it cannot, by itself, do much with active content. This is where PHP comes in – PHP is a server-side language that can be used to get entries from databases, accept connection requests, read/write files, and so much more. Just like HTTP, PHP is also cross-platform, in that any server running a PHP server can run PHP code regardless of what system was used to code it. Only the designers of the PHP server worry about making sure their software works on different platforms, and PHP coders don’t have to worry about any platform specifics.
So, in our IoT dashboard series, we will look at creating a simple IoT dashboard that can accept different IoT device connections, show a list of active devices, and display this data in chart form. But the best part of this project is that any device connected to your local area network (LAN) will be able to access the website and be “interfaceable” via a mobile device without having to learn about device specifics (such as Android and Apple). In this How-To, we will learn how to configure a Windows machine to run a simple PHP website that will act as the foundation for our own IoT dashboard!
We will be using a Windows-based machine to run our server. This is because Windows systems are generally easier to work with and code on, so your first step will be to find a Windows system. Luckily for us, running a website server requires very few resources and will run on most systems (if not all). This means you can use a 10-year-old laptop, a small, low-powered computer, or even your everyday PC.
When the installer has finished downloading, you will need to install EasyPHP. The installation is very trivial, and once completed, you will need to launch EasyPHP. You can check to see if EasyPHP is running by looking in the tray icon for the following symbol:
To open the EasyPHP dashboard, you need to right click this icon and then click Open Dashboard. Your browser should open to a website located at http://127.0.0.1:1111/index.php - if your browser shows an error, then restart EasyPHP and try again.
With the dashboard open, we need to configure it to use a folder of our choice as the website directory that will store our IoT platform. Therefore, in the dashboard window, click the “Add Directory” button, and in the page that appears, fill in two boxes: directory name and path. For now, we will call our Working directory name “IoT Platform,” and we will create a folder in our documents folder called “iot.”
The last step is to run the HTTP server, so we can run our PHP code and allow our computer to visit the website. To do this, click the start button under the HTTP Server at the top.
The next step is to test our server by creating a test “index.php” file in our “iot” directory and then attempting to connect to our website. Create a blank file called “index.php” in our “iot” directory and copy and paste the following code into it:
<?php echo 'Hello, World!'; ?>
To test if the site is functioning correctly, go to the EasyPHP dashboard and click the name of our project. The browser should redirect to http://127.0.0.1/edsa-IoT%20Platform/ -- if the following page shows, then our system is functioning and ready for development!
There are many opportunities for this server that we’ll explore in upcoming posts -- making an IoT dashboard, graphs, and even a Solar IoT panel project to cap it all off!