Sending Data to Thinger.io

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.

 

Screen Shot 2018-04-17 at 18.28.59.png

 

Troubleshooting

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.

Code Supplied

thing[“variable”] >> outputValue(myVar);

Our Code

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:

https://console.thinger.io/#/dashboard/SmartWaterSensor?authorization=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJEYXNoYm9hcmRfU21hcnRXYXRlclNlbnNvciIsInVzciI6IkphY2sxYmF0ZXMifQ.qVCIr4JTv0HmqcpDLZt-Sj1E_nK9JB2WbQ2sA7VLgHc

Full code:

https://create.arduino.cc/editor/jackrichardbates/fd7d324a-80a5-4401-8ed4-c0c36de89b75/preview?embed

 

 

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s