WEEK 6 (FYP 2)

 Friday, August 28, 2020


WEEK 6 FYP 2 ( WRITE PROGRAMMING FOR CONTROLLER)


Objectives:

1) To write the programming coding for the project.

2) To make sure the controller function very well.


Methodology:

1) Study about the coding that can be burn into the controller.

2) Draft the coding based on what the purpose need by the project.

3) The coding procedure using arduino IDE.


Result:

Below is the draft for coding:

 #define BLYNK_PRINT Serial // Comment this out to disable prints and save space

#include <BlynkSimpleEsp8266.h>

#include <SoftwareSerial.h>

#include <ESP8266WiFi.h>   

#include <Wire.h>

#include <Adafruit_INA219.h>


char auth[] = "gQIcbxsPxscjseDLZwecdBjJ6n1fTIuz";

char ssid[] = "zakwan_2.4G@unifi";

char pass[] = "0187744463";



Adafruit_INA219 ina219;

 int analogInput = A0;

  float correctionfactor = 0; 

  float vout = 0.0;

  float vin = 0.0;

    float R1 = 47000; 

  float R2 = 6800;

  int value = 0;

 



void setup() {

  Serial.begin(9600);

  Blynk.begin(auth, ssid, pass);

  ina219.begin();

}


void loop() {

  float shuntvoltage = 0;

  float busvoltage = 0;

  float current_mA = 0;

  float loadvoltage = 0;

  float energy = 0;



  shuntvoltage = ina219.getShuntVoltage_mV();

  busvoltage = ina219.getBusVoltage_V();

  current_mA = ina219.getCurrent_mA();

  loadvoltage = busvoltage + (shuntvoltage / 100);

  energy = loadvoltage * current_mA;


  value = analogRead(analogInput);

  vout = (value * 5.0) / 1023.0;

  vin = vout / (R2/(R1+R2)) * 0.66;

  vin = vin - correctionfactor;

  

  Serial.println(vin,4);

  



  Serial.print("Voltage:       "); Serial.print(loadvoltage); Serial.println(" V");

  Serial.print("Current:       "); Serial.print(current_mA); Serial.println(" mA");

  Serial.print("Power  :       "); Serial.print(energy); Serial.println(" W");

  Serial.println("");

 



    Blynk.virtualWrite(V6, loadvoltage);

    Blynk.virtualWrite(V7, current_mA);

    Blynk.virtualWrite(V8, energy);


    Blynk.run();

 

  delay(1000);

}


Analysis and Discussion:

After all the study and asked another lecturer about the programming coding, i was successfully complete the coding for my project. It was very grateful because i'm now in the right path to finish my project.


Conclusion:

As the conclusion, the programming part was done and i would like to thanks to my fellow lecturers that help me alot to troubleshoot the coding.

Comments