If I knew php, it could probably be done dynamically using php. This script is run every minute using a cron job on the Pi. I wanted to be able to view the current data on a web page, so I wrote a short Python script to generate an html page from the most recent data. A short php script is used (a first for me) to log the data from the incoming http “GET” commands from each of the Wemos boards. The Raspberry Pi is running a lighttpd web server and php5. Every minute, each Wemos reads its sensor and reports the value, via WiFi to a Raspberry Pi on the local network. Each one has a TMP-36 sensor being read by the analog port. How Does It Work?īefore I go any further with the details and procedures, here’s an overview of how the whole system works. The temperature sensor part was easy for me to change, but I used the rest of the method, which was in turn based on parts of the Wemos examples. Someone had done a similar thing with the Wemos, but using different temperature sensors (DS18B20). In this case I found exactly what I was looking for here. It’s always good to do this so you can crib ideas and sometimes even borrow some bits of code. So once I’d proved the concept and that WiFi was working, I did a quick google to see if anyone else had already done the temperature sensor network before. This is why I decided to use the Pi as a server and have the Wemos ‘nodes’ report in to it. That was pretty easy, but the connection was not persistent and kept dropping out. Having done that, I modified the sketch to read the TMP-36 and report the results when accessed. You use the Arduino IDE’s serial monitor to get the Wemos’s ip address, then and toggle the LED on and off. It enables you to type a URL into your browser to switch the onboard LED on and off. The only modification you have to make is to add your WiFi login credentials. The first sketch I tried was the WiFiWebserver sketch. You can even update them wirelessly, although I haven’t tried that yet (it screams “security hazard” to me, but would be OK if done well). If you are familiar with the Arduino IDE, these boards are a breeze to use. So a little ‘playtime’ was very welcome.) (I’ve been heavily into a development cycle on a top-secret new project that I hope to be able to announce within the next few weeks. They arrived recently and I took a little time to have a play. Has an ADC input (I love my TMP-36 sensors).On inspection, it ticked all my boxes for this project. A few weeks ago he showed me the Wemos D1 mini. Albert has a useful hobby of trawling ebay for bargain-basement electronics. Albert Hickey, a friend of mine, who also runs the Egham Jam put me onto these when he did his buttonflash game. I’d originally planned to do it with a RasPiO Duino or Arduino nano and inexpensive NRF24L01 radio boards. It’s not something I really need, but something nice to have. For a long time now I’ve wanted wireless temperature sensors scattered around the house and garden reporting their temperatures regularly to a central server.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |