element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Implementing my Local Webserver - a frustrating, yet instructional story.
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: neilk
  • Date Created: 17 Dec 2018 4:19 PM Date Created
  • Views 2247 views
  • Likes 5 likes
  • Comments 8 comments
  • apache_server
  • readynas
  • wi-fi
  • arduino_tutorials
  • esp-8266
  • netgear
  • witty
  • php
  • xampp
  • arduino
Related
Recommended

Implementing my Local Webserver - a frustrating, yet instructional story.

neilk
neilk
17 Dec 2018

I've long harboured the dream of remotely monitoring the temperature in my greenhouses, but have been put-off by the need to run cables, or invest in relatively costly WiFi shields for my Arduinos. I'm sure there are other solutions, but let's not go there

 

And then I read this blog from ntewinkel:  https://www.element14.com/community/community/project14/mixing-electronics-water/blog/2018/04/13/remote-temperature-monitoring

 

I was already aware of ESP8266 devices, but hadn't appreciated how cheap and easy to use they were! Nico kindly offers access the code in his Github repository in the Blog post, and when I contacted him privately, he very kindly offered me some space on his Server so I could try things out. On his advice, I ordered up a Witty, which comes as a stand alone ESP8266 board, powered via a micro USB connector. This plugs into a separate board, carrying a UART, for programming purposes (Arduino IDE) and also delivers power.

 

I was soon up and running, logging the temperature at my desk to Nico's Server and getting graphs back.

 

Fascinated by Nico's scripts - html and php - I decided that maybe I should set up my own, Web Server on my private network. I run a Windows 7 professional desktop machine which I have used in the past to run Microsoft Internet Information Server, when I was helping a friend enhance his website. To my annoyance, this has "disappeared" from my PC and I couldn't seem to find a way that I trusted to re-install it - it's no longer offered as an option under the Add/Remove Windows Components feature.

 

OK - lets see if we can establish an Apache server. No problem! But so many options to configure, most of which I didn't understand! I got it working with a simple html page I'd written some time ago to help my grand daughter. It uses a cascading style sheet and displays an image, both from separate folders.So it's a good test

 

Now for php. This seemed problematic, with lots of conflicting advice from Mr Google. Eventually I came across the XAMPP  website:  https://www.apachefriends.org/index.html . These are integrated installations for Apache, PHP, MYSQL and other tools. The Installation was straightforward (after I uninstalled the original Apache) and I soon had Nico's scripts working on my own server.

 

I did have a brief mental block over needing to refer to my PC server by its IP address when calling from the ESP8266 code, and as Localhost when calling the graphical display from my browser command line. Error messages from webservers seem to give little away!

 

I was happy with this set up to begin with and was able to tinker with Nico's original scripts to change the way in which the graph was displayed, and then to change the ESP8266 sketch to log temperatures from a second sensor to a separate file.

 

It soon became apparent that I had sort of backed myself into a corner - if I wanted this to run 24/7 I would either have to leave my PC running 24/7 (not keen on this) or implement another server which I would be happy to leave running. I looked  around for ideas and realised that my Netgear READYNAS Network Attached Storage unit runs 24/7 A quick chat with Mr Google revealed an official Netgear method of using the existing Apache server for your own private Web Server.

 

Unfortunately this didn't work for me, as described in the Netgear document...........further chats with Mr Google provided no help whatever. I tried the usual trick of rebooting the READYNAS, to no avail, and I was unwilling to try restoring the device to factory settings because of all the re-setting back up that would entail.

 

I went round and round the READYNAS Admin screens, looking at all the possible settings and eventually found a "switch" for something that seemed to be related to HTTP and so looked interesting. The switch was Off so I clicked it On. When I went back to the Web Server configuration screen I was able to complete it and hopefully I had a working Web Server.

 

I copied my little demo and its folders and files across and tested it. It worked except it wouldn't display the image. I tried moving the image to the same folder as the html file and changing the html to match - still no luck.

 

I put this on one side and began to investigate how to implement php. There is free implementation for the READYNAS which installed very easily and worked straightway with a simple test. I then and started to try out my versions of Nico's scripts. I became confused - sometimes they worked and sometimes they didn't.

 

