Before creating the topic
- Search forum for similar topics
- Check http://docs.blynk.cc and http://help.blynk.cc/
- Add details :
• Hardware model + communication type. For example: Arduino UNO with Ethernet Shield
• Smartphone OS (iOS or Android) + version
• Blynk server or local server
• Blynk Library version
• Add your sketch code.Code should be formatted as example below.
Simply paste your code between ``` If you don’t format your code, your topic can be deleted by moderators.
void loop()
Hello together,
i’am a new menber of the iot family.
i will control my water dispencer with ESP8266.therefore i build a blynk app with 2 slider to get glass-size and sparkling density for my cup. Everytime i use the sliders i get a value from virtualpin an can print it on serialmonitor. But if i try to calculate with teh value of the virtual pins i got no result even i declared the variables as global.
that’s the sketch
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "3fee5cc8d13e4acfa76c9eebf8a6734e";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "SvenRueckmann_iPhone";
char pass[] = "sven22";
int pinValueDensity;
int pinValueSize;
int maximumMilisekunden=60000; // 60000 Millisekunden=1 Minute=330 ml
int maximumGsize=330; // Glasgroesse 330 ml
int gstspark; //glas_size_time_sparkling_still Variable zur Steuerung des Zuflusses
int gststill; //glas_size_time_sparkling_still Variable zur Steuerung des Zuflusses
int gstssFaktorspark;//glas_size_time_sparkling_still Variable zur Steuerung des Zuflusses als prozentfaktor
int gstssFaktorstill; //glas_size_time_sparkling_still Variable zur Steuerung des Zuflusses als prozentfaktor
BLYNK_CONNECTED() {
Serial.println("*** Sync All ? ***");
Blynk.syncAll();
}
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
BLYNK_WRITE(V1)
{
pinValueDensity = param.asInt(); // assigning incoming value from pin V1 to a variable
Serial.print("sparkling density % is: ");
Serial.println(pinValueDensity);
fehlersuche();
faktor();
fehlersuche();
}
BLYNK_WRITE(V2)
{
pinValueSize = param.asInt(); // assigning incoming value from pin V2 to a variable
Serial.print("glass size ml is: ");
Serial.println(pinValueSize);
fehlersuche();
faktor();
fehlersuche();
}
// die wird nicht benutzt, weil sie gar nicht funktioniert
void laufzeit()
{
gstspark=0;
gststill=0;
gstspark=maximumMilisekunden*pinValueDensity/100*pinValueSize/maximumGsize;
gststill=maximumMilisekunden*(100-pinValueDensity)/100*pinValueSize/maximumGsize;
Serial.print("Laufzeit Sparkling in Sekunden ist : ");
Serial.println(gstspark/1000);
Serial.print("Laufzeit Still in Sekunden ist : ");
Serial.println(gststill/1000);
}
void faktor()
{
//gstssFaktorspark=1+(pinValueDensity/100*pinValueSize/maximumGsize);
//gstssFaktorstill=1+((100-pinValueDensity)/100*pinValueSize/maximumGsize);
pinValueDensity/=100;
gstssFaktorspark=pinValueDensity;
gstssFaktorspark *= pinValueSize;
gstssFaktorspark /=maximumGsize;
gstssFaktorstill=(100 - pinValueDensity);
}
void fehlersuche()
{
Serial.print("Density: ");
Serial.println(pinValueDensity);
Serial.print("Size: ");
Serial.println(pinValueSize);
Serial.print("Sparklingfaktor : ");
Serial.println(gstssFaktorspark);
Serial.print("Stillfaktor : ");
Serial.println(gstssFaktorstill);
Serial.print("maxSize : ");
Serial.println(maximumGsize);
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
}
void loop()
{
Blynk.run();
}
That’s the result at the serial monitor
maxSize : 330
Density: 0
Size: 254
Sparklingfaktor : 0
Stillfaktor : 100
maxSize : 330
glass size ml is: 290
Density: 0
Size: 290
Sparklingfaktor : 0
Stillfaktor : 100
maxSize : 330
Density: 0
Size: 290
Sparklingfaktor : 0
Stillfaktor : 100
maxSize : 330
what can i do? I used also other spellings for calculation like /= or *=. Result was same.
regards sven