No/Invalid Outputs

• Arduino UNO + HC-SR04 + TMP36.
• Android 9
• Blynk server
• Blynk version 0.6.1

I have some knowledge about Blynk and Arduino. I followed a project made by Gabriel Jomar, link: https://community.createlabz.com/knowledgebase/water-level-and-weight-monitoring-using-waterproof-ultrasonic-sensor-and-hx711-load-cell-with-blynk-app/

I modified some of his codings and I also don’t have the same hardware as his, I use HC-SR04 instead of JSN-SR04T. I need to help with this urgently, I can’t figure out the problem and I am also competing for my school.


// Water distance display is at Virtual Pin 2
// Depth display is at Virtual Pin 0
// Litre display is at Virtual Pin 1
// TMP36 sensor is at Virtual Pin 4
// SuperChart with water and temperature data is at V3 and V5

#include <NewPing.h>

#define BLYNK_PRINT DebugSerial
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX

#include <BlynkSimpleStream.h>
char auth[] = "xxxxx";
BlynkTimer timer;

// *****************************************************
#define PI 3.1415926535897932384626433832795
const int DIAM = 10.4;
const int DEPTH = 17;
const unsigned int Period = 1000;
const int Area1 = PI * ((DIAM / 2) * (DIAM / 2));
// *****************************************************
#define TRIG 4
#define ECHO 5
#define WPUMP 13
const int MAX_DIST = 16;
const int HOTTT = 28;
int LITRE, DEPT, DIST;
// *****************************************************
NewPing sonar(TRIG, ECHO, MAX_DIST);
// *****************************************************
int sensorVal = analogRead(A0);
float volt = (sensorVal/1024.0) * 5;
int tempC = (volt - 0.5) * 100;

void reading(){
 DIST = sonar.ping_cm();
  if (DIST >= DEPTH || DIST == 0) DIST = DEPTH;
    DEPT = DEPTH - DIST;
    LITRE = (Area1 * DEPT)/1000;
    delay(50);

    Blynk.virtualWrite(V0, DEPT);
    Blynk.virtualWrite(V1, LITRE);
    Blynk.virtualWrite(V2, DIST);
    temp();
}

void temp()
{
  Blynk.virtualWrite(V4, tempC);
}

void superChart()
{
  Blynk.virtualWrite(V3, DIST);
  Blynk.virtualWrite(V5, tempC);
}

void setup()
{
  // IF-ELSE
  if (HOTTT >= tempC && LITRE <= 3){
    digitalWrite(WPUMP, LOW); 
  }
  else{
    digitalWrite(WPUMP, HIGH);
  }
  
  // Debug console
  DebugSerial.begin(9600);

  // Blynk will work through Serial
  // Do not read or write this serial manually in your sketch
  Serial.begin(9600);
  Blynk.begin(Serial, auth);
  
  pinMode(12, OUTPUT);
  digitalWrite(12, HIGH);

  timer.setInterval(Period, reading); 
  timer.setInterval(1000L, superChart);
}

void loop()
{
  Blynk.run();
  timer.run();
}

Don’t you think it would make sense to share some information about what is and isn’t working for you?

  • Does the code compile?
  • Does it connect to Blynk?
  • Are you getting any readings in Blynk?
  • Is your pump activating (you seem to have an issue with WPUMP [pin 13] and a pinMode statement for pin 12]?
  • What does your serial monitor show?

Pete.