bavspb
November 17, 2018, 6:10pm
1
Hi!
I am using ESP-01 and want to send float data(for example, 0.05) to Blynk IOS app (ver: 2.23.0(4)) but it does not work with float. If I use integer variable it works fine.
Here is the code:
float Result = 0.05;
BLYNK_READ(V5)
{
Blynk.virtualWrite(V5, Result);
}
If I declare Result as Int type(for ex, 5) it works fine.
What should I done to fix it?
thanks!
What sort of widget is V5?
Widgets like Value and Labelled Value have the ability to define how your data is displayed…
Next formatting options are supported:
`/pin/` - displays the value without formatting (12.6789)
`/pin./` - displays the value without decimal part (13)
`/pin.#/` - displays the value with 1 decimal digit (12.7)
`/pin.##/` - displays the value with two decimal places (12.68)
So, if you have it set to /pin./
then you’ll only see integer values displayed, even if you’re sending float data.
Pete.
bavspb
November 17, 2018, 6:59pm
3
Hi! I am using /pin/
Looks like it is correct.
I thought may be I have an old Arduino IDE board version(it was 2.4.0) and now I set up 2.4.2
(http://arduino.esp8266.com/versions/2.4.2/package_esp8266com_index.json )
but nothing has changed
Gunner
November 17, 2018, 9:48pm
4
Define “does not work”… wrong value,? no value? seemingly random characters?
And as already asked, please confirm what widget is on V5?
1 Like
bavspb
November 18, 2018, 7:28am
5
Yes, widget is on V5! It is Labeled Value widget.
I want to add 0.01 to float Result by pressing the hardware button on breadboard. I set Result to initial value = 2.
So, if i press first time I should see 2.01 in app, second time - 2.02 and so on. But I just see 2 in spite of I pressed button
If I add 1(integer) it counts in correct way and I see right result.
I think you need to post your full code (correctly formatted of course).
Pete.
Gunner
November 18, 2018, 7:44am
7
Have you confirmed that your code is calculating the floats correctly by printing the result to your serial monitor?
bavspb
November 18, 2018, 8:03am
8
yes, I confirm it calcs correctly.
bavspb
November 18, 2018, 8:04am
9
Here is the code
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266mDNS.h>
#include <ESP8266WebServer.h>
#include <BlynkSimpleEsp8266.h>
const byte CounterPin = 2;
int CounterState;
float Result =2.00;
volatile byte interruptCounter = 0;
char auth[] = "My_Token";
char ssid[] = "My_SSID";
char pass[] = "My_psw";
void handleInterrupt() {
static unsigned long last_interrupt_time = 0;
unsigned long interrupt_time = millis();
if (interrupt_time - last_interrupt_time > 500)
{
Result=Result+0.01;
}
last_interrupt_time = interrupt_time;
}
BLYNK_READ(V5)
{
Blynk.virtualWrite(V5,Result);
}
void setup() {
Blynk.begin(auth, ssid, pass);
Serial.begin(115200);
delay(10);
Serial.println('\n');
pinMode(CounterPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(CounterPin), handleInterrupt, FALLING);
}
void loop() {
Blynk.run();
}
Gunner
November 18, 2018, 8:07am
10
It never fails… almost no one reads the Welcome Topic before posting here (despite it being a universal forum requirement) so they just don’t get it
Hey, welcome to Blynk Community.
This is the best place to ask questions, leave feedback and share your ideas.
If this is the first time you hear about Blynk, check out our website www.blynk.cc and come back!
As the community is big (and growing), let’s agree on some basic rules.
Asking for help
Before creating a new topic and asking for help, please check if your question was already answered:
Use forum search function
You may want to check out:
Blynk Documentation
Blynk Wiki
Blynk Exa…
@bavspb I fixed your last post for you
1 Like
Gunner
November 18, 2018, 8:30am
11
@bavspb
I just added in a simple test (to one of my existing projects) to emulate your count up… and it is working just fine for me in both Android and iOS on a Labeled Display Widget set for /pin.##/
float Result = 2.00;
BLYNK_READ(V18){
Result=Result+0.01;
Blynk.virtualWrite(V18,Result);
}
… and counting…
Since you are using BLYNK_READ()
are you sure you set your display widget to a reading rate and not PUSH?
1 Like
bavspb
November 18, 2018, 8:47am
12
I have exactly the same screen with settings as you attached besides Input. I gave V5 pin. So it should work but does not
Gunner
November 18, 2018, 8:52am
13
Local Server or Cloud?
What version Blynk Library?
Gunner
November 18, 2018, 9:00am
17
Possibly from the IDE Library manager… depending on how you originally installed it
From within the the library files themselves (OK, not as easy)
When using Blynk print , it will show in the serial monitor.
And you can even print it to a display widget with this command… Blynk.virtualWrite(vPin, BLYNK_VERSION);
Also… what version of ESP Core for Arduino? This you should be able to see in the IDE Library manager.
But all that said… if you do not know, then they are both probably too old
I recommend updating them both…
Blynk library for embedded hardware. Works with Arduino, ESP8266, Raspberry Pi, Intel Edison/Galileo, LinkIt ONE, Particle Core/Photon, Energia, ARM mbed, etc. - blynkkk/blynk-library
bavspb
November 18, 2018, 9:04am
18
thanks for detailed guiding me!
As I wrote earlier Arduino IDE board version(it was 2.4.0) and now I set up 2.4.2
I will check other stuff shortly
Gunner
November 18, 2018, 9:05am
19
Ahh… yes, I glanced over that, but was looking for the word ESP CORE
bavspb
November 18, 2018, 9:36am
20
added newest Library but it did not help