Arduino, ESP8266, HC-12 wireless, and WEMOS based Internet of Things projects.
Arduino graphical electric fence pulse monitor. Bar graph water meter display.
IOT
Arduino and ESP8266 projects that connect with the Internet of Things. Including HC-12 wireless serial projects.
UPDATES:   17  Aug 2017   Arduino examples of communicating with a number of free IOT dashboards
                      22 Aug 2017    Arduino water meter monitor, displaying usage in 6 minute blocks
                      27 Aug 2017    Arduino sends data to your website database, and bring back to your custom Excel dashboard
                                               RSSI monitor for ESP8266 Wemos D1
                      08 Sep 2017    Arduino electric fence monitor with graphical display, Standalone, and HC-12 based wireless remote versions
Using Cayeene IOT dashboard to remotely display  flow sensor data at selected intervals via the ESP8266 based WEMOS D1.

Cayeene ( https://mydevices.com/) is a free, simple to use, and well documented way to enter the world of remote monitoring and control available on the "IOT" for those using the Arduino IDE.
All the programming difficulty is removed by  available libraries, and the only technical info you need is your Wifi SSID and password! The file included a normal Arduino "ino", which flawlessly programs the WEMOS D1.
  My only frustration is that, currently, the Cayenne dashboard has a limited selection of display "widgets". A larger selection is in the pipeline. In particular, there was no tag for "flow" so I had to label one gauge "volts" whilst displaying flow! The coming Text Box "widget" will be very useful.

The WEMOS D1 is not specifically listed on the Cayeene list of supported hardware, but the work-around is to choose the Arduino MEGA and add an ESP8266. Pay attention to the attached code, because the choice of "includes" needed to make the WEMOS D1 talk to the Cayenne dashboard is not as in per official Cayenne examples. My code includes some unnecessary features that were included so as to test Cayenne dashboard features, because this project was a first for me. The code contains comments on the correct use of 5v Hall Effect flow sensor and "Tiny RTC I2C Module" with the 3.3v WEMOS D1.
Project: Display water flow-meter data on Cayenne dashboard, sent via wifi connection from WEMOS D1
Above, the Cayenne Dashboard is plain but effective,  and simple to build. Communication is two way, so although the monitoring project didn't really need them, I added  features to just test the system. Gets an "A" in all areas I utilised, but I await the extra widgets now being prepared.
Above is the complete project designed to test the ability of the Cayenne dashboard to communicate with the WEMOS D1 The small breadboard contains a voltage divider, needed because the flow meter requires a 5v supply, and the WEMOS can only handle 3.3v inputs
The code provided for download is fully commented, and should answer all questions needed to replicate this build. With the Cayenne system, you must have the software loaded, with the allocated token added, and communication established, before you can build your dashboard. All too easy.
Using thinger.io dashboard to remotely display  flow sensor data at selected intervals via the ESP8266 based WEMOS D1. (same flow-meter setup as illustrated above)

thinger.io ( https://thinger.io/) is  free (with restrictions), easy to use, and a well documented way to enter the world of remote monitoring and control available on the "IOT" for those using the Arduino IDE.

The code for download is adapted from the Cayenne project code above, but modified to suit the methods used by thinger.io. You need to use C++11 Lambda functions, which are well explained in the Arduino documentation (http://docs.thinger.io/arduino/)
Two code versions are for download:-
This code is for a Dashboard setup that initiates requests data from the WEMOS D1 at intervals set when you set up each widget.

This download is for a dashboard set to receive data to a "bucket" as pushed at regular intervals by your WEMOS D1
In summary, coding is simple, and dashboard was easy to setup, the wigets being intuitive to use. The restrictions  to the free version in no way restrict your ability to fully explore this platform. Another "A"!


Project: Display water flow-meter data on Thinger.io dashboard, sent via wifi connection from WEMOS D1
Left. The thinger.io dashboard allows for both display and control, and is easily built.
Project: Display sample data on Freeboard dashboard, sent via wifi connection from
WEMOS D1 to dweet.io and from there to Freeboard.
A method of displaying your data and sending alerts. Simple, and will suit some projects.
Data is first sent to dweet.io (https://dweet.io/), then displayed on a Freeboard dashboard (https://freeboard.io/). This transfer is painless because dweet is linked already to Freeboard.
The free service is limited and public, but sufficient to let you explore the potential.
JSON formatted strings are needed, but easy to do. Code (use download button, left) sends simple random data, at 30 second intervals as displayed below.
Left. Simple Freeboard dashboard, data sent from WEMOS D1
Project: Display sample data on Thingsboard dashboard, sent via wifi connection from WEMOS D1
Having successfully tested other free IOT dashboards, I turned my attention to the thingsboard.io  platform. (https://thingsboard.io/) This is highly developed, and of professional quality in every way, with features way beyond my simple needs. Documentation is excellent, and your entry is clearly guided, step by step. If you go wrong following these instructions, take a deep breath and start again!
After an afternoon's frustration, no doubt caused by my inexperience, I only succeeded in getting my data to the dashboard, but got messages indicating that the wigits on the example dash had probably been removed, despite being evident. On edit, they recognised the data sending device, but needed Time series keys, which should not be the case in the event of logins using "live demo server". Here I have retreated in defeat until I can gain a better understanding of what I have done wrong.
Most importantly, the code is proven. You can easily get WEMOS D1 to work with this system.
Despite my inexperience, thingsboard.io gets an "A+" all round.
Left: Thingsboard dashboard  gets my data, but  the other four widgets cannot find it.
Project: Water meter monitor with local display
A friend with a large garden and a number of discrete watering circuits was unhappy with timers that failed, and the corresponding need to check each line daily.
Rather than a sensor transmitting from each tap, the electronic timers were each given their own time block, and a single flow-meter was inserted just downstream of the service meter.
A single point check was all it took to verify every circuit had "fired"
Metering was in six minute blocks, from 6am to 10pm, and a single push button toggled display back for seven days, so "this day one week ago" could be compared"
Small board is RTC. Flow sensor is Chinese Hall Effect type, and magnetic pick up is external to water flow.
Above. Water flow meter uses a hall effect sensor
installed in line at exuit of service meter.
Local display gives consumption in 6 minute blocks, and can bring up a full week's data.
Project:  Display sample data on IotTweet dashboard, sent via wifi connection from WEMOS D1
The IotTweet (https://www.iottweet.com/index.php) dashboard is simple, easy to use and free.
  The attached software download shows you how to use the WEMOS D1 to send to, and receive data from, a very easy to set up dashboard. The dashboard can display text messages sent from your device. A quick, neat solution for simple monitor and control applications with a tiny learning curve. A neat feature is the ability to easily examine the incoming data stream.
Project:  RSSI indicator for ESP8266 WEMOS D1 with OLED display and "fiddling" the ESP8266 antenna.
This SSID and RSSI display is based on ESP8266 library code, so in that regard is nothing original. Its use is important to do two things:-.
Firstly, the  2.4 GHz signal from your access point varies in strength greatly depending on location and object reflections, including reflections from moving objects.
So, to get around this, proprietary products will use "dual diversity". In the simplest form, this means two antennas, with the unit drawing from the antenna with the strongest signal. Because your ESP8266  has one pcb antenna, use this software to locate a position of strongest signal with least disturbances.

Secondly, even if you have no socket for attaching a gain antenna, you can fiddle, and may be able to to improve on the pcb antenna.
Cut two pieces of copper wire, one at 1/4 wave, and one at 5/8 wave (for 2400 MHz)
With plastic tweezers slide one end of the 1/4 wave piece along the pcb antenna, watching the RSSI. If you can find a position that improves your average gain by 3 dB (e.g, from -66 to -63 dB) then you have doubled your signal strength. Solder it in position quickly, with a tiny blob of solder. If no improvement with the 1/4 wave piece, try the 5/8 wave piece.
Remember, even if you can attach an external gain antenna, a lot are of dubious quality, and you should check your RSSI
Project:  Sending data via WEMOS D1 ESP8266 to WEB DATABASE to EXCEL DASHBOARD
After finding how easy it is to use the the free IOT Dashboards on Dweet, Thingsboard, IOTTweet, and Cayeene, I found equally simple to send data to the cloud with Excel. This  project demonstrates, and gives example code, showing how to post data to your website database, and how to get that back to Excel without using ODBC. The advantage in using Excel is that you have immense facility within Excel to build custom dashboards that exactly meet your needs, which I found was the feature lacking in the free IOT dashboards.
  In this project, a WEMOS D1 (or other ESP8266 device) connects to your web database, and uploads data at fixed intervals.To achieve this, the WEMOS sends a POST request containing data, to the PHP server side script, which does the business with your database.

  When requested  Excel sends a  POST request to another PHP script which sends our data back to Excel via an “echo”. Normally you would use Excel’s ODBC facility to make this a painless task, but my “budget” website sits on a Unix server which does not allow this. Hence, we have to use server side scripts, and do a little more work in Excel VBA  to format the HTML stream that it receives. The bonus is that this method opens the possibility of easily feeding coded commands back to the ESP8266 (Filling the "echo" response back from the PHP scrip when data is uploaded, with a command string uploaded previously to the database per an Excel POST request.)

The coding is mySQL, not mySQLi as expected these days. I’m sure you can convert it.
Download file contains Excel, PHP, and Arduino files.
The benefit of using Excel instead of the publically available IOT dashboards is the level of control you have in formatting the display.
Flow sensor mounted in service line
Project:  Arduino  Electric Fence Monitor with Graphical Display
Serious farmers need a constant monitoring system for their electric fences. The liabilities brought about by an animal loose on a highway can be horrendous. And, for many, electric fencing is not only about keeping animals in! Fences often typically keep predators out, and cannot be off for even a short time. In Australia, where packs of feral dogs infest Crown Land, the cost of fence failure for those farming the public / private interface country has many times resulted in the destruction of a livelihood in a single night.

This is my checklist for an enterprise whose survival relies on  fence integrity.
  1. Continual monitoring, at least at the homestead.
  2. Audible warning of common faults.
  3. Monitoring that allows more than fence volts or load. eg., “distance to fault”
  4. As maintenance free as possible.
  5. No HV at the reporting end.
  6.  Holding info re. a good waveform for the individual fence for visual /mathematical
       comparison.
  7. Useful information. Graphical display,  Joules delivered and reflected, line voltage, etc
  8. Cost  minimal ( Utilising the home PC rather than a separate monitor)
  9. (Advanced) Monitor or alert  per SMS gateway to phone.

File packages are attached to allow you to replicate three versions I have built:-
      1.  A standalone, hand held display.
      2. An Arduino based field located sender, to an Arduino based house display, using   
         HC-12 wireless units.
      3.  An Arduino based field located sender, reporting to Excel graphical display via an USB
           433 MHz  wireless dongle
All are complete projects, tested and working on the bench, meeting most portions of the “wish list” above. Circuit and other details are in the accompanying PDF file. The problem of sending large data sets (300 points) was solved by  breaking the set into 30 point structures and using Bill Porter's "EasyTransfer" library, after increasing the Arduino default buffer size to 256 bytes. A project now being moved to the Due platform for  faster adc reads, to allow a better look at the rising edge of the pulse with associated diagnostic opportunities.
Upper left, RX unit.   Right, TX unit with HC-12, level shifter, and comparator (trigger) on a UNO proto- board, sitting on Arduino Mega. Pulse shown is from a  small generator that emulates the fence pulse.

Below, Excel dashboard. The large setup portion was to allow developmental settings, but the only change you will make is to add the port number assigned by 'Windows to the HC-12 USB wireless dongle.