BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

No value in Blynk apps

I had followed your every detail instruction and boom its worked! Thank you very much for your help and guide sir. Iam really appreciate it :smile:

1 Like

Another question sir, I already used the A0 pin on my nodeMCU for the voltage sensor, can i use digital pin for my current sensor?

Presumably you’re using a voltage divider to measure the battery voltage.
How were you planning on measuring the current?

Pete.

Yes, I am using voltage divider to measure the battery voltage.
For the current, I am planning to use ACS712 current sensor as picture below

image

The ACS712 provides an analogue output, so can’t be used with a digital pin.
You’d need to use a multiplexer to give more analogue pins.

The ACS712 has a maximum current rating of 30A (assuming you buy the correct module) and all of the current being drawn has to go via the sensor. If this is for a leisure battery then it could be okay (maybe).

Pete.

1 Like

Multiplexer for example like ADS1115 (in the picture below)? Will it need extra coding to pair it with nodeMCU?

image

I was thinking more like the 74HC4051 Multiplexer, which is in effect an electronically controlled selector switch that connects your existing analogue to one of 8 (in this case) analogue inputs, rather than an analogue to digital converter like the ADS1115 - although either would work.

Both would requite additional coding, but in different ways.

Another option is to use an ESP32 board, but once again, coding changes would be needed.

Are you 100% sure about being able to pass all the current you want to measure through the ACS712?

Pete.

2 Likes

Better buy LoLin ESP32 with 18 ADC for only 5$ ?

1 Like

well i am only measuring current about 2A max so maybe the ACS712 will able to do it. OR maybe I just buy a sensor that can detect both current and voltage?

But I already bought the ESP8266 and the ACS712 sensor, wanna make full use of them

Unfortunately both your voltage and current sensing methods each require an analog pin, of which an ESP8266 only has one. So if you want to make full use, then you need to either add in a ADC multiplexor, change to an ESP32 with multiple ADC ports or use a different sensor like the INA219 that runs on i2C and will read both voltage and current as well as being much more accurate than the ACS712.

I have used both for similar monitoring of a battery and charge… and a bunch of other stuff…

2 Likes

Nice project! Is that INA219 sensor you using in your project doesnt required analogpin and can detect both current, voltage and even power? It is suitable to detect 15V max and 2A max rating?

It uses the i2C communication bus.

Yes, no problem. 0 to 26 VDC and the current is read via a shunt so not sure the max, but probably whatever the primary contacts are good for. I think I have seen as high as 4-5A on my solar charger.

https://www.google.com/search?q=ina219+arduino

2 Likes

Great! I’ve decided to give INA219 a try and already ordered it from my supplier

It seem I can find any connection diagram for my ESP8266 nodeMCU to connect with INA219. I try connecting the SCL and SDA pin of the INA219 into my D1&D2 pin of my nodeMCU but the INA219 become hot and I afraid I might have burn it. Can help me with my connection?

here is another Forum topic that might help…

I have following all the guide that you have given to me but I got this whether there are load or no load connected to the Vin+ and Vin- of the INA219.

These are my latest code

#include <Wire.h>
#include <Adafruit_INA219.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

Adafruit_INA219 sensor219;

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "-";
 
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "-";
char pass[] = "-";


#define DHTPIN 0          // D3
 
// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11

 
DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;
 
float setpoint = 0;
bool relayoff = true;
const int relayPin = 12;  // D6;

BLYNK_WRITE(V0)  // slider widget
{
  setpoint = param.asFloat();
  relayoff = true;  
}

int analogInput = A0;
float vout = 0.0;
float vin = 0.0;
float R1 = 30000.0; //  
float R2 = 7500.0; // 
int value = 0;  

  float busVoltage = 0;
  float current = 0; // Measure in milli amps
  float power = 0;
  