It took a while for the penny to drop - the READYNAS device runs on a Debian OS which turns out to be case sensitive for filenames ( i imagine a lot of people reading this will already know that!) and I was a bit casual in sometimes typing uppercase and sometimes not. Once I became totally disciplined in my use of upper and lower case everything worked perfectly.

 

I went back to my demo - sure enough, my image file naming was sloppy - .jpeg in the name of the actual image and .JPEG in the html script!

 

The Witty, powered by a USB phone charger, has been running for several days and happily updating log files on my READYNAS server.

 

I hope you've enjoyed reading this - it does have a happy ending!

 

PostScript

 

I for got to mention that if I use the hostname of the READYNAS in the ESP8266 sketch, it doesn't work, so I have to use the IP address instead. As this was being dynamically allocated by DHCP on my network router,  I've set it to a fixed value in the READYNAS Network settings, just in case the READYNAS  gets allocated a different IP address after a power cut or a router re-boot.

 

When I access the READYNAS Web Server from my PC, it's quite happy for me to use the READYNAS hostname.

  • Sign in to reply

Top Comments

  • Gough Lui
    Gough Lui over 7 years ago +2
    If you use a decent router, and the DNS is supplied by the router, you can set a static binding on the DNS server on the router to point a name to a fixed IP (e.g. "databox.lan -> 192.168.0.99"). Some…
  • ntewinkel
    ntewinkel over 7 years ago +1
    Hooray! Glad you got it all figured out. That upper/lowercase thing has bit me more than once too. I guess if I were more disciplined in only ever using lowercase names things would go a lot more smoothly…
  • neilk
    neilk over 7 years ago in reply to ntewinkel +1
    Hooray! indeed . Thanks again for letting me try things out on your server and for the access to your scripts - I've learned a lot from them, but there is still one thing I don't understand; maybe you…
  • neilk
    neilk over 7 years ago in reply to ntewinkel

    ntewinkel  wrote:

     

    We probably should have used POST there, because it is sending info to the server.

     

    Confirming that POST works fine and looks more "sensible" than GET image

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • neilk
    neilk over 7 years ago in reply to ntewinkel

    Hi Nico

     

    yes POST would have have been more intuitively obvious! That the browser automatically adds it explains it all.

     

    I'll try using POST instead of GET and see what happens - I assume the PHP scripts keep their GET(s)?

     

    I'm afraid the Tutorial doesn't cast any extra light on things for me - I'll keep on looking at examples that seem to do almost what I want and then tweak them!

     

    The bonjour stuff is a bit hard to follow - for now!

     

    I'll concentrate on getting the dual sensor system recording live to a single file and then try and resolve the parameter issues in the multi line graphs.

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ntewinkel
    ntewinkel over 7 years ago in reply to neilk

    Interesting... you can set up your ESP8266 with bonjour, using the "ESP8266mDNS library"

    https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266mDNS

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ntewinkel
    ntewinkel over 7 years ago in reply to neilk

    Hi Neil,

     

    The "GET" is an http method. When you go to URLs in your browser, the browser automatically adds it.

     

    I actually just copied from examples and followed the pattern. image

    And I now realize that's really the wrong keyword to use, as GET implies we are only retrieving information.

    We probably should have used POST there, because it is sending info to the server.

     

    I'm not an expert at those details, as you can tell image

     

    Here's a URL with more info:

    https://www.tutorialspoint.com/http/http_methods.htm

     

    Cheers,

    -Nico

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • neilk
    neilk over 7 years ago in reply to Gough Lui

    Thanks for that explanation, Gough; I think I understand it image seriously though it explains a lot.

     

    I had already looked at my router, but it doesn't seem to have the facility to bind a name to an IP address - at least, not one that I can see.

     

    There was a table linking names to IP addresses and the NAS fixed IP address (which I set) was linked to the NAS MAC address. There was a facility to let me change that, so I changed it to the NAS name  and then tried again in the ESP8266 sketch image image - it still failed, so I reverted back to the fixed IP address.

     

    Neil

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube