Hi there,
I’m sorry to bother you all with probably stupid questions, but I don’t find a solid starting point.
I have been using Arduino for a few months, and I am currently using it for some projects, but i’m trying tu use it combined with blynk… and here I got some problems, probably because I still don’t have a solid basis for writing codes.
The problem is not communicating with Blynk, I succesfully used esp8266 for the easiest projects like turning on a led … etc and it works fine, but I don’t know how to carry, for example, this sketch that I wrote (and it’s working on Arduino uno stand alone) on arduino combined with ESP8266 and blynk.
Given that I have to keep clean void loop () function, how could I make what I written in it working?
I wrote this sketch to monitor the event of water losses on my irrigation system, and it consist in a water flow connected to the water tap. If I would, for example, display what I see on my LCD on the LCD on Blynk… where do I have to wrote my code?
this is my sketch I use with arduino Uno, water flow and LCD
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
int X;
int Y;
float TIME = 0;
float FREQUENCY = 0;
float WATER = 0;
float TOTAL = 0;
float LS = 0;
const int input = A0;
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(input, INPUT);
}
void loop()
{
X = pulseIn(input, HIGH);
Y = pulseIn(input, LOW);
TIME = X + Y;
FREQUENCY = 1000000 / TIME;
WATER = FREQUENCY / 10.4;
LS = WATER / 60;
if (FREQUENCY >= 0)
{
if (isinf(FREQUENCY))
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("VOL:0.00");
lcd.setCursor(0, 1);
lcd.print("LITRI:");
lcd.print( TOTAL);
Serial.println ("ZEBROLLA");
}
else
{
TOTAL = TOTAL + LS;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("L/M: ");
lcd.print(WATER);
lcd.setCursor(0, 1);
lcd.print("TOTAL:");
lcd.print( TOTAL);
lcd.print(" L");
Serial.print( "VOL: "); Serial.print( WATER);
Serial.print( "FREQUENCY: "); Serial.print( FREQUENCY);
Serial.print( "TOTALE: "); Serial.println( TOTAL);
}
}
delay(500);
}
I kow i have to start with
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
char auth[] = "123";
char ssid[] = "456";
char pass[] = "789";
#define EspSerial Serial
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
void setup()
{
Serial.begin(9600);
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
}
void loop()
{
Blynk.run();
}
then I tryed with creating functions like “void water_flow” n which paste my previuos loop funcion, but… isn’t that so easy…
Could anyone tell me the way to go or some basic text to consult? I don’t want none to write me the sketch, otherwise I won’t learn anymore! just to figure out how to get out of this deadlock!
Thank you all!