void sendSensor()
{

  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
 
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, t);
  Blynk.virtualWrite(V6, h);
  if((setpoint < t) && (relayoff == true))
  { 
    digitalWrite(relayPin, 0); // assuming relay is active HIGH
    relayoff = true;
  }  
  if((setpoint > t) && (relayoff == true))
  { 
    digitalWrite(relayPin, 1); // assuming relay is active HIGH
    relayoff = true;
  }

   // read the value at analog input
  value = analogRead(analogInput);
  vout = (value * 3.3) / 1024.0;
  vin = vout / (R2/(R1+R2));         
  Serial.print("INPUT V= ");
  Serial.println(vin,2);
  delay(500);
  
  Blynk.virtualWrite(V1, vin);

  busVoltage = sensor219.getBusVoltage_V();
  current = sensor219.getCurrent_mA();
  power = busVoltage * (current/1000); // Calculate the Power
  
  
  Serial.print("Bus Voltage:   "); 
  Serial.print(busVoltage); 
  Serial.println(" V");  
  
  Serial.print("Current:       "); 
  Serial.print(current); 
  Serial.println(" mA");
  
  Serial.print("Power:         "); 
  Serial.print(power); 
  Serial.println(" W");  
  
  Serial.println("");  

  delay(2000);

  Blynk.virtualWrite(V2, busVoltage);
}


void setup()
{
   Wire.begin(4,5); //SDA, SCL
  
   Serial.begin(9600);    
   sensor219.begin();
   pinMode(analogInput, INPUT);
   Serial.print("DC VOLTMETER");
   Serial.begin(9600);
   Blynk.begin(auth, ssid, pass);
   dht.begin();
   pinMode(relayPin, OUTPUT);

  // Setup a function to be called every second
  timer.setInterval(5000L, sendSensor);
}

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

I connected the SCL to D1 and SDA to D2

Hello, I have problem regarding with INA219 sensor. I have tried the sensor on my Arduino Uno and it work. But when I connect the INA219 to my NodeMCU, its not working. I had connected the SCL to D1 and SDA to D2 from INA219 to NodeMCU. I am suspecting that the I2C pin on my NodeMCU is not active. Iam using below code.

include <Wire.h>
#include <Adafruit_INA219.h>

Adafruit_INA219 ina219;


void setup(void) 
{
  Wire.begin(4,5);
  Serial.begin(115200);
  while (!Serial) {
      // will pause Zero, Leonardo, etc until serial console opens
      delay(1);
  }

  uint32_t currentFrequency;
    
  Serial.println("Hello!");
  
  // Initialize the INA219.
  // By default the initialization will use the largest range (32V, 2A).  However
  // you can call a setCalibration function to change this range (see comments).
  ina219.begin();
  // To use a slightly lower 32V, 1A range (higher precision on amps):
  //ina219.setCalibration_32V_1A();
  // Or to use a lower 16V, 400mA range (higher precision on volts and amps):
  //ina219.setCalibration_16V_400mA();

  Serial.println("Measuring voltage and current with INA219 ...");
}

void loop(void) 
{
  float shuntvoltage = 0;
  float busvoltage = 0;
  float current_mA = 0;
  float loadvoltage = 0;
  float power_mW = 0;

  shuntvoltage = ina219.getShuntVoltage_mV();
  busvoltage = ina219.getBusVoltage_V();
  current_mA = ina219.getCurrent_mA();
  power_mW = ina219.getPower_mW();
  loadvoltage = busvoltage + (shuntvoltage / 1000);
  
  Serial.print("Bus Voltage:   "); Serial.print(busvoltage); Serial.println(" V");
  Serial.print("Shunt Voltage: "); Serial.print(shuntvoltage); Serial.println(" mV");
  Serial.print("Load Voltage:  "); Serial.print(loadvoltage); Serial.println(" V");
  Serial.print("Current:       "); Serial.print(current_mA); Serial.println(" mA");
  Serial.print("Power:         "); Serial.print(power_mW); Serial.println(" mW");
  Serial.println("");

  delay(2000);
}

This what Iam getting on the NodeMCU
image

I had figure out the problem within my project. The problem was my NodeMCU i2c pin, it work fine after i switch the NodeMCU with new one. The problem is the voltage showing is not correct with my battery voltage which 12V. How do I fix this