Skip to content

Commit

Permalink
OK Blynk Cloud joined
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioJoshua committed Jan 22, 2023
1 parent 780b57b commit a440a05
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 4 deletions.
Binary file modified Photo_Board.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 97 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#endif


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

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;




//

#include "ACS712.h"
Expand Down Expand Up @@ -119,6 +136,8 @@ void doThisOnDisconnect(){
*/
setDebugMessageLevel(DBG_VERBOSE);
ArduinoCloud.printDebugInfo();

Blynk.begin(auth, ssid, pass);
}


Expand Down Expand Up @@ -155,8 +174,8 @@ void setup()
initArduinoMKR_Cloud();
}


void loop()
/// @brief func display for loop function
void dislayLoop()
{
lcd.clear();

Expand Down Expand Up @@ -226,6 +245,52 @@ void loop()
display.println(analogRead(A0));

display.display();

}

/// @brief update the value ACS712 on display also on Variable ArduinoCloud
void updateArduinoCloud()
{
Serial.println("updateArdinoCloud update Variable");
float f1 = ACS.mA_DC();
float f2 = ACS.getmVperAmp ();
float f3=ACS.getmAPerStep();
int f4=analogRead(A0);

mAmpere=f1;
ampere=f1;
a0Raw=f4;
mAxStep=f3;
mVxA=f2;
// Serial.println("updateArdinoCloud Ended update Variable");
}


/// @brief updating value local sensor to Blynk Cloud on loop func
void updateBlynkCloud()
{
Serial.println("updateBlynkCloud update Variable");
float f1 = ACS.mA_DC();
float f2 = ACS.getmVperAmp ();
float f3=ACS.getmAPerStep();
int f4=analogRead(A0);

/// @brief mAmpere with unit Ampere
Blynk.virtualWrite(V0, f1);
/// @brief mAmpere without unit
Blynk.virtualWrite(V1, f2);
/// @brief AnalogRaw Value
Blynk.virtualWrite(V2, f4);

}

void loop()
{
dislayLoop();
updateArduinoCloud();
updateBlynkCloud();


// delay(1000);
if (ArduinoCloud.connected())
Serial.println("it's joined to ArdinoCloud");
Expand All @@ -235,13 +300,14 @@ void loop()
}
#if defined(ARDUINO_ARCH_SAMD) || defined(ONLINE) || defined(ESP8266)
ArduinoCloud.update();
Blynk.run();
#endif
}


// -- END OF FILE --


#pragma region Evet ArduinoCloud
/*
Since Ampere is READ_WRITE variable, onAmpereChange() is
executed every time a new value is received from IoT Cloud.
Expand Down Expand Up @@ -280,4 +346,31 @@ void onMAxStepChange() {
*/
void onMVxAChange() {
// Add your code here to act upon MVxA change
}
}

#pragma endregion


#pragma region Blynk Events

BLYNK_CONNECTED()
{
Serial.println("Blynk Connected event: nitialize Vpin Value ");
// Blynk.syncVirtual(V1); // will cause BLYNK_WRITE(V0) to be executed
// Blynk.syncVirtual(V2); // will cause BLYNK_WRITE(V0) to be executed

}


// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin V1
BLYNK_WRITE(V1)
{
int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable

// process received value
}



#pragma endregion

0 comments on commit a440a05

Please sign in to comment.