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.
Top Comments