Slider not send data

Dear Sir,
I am a new member of Blynk. I have a problem the slider not send the setting value (100). Sometime it sent (0) that made my condition not working. Please help me. Sorry for my poor English
Thanks

Sakchai

// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPLvsXDEA6l"
#define BLYNK_DEVICE_NAME "Smart Farm"
#define BLYNK_FIRMWARE_VERSION        "0.3.10"
#define BLYNK_PRINT Serial
#define APP_DEBUG

#include "BlynkEdgent.h"

int SoilValue ;
int Raw ;
int Slider ;

BlynkTimer timer;

void sensorDataSend(){
  
  SoilValue = analogRead(A0);
  Raw=map(SoilValue,406,281,0,100);
  Blynk.virtualWrite(V3, Raw);
  Blynk.virtualWrite(V4, SoilValue);
  Blynk.virtualWrite(V9, Slider);

}    

void setup()
{
  Serial.begin(115200);
  BlynkEdgent.begin();
  Blynk.syncAll();
  
  timer.setInterval(1000L, sensorDataSend);
}

BLYNK_WRITE(V1){
   Slider = param.asInt();
   }

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

Hello.

The data from the control widgets are not stored/displayed on the graph. Only data sent from the hardware. If you still want to show it, you need to send the value back to the server.

@Dmitriy I think that’s what he’s doing here…

(I assume that the slider is on V1 and the graph on V9).

There are a couple of issues…

The Blynk.syncAll(); in void setup probably won’t have the desired effect unless it’s moved to BLYNK_CONNECTED() and of course it won’t work unless the virtual datastreams have the “Sync with latest server value every time device connects to the cloud” option enabled.

This means that the device may be starting with a zero value for Slider rather than the value set by the slider widget.

Adding some serial print statements into the sketch would help.

Pete.

3 Likes

Hi Pete, Dmitriy

Sorry for late reply
I removed Blynk.syncAll(); and send serial print as you requested
but it will send (0) value for right now. this will be happen later.
Additional, I don’t understand the slider needs activated to send value (100) after uploading program. I think it might be automatiocally to send value.

Thanks,
Sakchai


How did you configure your datastream ?
Post a screenshot please.

1 Like

I didn’t say that you should remove it, it needs to be placed in a function called BLYNK_CONNECTED()
Also, as I said earlier, it won’t work unless every datastream that you want to synchronise has the “Sync with latest server value every time device connects to the cloud” enabled (in the Advanced settings for the datastream).

BTW, please don’t paste screenshots of your serial monitor, copy and paste the data instead.

Pete.

2 Likes

Hi John,
Here you are

Thanks,
Sakchai

John was asking for the detail of how your V1 datastream is configured.

Pete.

Right, like this

Hi John93,

I already checked it for ago since I start the project

V1 = Slider
Thanks

Thannks

So, have you made the code changes?

Pete.

1 Like

Good, now add this function to your sketch

BLYNK_CONNECTED() {
Blynk.syncAll();
}
1 Like

Hi John and Pete,

I already changed my code.
Let me monitor and update you soon.
Thanks for help


19:21:17.378 → [6414] Connecting to blynk.cloud:443
19:21:18.675 → [7735] Ready (ping: 12ms).
19:21:18.954 → [7990] CONNECTING_CLOUD => RUNNING
19:21:19.376 → Slider Value 100
19:21:19.791 → Slider Value 100
19:21:20.817 → Slider Value 100
19:21:21.796 → Slider Value 100

Sakchai


// Fill-in information from your Blynk Template here
#define BLYNK_TEMPLATE_ID "TMPLvsXDEA6l"
#define BLYNK_DEVICE_NAME "Smart Farm"
#define BLYNK_FIRMWARE_VERSION        "0.3.10"
#define BLYNK_PRINT Serial
#define APP_DEBUG

#include "BlynkEdgent.h"

int SoilValue ;
int Raw ;
int Slider ;

BlynkTimer timer;


void sensorDataSend(){
  
  SoilValue = analogRead(A0);
  Raw=map(SoilValue,406,281,0,100);
  Blynk.virtualWrite(V3, Raw);
  Blynk.virtualWrite(V4, SoilValue);
  Blynk.virtualWrite(V9, Slider);
  Serial.print("Slider Value ");
  Serial.println(Slider);
  

}    

BLYNK_CONNECTED(){
    Blynk.syncAll();
}
void setup()
{
  Serial.begin(115200);
  BlynkEdgent.begin();
 



  timer.setInterval(1000L, sensorDataSend);
}

BLYNK_WRITE(V1){
   Slider = param.asInt();
   }

void loop() {
  BlynkEdgent.run();
  timer.run();
 }
1 Like