/*
 * trimite B de la senzor Hall intern
 * afiseaza local pe Oled 
  */

#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#include <SimpleTimer.h>
SimpleTimer timer;

char auth[] = "e5beac0d31f4433da82dc64b99a03b39"; 
char ssid[] = "UPCF4821BC";
char pass[] = "Gherla1956";

#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#define OLED_ADDR   0x3C
Adafruit_SSD1306 display(-1);

void setup() {
  Serial.begin(115200);
  SPI.begin();
    Blynk.begin(auth, ssid, pass);
    timer.setInterval(1000L, sendUptime);

  display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("ESP32 Hall Blynk");
  display.display();
  delay(1000); 
}

void sendUptime(){
   float val = hallRead();
    Serial.print("Hall=");
    Serial.println(val);
    
  display.clearDisplay();
  display.setTextSize(2);
  display.setTextColor(WHITE);//trebuie
  display.setCursor(0,0);
  display.print("B=");
  display.println(val);
  display.display();
    delay(20);
    
   Blynk.virtualWrite(12, "  Hall= ");
   Blynk.virtualWrite(12, val);  
     } 


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