Hi Arduino community,
I am quite new here and started a small project with LCD display and INA219 current sensor to measure the relative efficiency of two different LEDs using a Si-photodiode.
up to now, each part of the project works properly. However, a strange thing arises when I put all the parts together and display the sensor current in the LCD display. As shown in following, when I connected the current sensor and the LCD display to the Arduino, the display did not show properly the current as shown in the graph. (note that if I remove the current sensor from the arduino, the display works fine as expected!).
I searched for a while relevant threads in the Forum, but I could not find one that could help me. Any help or instruction is really welcomed.
here is also a part of the code for clarity:
<
#include <Adafruit_INA219.h>
#include <LiquidCrystal.h>
Adafruit_INA219 ina219;
// Set green LED
int buttonPinG = 10;
int ledPinG = 9;
int buttonReadG;
// set blue LED
int buttonPinB = 8;
int ledPinB = 7;
int buttonReadB;
int Oldstate = 0; // green LED button
int Oldstateb =0; // blue LED button
int state = 0;
// LCD settings
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
uint32_t currentFrequency;
void setup() {
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Efficiency:");
pinMode(ledPinG, OUTPUT);
pinMode(buttonPinG,INPUT);
pinMode(ledPinB, OUTPUT);
pinMode(buttonPinB,INPUT);
// ina219
ina219.begin();
Serial.begin(9600);
}
void loop() {
float busvoltage = ina219.getBusVoltage_V();
float shuntvoltage = ina219.getShuntVoltage_mV();
float current_mA = ina219.getCurrent_mA();
float loadvoltage = busvoltage + (shuntvoltage /1000);
buttonReadG = digitalRead(buttonPinG);
buttonReadB = digitalRead(buttonPinB);
lcd.setCursor(0,1);
lcd.print(current_mA);
Serial.print("Current: "); Serial.print(current_mA); Serial.println(" mA");
delay(500);
}
thanks in advance.