BLYNK
BLYNK.IO       📲 GETTING STARTED       📗 DOCS       👉 SKETCH BUILDER

Set min and max value with setProperty function

Hi,
i have an idea about setting min and max values of widgets like gauge or level. For example, if I have an energy meter and every day it extracts min and max value of power, it would be useful be able to set these values as min and max of gauge widget that displays average power consumpion, in order to have “dynamic” widget that updates every day. The result would be:

Blynk.setProperty(V1, "min", minpower);
Blynk.setProperty(V1, "max", maxpower);

What do you think? :smile:

4 Likes

Just what I was looking for. Is this request accepted?

No. But I think it is time to add this feature.

1 Like

Implemented on server side - https://github.com/blynkkk/blynk-server/issues/557. In apps will be available in few weeks.

1 Like

Cool :smiley:

I tried to use the function Blynk.setProperty(vPIN, “max”, value). It doesn’t work :frowning:

@Bird55 does the widget you are trying to set a “max” value actually have max and min values?

1 Like

Yes, I use the Gauge widget

Is your app was in running mode? Does stop/run app helps? Android/ios? Versions?

Android, version 7.0
I use the function ESP.deepSleep(sleepTime), in order to reduce energy consumption.
I’ve connected the D0 pin with RST pin, and my Wemos wakes up after a delay sleepTime and performs the function of setup().
I wanted to use this function to set the max/min values.
But setting the color and label worked.

So did start/stop of the app helps? I mean gauge values are changed after that or not?

Do you set “color”, label and max in that order and straight after each other in your sketch?
Try max first and comment out label, see what that gives you.

No, the start / stop application does not help.

I tried, there is no result

Paste your formatted sketch.

Here, I simplified the code for my sketch

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include "Seeed_BME280.h"
#include <Wire.h>
const int sleepTimeM = 5; //this is in minutes
const byte battLevelPin = A0;
BME280 bme280;
char auth[] = "*";
char ssid[] = "*";
char pass[] = "*";
void setup() {
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  if(!bme280.init()) {
    Serial.println("Device error!");
  }
  Blynk.setProperty(V2, "min", 3);
  Blynk.setProperty(V2, "max", 5);
}
void loop() {
  Blynk.run();
  //get and print temperature
  float temp = bme280.getTemperature();
  Blynk.virtualWrite(0, temp);
  //get and print atmospheric pressure data
  float pressure = bme280.getPressure();
  Blynk.virtualWrite(1, p);
  //get and print battery voltage
  float battLevelNow = analogRead(battLevelPin) / 251.0;
  Blynk.virtualWrite(2, battLevelNow);
  ESP.deepSleep(sleepTimeM * 60 * 1000000);
}

I understood what my mistake was. The values ​​of max and min must be integers.
Thank you for your time.

3 Likes

Try this:

Remove the Blynk.setProperty commands from setup and put them in BLYNK_CONNECTED

// only run the commands after you connect and not before so they aren't missed
BLYNK_CONNECTED(){
  Blynk.setProperty(V2, "min", 3);
  Blynk.setProperty(V2, "max", 5);
}

@Bird55 I’ll also do a fix for next server version so the server will accept floats too.

Hello @Dmitriy , is this function implemented in Blynk 2.0? Can I change min and max values of a Gauge widget?