The concept of my project involves collecting rain data using a tipping bucket rain gauge. This rain gauge is connected to an Arduino UNO, and the Arduino is linked to a NodeMCU ESP8266 for Wi-Fi connectivity, allowing me to monitor the data using the Blynk platform. I’ve included the code for both the Arduino and ESP8266 below.
|Arduino
#include <Arduino.h>
const byte interruptPin = 3;
const int interval = 100;
volatile unsigned long tiptime = millis();
void setup() {
Serial.begin(9600);
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), count, FALLING);
}
void loop() {
delay(100);
}
void count() {
unsigned long curtime = millis();
if ((curtime - tiptime) < interval) {
return;
}
unsigned long tipcount = curtime - tiptime;
tiptime = curtime;
double rainrate = 914400.0 / tipcount;
Serial.print("Cup tip: ");
Serial.print(tipcount);
Serial.print("ms");
Serial.print("\t"); // Separate values with a tab
Serial.print("Rain rate: ");
Serial.print(rainrate);
Serial.println("mm/hr");
}
NodeMCU ESP8266
#define BLYNK_TEMPLATE_ID "TMPL63xopzArS"
#define BLYNK_TEMPLATE_NAME "Project Attempt 1"
#define BLYNK_AUTH_TOKEN "vkTYm8Xp2qDCOoxApWcxR8WPcR76F9Ua"
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SPI.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
volatile unsigned long tiptime = millis(); //
const int interval = 100;//
char auth[] = "vkTYm8Xp2qDCOoxApWcxR8WPcR76F9Ua";//Enter the Auth code which was send by Blink
char ssid[] = "IfUrNotInMyBlacklistUMayConnect";
char pass[] = "001010011";
void setup()
{
Serial.begin(9600); // See the connection status in Serial Monitor
Blynk.begin(auth, ssid, pass);
}
void loop()
{
char buffer[20]="";
if(Serial.available()>0){
// char data=Serial.read();
Serial.readBytesUntil('\n', buffer, 20);
Serial.println(buffer);
}
Blynk.run(); // Initiates Blynk
}
void count()
{
unsigned long curtime = millis();//
if ((curtime - tiptime) < interval)
{
return;//
}
unsigned long tipcount = curtime - tiptime;//
tiptime = curtime;//
double rainrate = 914400.0 / tipcount;//
Blynk.virtualWrite(V0, tipcount); // Send cup tip data to V0 (SuperChart)
Blynk.virtualWrite(V1, rainrate); // Send rain rate data to V1 (SuperChart)
}
The primary objective of my project is to display the cup tips and rain rate every time data is interrupted by the tipping bucket sensor. The ESP8266 is used to establish a wireless connection for Blynk so that the data can also be visualized within the Blynk app. However, I’ve encountered issues as the system isn’t working as expected. It’s worth noting that the data from the Arduino successfully transfers to the ESP8266, but the challenge lies in displaying this data on the Blynk platform, which is currently not functioning as intended I’m seeking guidance on how to resolve this problem. What steps should I take to troubleshoot and resolve the issue?