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
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