The final step of our project was to connect everything to our NodeMCU esp8266. As the Node is a board itself, we attached the flow rate sensor, LCD and LEDs to its D pins and shared the power between the Arduino and the Node. We then changed our code to correspond to the amendments we made.
Once connected, we had the problem that the flow rate sensor was not responding and not giving any readings. We knew this because when opening the serial monitor there were no readings being taken. After analysing the new setup, we narrowed down the possible reasons for this below:
- LCD sucking power from the Flow Rate Sensor
- Need external power
- Pins on the NodeMCU esp8266 doesn’t support interrupt pins
- Code was wrong
Firstly, we took the LCD out of the setup and ran the code again which proved not to be the problem. Next was applying an external power supply which again made no difference.
On the Arduino, the interrupt pins are mapped to pins 2 and 3 whereas the Node after some further research we found out that it didn’t specifically have any interrupt pin but it was the code relating to the interrupt that had to be changed. So because of this we needed to change the syntax to allow the flow rate sensor and the esp8266 to communicate with each other. As you can see below, the change was very simple but without it it would never work. We found the new code by looking up the syntax for the esp8266 interrupt.
Old Line of Code
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
New Line of Code
attachInterrupt(digitalPinToInterrupt(sensorPin), pulseCounter, FALLING);
Sending Data to Thinger.io
Sending data to thinger.io is a fairly simple process, Thinger.io supply lines of code published on their website which allowed us to define the sensor we were using and the data we wanted to transmit on the dashboard. Below is the line of code we used to transmit our data.
thing[“variable”] >> outputValue(myVar);
thing[“sensorPin”] >> outputValue(totalLitres);
To set up a dashboard widget, it uses the “sensorPin” as what its reading and the “totalLitres” as whats it displaying.
Below is a video showing our dashboard in use:
Although we did want to display more than just the total litres used, we were unable to because each widget uses one sensor and as all the data comes from the flow rate sensor we couldn’t display more than one set of data. But using this dashboard shows the potential it has and is a great way for the user to check how much water is being used when they are away from the LCD.
Link to the dashboard: