Arduino uno & ethernet shield W5100 (wasnt online yet)

it has got only a buton (V0), buton value (V1), slider for set temp (V10) and Room temperature value (V15).

i see on my app, only slider value and buton value.

i see slider value in serial monitor, but i can’t see Temperature value. but if i write this code

INCOMING_DATA = analogRead(A0);
VOLTAGE = (INCOMING_DATA / 1023.0) * 5000;
TEMPERATURE = VOLTAGE / 10.0;

Serial.print("Room Temperature: ");
Serial.println(TEMPERATURE);}

i can see serial monitor.
i think my program is not enter to “void sendUpTEMPERATURE” case, isn’t it?

I’m not going to respond any further to this topic unless you abandon this template, device and sketch and go down the route I suggested by creating a new template and device and making changes to your original sketch.

Pete.

but i erased all of them and i create new template and program. i think, i don’t understand with google translate or i understand wrong

i create new template on examples.blynk.cc (Blynk Simple Demo).

/*************************************************************

  This is a simple demo of sending and receiving some data.
  Be sure to check out other examples!
 *************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPLPtDx9eoi"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            ""


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

char auth[] = BLYNK_AUTH_TOKEN;

#define W5100_CS  10
#define SDCARD_CS 4

BlynkTimer timer;

// This function is called every time the Virtual Pin 0 state changes
BLYNK_WRITE(V0)
{
  // Set incoming value from pin V0 to a variable
  int value = param.asInt();

  // Update state
  Blynk.virtualWrite(V1, value);
}

// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
  // Change Web Link Button message to "Congratulations!"
  Blynk.setProperty(V3, "offImageUrl", "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations.png");
  Blynk.setProperty(V3, "onImageUrl",  "https://static-image.nyc3.cdn.digitaloceanspaces.com/general/fte/congratulations_pressed.png");
  Blynk.setProperty(V3, "url", "https://docs.blynk.io/en/getting-started/what-do-i-need-to-blynk/how-quickstart-device-was-made");
}

// This function sends Arduino's uptime every second to Virtual Pin 2.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V2, millis() / 1000);
}

void setup()
{
  // Debug console
  Serial.begin(115200);

  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  Blynk.begin(auth);
  // You can also specify server:
  //Blynk.begin(auth, "blynk.cloud", 80);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);
}

void loop()
{
  Blynk.run();
  timer.run();
  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

i add only slider first, it is run. after, i add read analog value, but it is not run. but if i write “analog read” to void loop for try, it is run. i dont understand what is wrong. so i read my analog pin value normally.

You need to add the function to send the temp to BLYNK

void sendUpTEMPERATURE()
{
INCOMING_DATA = analogRead(A0);
VOLTAGE = (INCOMING_DATA / 1023.0) * 5000;
TEMPERATURE = VOLTAGE / 10.0;

Serial.print("Room Temperature: ");
Serial.println(TEMPERATURE);
Blynk.virtualWrite(V15, TEMPERATURE);

}

You also need to add a timer to call the temperature function.

void setup()
{
  // Debug console
  Serial.begin(115200);
  delay(100);

  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  pinMode (RELAY,OUTPUT);
  digitalWrite(RELAY,LOW);

  Blynk.begin(auth);
  // You can also specify server:
  //Blynk.begin(auth, "blynk.cloud", 80);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  timer.setInterval(1000L, myTimerEvent);  //delete this if you are not using it
 delay(100); // needed to keep timers from trying to run concurrently; not needed if you delete timer above
 timer.setInterval(2000L, sendUpTEMPERATURE); // run temp function every 2 seconds

}

also delete this if you are not using it.

// This function sends Arduino's uptime every second to Virtual Pin 2.
void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V2, millis() / 1000);
}

i understand now :frowning: i was added only 1 timer…

The Template and Device you are using are generated using the QuickStart process. The sketch you are using is the sketch generated by the Blynk quickstart process not the sketch you were previously using for Legacy with the code issues that I pointed-out fixed and the three line of firmware configuration from your new device pasted at the beginning.

Stop using this QuickStart stuff - it’s the wrong approach.

Pete.

you are right @PeteKnight, but i am not write program always. i am industriel robot proggrammer, but not arduino. so i don’t know a lot of things.
i am only write program in my home for set temperature, and i don’t look until the server closed.
after this, i will learn more :slight_smile:

My advice is to go back to this post…

and work through each of the issues I’ve raised and fix them in your ORIGINAL code.

Then, do the other things I’ve said in that post to create your template and device and obtain your firmware configuration data that goes at the top of your sketch.

Pete.

i erased all “led” and “lcd”.

void setup()
{
  // Debug console
  pinMode (RELAY,OUTPUT);
  digitalWrite(RELAY,LOW);
  Serial.begin(115200);
  delay(100);
  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  Blynk.begin(auth);
  // You can also specify server:
  //Blynk.begin(auth, "blynk.cloud", 80);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  //timer.setInterval(1000L, myTimerEvent);
  //delay(100);
  timer.setInterval(1000L, sendUpTEMPERATURE);
}

i think, my SD card is inactive and it is before my Blynk.begin command.

if i dont use, i cleared all of them.

i think, i cant understand…

i erased the button, i won’t use. i think, i can use buton or slider, but it is not succes. so i can only use the slider.

generally, i think, i solved the problems, isn’t t? please let me know if there is something I did not do or did not understand.

My sketch’s last version is ;

/*************************************************************

  This is a simple demo of sending and receiving some data.
  Be sure to check out other examples!
 *************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPLPtDx9eoi"
#define BLYNK_DEVICE_NAME           "MY SWEET HOME"
#define BLYNK_AUTH_TOKEN            "**"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

char auth[] = BLYNK_AUTH_TOKEN;

#define W5100_CS  10
#define SDCARD_CS 4

#define RELAY 9
float VOLTAGE = 0;
float TEMPERATURE = 0;
float SET_TEMP = 0;
int INCOMING_DATA = 0;
const int LM35 = A0;
int UpdateFrequency = 5000L;
int Hysteresis = 1;

BlynkTimer timer;

bool result = Blynk.connected();

// This function is called every time the Virtual Pin 0 state changes
/*
BLYNK_WRITE(V0)
{
  // Set incoming value from pin V0 to a variable
  int value = param.asInt();

  // Update state
  Blynk.virtualWrite(V1, value);
}
*/

BLYNK_WRITE(V10)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  Serial.print("V10 Slider value is: ");
  Serial.println(pinValue);
}

void sendUpTEMPERATURE()
{
INCOMING_DATA = analogRead(A0);
VOLTAGE = (INCOMING_DATA / 1023.0) * 5000;
TEMPERATURE = VOLTAGE / 10.0;
Blynk.virtualWrite(V15, TEMPERATURE);
Serial.print("Room Temperature: ");
Serial.println(TEMPERATURE);
if (SET_TEMP < TEMPERATURE)
{
  digitalWrite(RELAY,LOW);
}
 if (SET_TEMP >= (TEMPERATURE + Hysteresis))
 {
  digitalWrite(RELAY,HIGH);
  //Serial.print("KOMBI YANIYOR");
 }
 if (TEMPERATURE > SET_TEMP)
 {
  digitalWrite(RELAY,LOW);
 }
 if (TEMPERATURE < 18)
 {
  //Blynk.notify("ODA ISISI ÇOK DÜŞÜK, KONTROL ET!!");
 } 
 }


// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
  // Change Web Link Button message to "Congratulations!"
 Blynk.syncAll();
 }

// This function sends Arduino's uptime every second to Virtual Pin 2.
/*
 void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  //if (V0 == HIGH)
  //{
 Blynk.virtualWrite(V2, millis() / 1000);
  //}
  
} 
*/
void setup()
{
  // Debug console
  pinMode (RELAY,OUTPUT);
  digitalWrite(RELAY,LOW);
  Serial.begin(115200);
  delay(100);
  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  Blynk.begin(auth);
  // You can also specify server:
  //Blynk.begin(auth, "blynk.cloud", 80);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  //timer.setInterval(1000L, myTimerEvent);
  //delay(100);
  timer.setInterval(1000L, sendUpTEMPERATURE);
}

void loop()
{
  Blynk.run();
  timer.run();

  if(Blynk.connected() == false)
  {
      digitalWrite(RELAY,LOW);
      Blynk.connect();
  }

  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

please check it for me and return to me.

This variable is local, not global. You can’t see it’s value outside of the BLYNK_WRITE(V10) function, so you can’t use it for anything.

When you were using V15 for the slider I said this…

But you’ve neither swapped to a sensible variable name, or made it global.

When you were using V5 for your slider I said that you should…

This obviously needs to change now that you are (for some unknown reason) using V10 for your slider.

When you’ve done this, is your device working as expected?

Pete.

but i can see room temprature (V15) and Set Temp (Slider-V10) in my Blynk app and serial monitor. so i tought it was fixed. but relay is not active when i was set to temp over than room temperature.

i will try it in the evening again.

i don’t understant it, i use V10 silder for set the temp. do i need to use something else

The Set Temp value is being set from the app, so of course it’s visible there. You are serial printing the pinValue value from within `BLYNK_WRITE(V10), where that value is visible.

You have created a global variable called SET_TEMP, but you aren’t using it.

Blynk.syncAll() doesn’t work in Blynk IoT (well, that’s not 100% true, but it doesn’t work in the same way).
You have to stop using Blynk.syncAll() and instead synchronise the specific individual pins that are providing data from the app to your sketch - in this case just the Set Temp slider.

Pete.

BLYNK_CONNECTED()
{
  // Change Web Link Button message to "Congratulations!"
 Blynk.syncVirtual(V5);
 //Blynk.syncVirtual(V10);
 }
void sendUpTEMPERATURE()
{
.
.

Blynk.virtualWrite(V10, SET_TEMP);
.
.
}

i write like this, SET_TEMP value is always 10, when i was set with slider.

BLYNK_WRITE(V5)
{
  int pinValue = param.asInt();
}

i didn’t see any difference.

i even wrote it in the “void loop” just for testing purposes, but I still couldn’t get any results.

i think, i don’t know how to use the SET_TEMP…

I don’t understand your comments or the code snippets.

Pete.

I wanted to write the changes I made in my code part by part, but I guess it wasn’t clear.

in a word, i made the changes according to what you said, but I guess I couldn’t.

/*************************************************************

  This is a simple demo of sending and receiving some data.
  Be sure to check out other examples!
 *************************************************************/

// Template ID, Device Name and Auth Token are provided by the Blynk.Cloud
// See the Device Info tab, or Template settings
#define BLYNK_TEMPLATE_ID           "TMPLPtDx9eoi"
#define BLYNK_DEVICE_NAME           "MY SWEET HOME"
#define BLYNK_AUTH_TOKEN            "***"


// Comment this out to disable prints and save space
#define BLYNK_PRINT Serial


#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>

char auth[] = BLYNK_AUTH_TOKEN;

#define W5100_CS  10
#define SDCARD_CS 4

#define RELAY 9
float VOLTAGE = 0;
float TEMPERATURE = 0;
float SET_TEMP = 0;
int INCOMING_DATA = 0;
const int LM35 = A0;
int UpdateFrequency = 5000L;
int Hysteresis = 1;

BlynkTimer timer;

bool result = Blynk.connected();

// This function is called every time the Virtual Pin 0 state changes
/*
BLYNK_WRITE(V0)
{
  // Set incoming value from pin V0 to a variable
  int value = param.asInt();

  // Update state
  Blynk.virtualWrite(V1, value);
}
*/

BLYNK_WRITE(V10)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  //Blynk.virtualWrite(V10, SET_TEMP);
  Serial.print("V10 Slider value is: ");
  Serial.println(pinValue);
}
BLYNK_WRITE(V5)
{
  int pinValue = param.asInt();
}

void sendUpTEMPERATURE()
{
INCOMING_DATA = analogRead(A0);
VOLTAGE = (INCOMING_DATA / 1023.0) * 5000;
TEMPERATURE = VOLTAGE / 10.0;
Blynk.virtualWrite(V15, TEMPERATURE);
//Blynk.virtualWrite(V10, SET_TEMP);
Serial.print("Room Temperature: ");
Serial.println(TEMPERATURE);
if (SET_TEMP < TEMPERATURE)
{
  digitalWrite(RELAY,LOW);
}
 if (SET_TEMP >= (TEMPERATURE + Hysteresis))
 {
  digitalWrite(RELAY,HIGH);
  //Serial.print("COMBI IS BURN");
 }
 if (TEMPERATURE > SET_TEMP)
 {
  digitalWrite(RELAY,LOW);
 }
 if (TEMPERATURE < 18)
 {
  //Blynk.notify("ROOM TEMPERATURE TOO LOW, CHECK IT!!");
 } 
 }


// This function is called every time the device is connected to the Blynk.Cloud
BLYNK_CONNECTED()
{
  // Change Web Link Button message to "Congratulations!"
 Blynk.syncVirtual(V5);
 //Blynk.syncVirtual(V10);
 }

// This function sends Arduino's uptime every second to Virtual Pin 2.
/*
 void myTimerEvent()
{
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  //if (V0 == HIGH)
  //{
 Blynk.virtualWrite(V2, millis() / 1000);
  //}
  
} 
*/
void setup()
{
  // Debug console
  pinMode (RELAY,OUTPUT);
  digitalWrite(RELAY,LOW);
  Serial.begin(115200);
  delay(100);
  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card

  Blynk.begin(auth);
  // You can also specify server:
  //Blynk.begin(auth, "blynk.cloud", 80);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8080);

  // Setup a function to be called every second
  //timer.setInterval(1000L, myTimerEvent);
  //delay(100);
  timer.setInterval(1000L, sendUpTEMPERATURE);
  //timer.setInterval(1500L, sendUpSET_TEMP);
}
void loop()
{
  Blynk.run();
  timer.run();

  if(Blynk.connected() == false)
  {
      digitalWrite(RELAY,LOW);
      Blynk.connect();
  }

  // You can inject your own code or combine it with other sketches.
  // Check other examples on how to communicate with Blynk. Remember
  // to avoid delay() function!
}

If your slider widget, which is used to define your set value, is attached to pin V10 then you are capturing that widget value in a local variable called pinValue
That variable isn’t visible or useable outside of the BLYNK_WRITE(V10) function, so can’t be used in your sendUpTEMPERATURE() where you are attempting to turn a relay on or off by comparing the temperature reading to the value you’ve set with your V10 slider.

In line of code like this:

You are using a variable called SET_TEMP to do your temperature comparison, but SET_TEMP has no relationship to the V10 slider value.
SET_TEMP is being declared as global and set to zero at the top of your sketch…

but it never changes. It will always be zero.

If you did this:

BLYNK_WRITE(V10)
{
  SET_TEMP = param.asInt(); // assigning incoming value from pin V1 to a variable
  Serial.print("V10 Slider value is: ");
  Serial.println(SET_TEMP);
}

then the incoming value from the V10 slider will be stored in the global SET_TEMP variable that you’re using for your temperature comparisons in sendUpTEMPERATURE()

If you want the Blynk server to tell your sketch what the value of the slider attached to V10 is when the program starts-up then you need to fix this:

I have no idea what is connected to V5, or why you are synchronising its value at startup, or why you have a BLYNK_WRITE handler for it.

Pete.

1 Like

Blynk.notify has been replaced with Blynk.logEvent

if i manage to pull the relay first, it will be there too :slight_smile: