Arduino uno & ethernet shield W5100 (wasnt online yet)

here you are, it is my all program:

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

  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           "TMPLbyzZk8ht"
#define BLYNK_DEVICE_NAME           "Quickstart Device"
#define BLYNK_AUTH_TOKEN            "7PfpVbyHZDL2ZT1***"


// 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
WidgetLCD lcd(V1);
float VOLTAGE = 0;
float TEMPERATURE = 0;
float SET_TEMP = 0;
int INCOMING_DATA = 0;
#define RELAY 9
const int LM35 = A0;
int UpdateFrequency = 5000L;
int Hysteresis = 1;
//WidgetLED led1(V9);
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);
}

// 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
  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);
}

BLYNK_WRITE(V5)
{
 SET_TEMP = param.asInt();
 Blynk.virtualWrite(V5,SET_TEMP);
}

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

void sendUpTEMPERATURE()
{
  
Blynk.virtualWrite(V5, TEMPERATURE);
 
INCOMING_DATA = analogRead(LM35);
VOLTAGE = (INCOMING_DATA / 1023.0) * 5000;
TEMPERATURE = VOLTAGE / 10.0;

  lcd.print(0, 1, TEMPERATURE);
 
 /*if ((SET_TEMP < TEMPERATURE) {
  digitalWrite(RELAY,LOW);
  lcd.clear();
  lcd.print(0, 0, "KOMBİ SÖNDÜ!!");
  led1.off();
  //Blynk.notify("İSTENEN SICAKLIĞA ULAŞILDI!!");
 } 
 else if ((SET_TEMP >= (TEMPERATURE + Hysteresis)) {
  digitalWrite(RELAY,HIGH);
  //lcd.clear();
  lcd.print(0, 0, "KOMBİ YANIYOR");
  led1.on();
  //Blynk.notify("İSTENEN SICAKLIĞA ISITILIYOR!!");
 } */
/* if (TEMPERATURE > SET_TEMP){
  //Blynk.notify("ACTUEL TEMPERATURE IS OVER THAN SET_TEMP!!");
  //lcd.print(0, 1, "ODA FAZLA ISINDI");
  digitalWrite(RELAY,LOW);
  led1.off();
  //Blynk.notify("RELAY IS OFF!!");
 }
 if (TEMPERATURE < 18){
  lcd.print(0, 1, "ODA ISISI DÜŞÜK!");
  Blynk.notify("ODA ISISI ÇOK DÜŞÜK, KONTROL ET!!");
 }
 else {lcd.print(0, 1, "ODAISISI YETERLİ");
 }*/
}

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!
}

if you want, i can share my app screenshots…

Please post your entire Legacy app, with no changes.

Pete.

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#define W5100_CS  10
#define SDCARD_CS 4
WidgetLCD lcd(V1);


char auth[] = "*****";
float VOLTAGE = 0;
float TEMPERATURE = 0;
float SET_TEMP = 0;
int INCOMING_DATA = 0;
#define RELAY 9
const int LM35 = A0;
int UpdateFrequency = 5000L;
int Hysteresis = 1;
WidgetLED led1(V1);
BlynkTimer timer;
bool result = Blynk.connected();

void setup()
{
  pinMode (RELAY,OUTPUT);
  digitalWrite(RELAY,LOW);
  Serial.begin(9600);
  delay(100);
  Blynk.begin(auth);
  pinMode(SDCARD_CS, OUTPUT);
  digitalWrite(SDCARD_CS, HIGH); // Deselect the SD card
  timer.setInterval(UpdateFrequency, sendUpTEMPERATURE);
}

BLYNK_CONNECTED() {
  Blynk.syncAll();
  
}
BLYNK_WRITE(V5)
{
 SET_TEMP = param.asInt();
 Blynk.virtualWrite(V5,SET_TEMP);
}

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

void sendUpTEMPERATURE()
{
  
Blynk.virtualWrite(V10, TEMPERATURE);
 
INCOMING_DATA = analogRead(LM35);
VOLTAGE = (INCOMING_DATA / 1023.0) * 5000;
TEMPERATURE = VOLTAGE / 10.0;

  //lcd.print(0, 1, TEMPERATURE);
 
 if ((SET_TEMP < TEMPERATURE) || (V15 == LOW)){
  digitalWrite(RELAY,LOW);
  lcd.clear();
  lcd.print(0, 0, "KOMBİ SÖNDÜ!!");
  led1.off();
  //Blynk.notify("İSTENEN SICAKLIĞA ULAŞILDI!!");
 }
 else if ((SET_TEMP >= (TEMPERATURE + Hysteresis)) || (V15 == HIGH)){
  digitalWrite(RELAY,HIGH);
  //lcd.clear();
  lcd.print(0, 0, "KOMBİ YANIYOR");
  led1.on();
  //Blynk.notify("İSTENEN SICAKLIĞA ISITILIYOR!!");
 }
 if (TEMPERATURE > SET_TEMP){
  //Blynk.notify("ACTUEL TEMPERATURE IS OVER THAN SET_TEMP!!");
  //lcd.print(0, 1, "ODA FAZLA ISINDI");
  digitalWrite(RELAY,LOW);
  led1.off();
  //Blynk.notify("RELAY IS OFF!!");
 }
 if (TEMPERATURE < 18){
  lcd.print(0, 1, "ODA ISISI DÜŞÜK!");
  Blynk.notify("ODA ISISI ÇOK DÜŞÜK, KONTROL ET!!");
 }
 else {lcd.print(0, 1, "ODAISISI YETERLİ");
 }
}

void loop()
{
 
 timer.run();

 Blynk.run();


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

}

If i use

Serial.println(TEMPERATURE);

in void loop(), it writes (0,00) on serial monitor

The sketch has quite a few issues, some of which I’ve pointed-out before…

Issue 1, you’re assigning V1 as an alias for two different widgets, and LCD and LED…

Issue 2, these two lines of code are partly responsible for ensuring that the Ethernet interface is active, and the SD card is inactive (The two cant operate at the same time). As a result, they shouod be BEFORE your Blynk.begin command…

Issue 3, The Blynk server is notifying you of a change in the value of the (slider) widget attached to V5. You are then immediately writing this change back to pin V5. I’ve asked you before why you are doing this and you’ve failed to answer. You need to remove the Blynk.virtualWrite command from this BLYNK_WRITE function…

Issue 4, You are writing the TEMPERATURE variable to Pin V5 BEFORE you’ve taken the temperature reading…

Issue 5, In this if statement you are attempting to check if the (button?) widget attached to pin V15 is LOW. However, you can’t do this. V15 is an alias that allows you to refer to a virtual pin, and if you try to print it’s value you’ll see that it is always 15 (and V16 will always be 16 etc).
You need to make the pinvalue variable in BLYNK_WRITE(V15) global (and preferable give it a more sensible name) than use that variable in your if statement…

You also do the same thing elsewhere in your sendUpTEMPERATURE function.

Once you’ve fixed these issues then I’d suggest that you delete the QuickStart device and template using the web console.
Then, create a new template and add-in the virtual datastreams that you require. These appear to be V1, V5 and V15 (and possibly another one that will be for your LED which currently seems to be sharing pin V1 - see Issue 1 above).
Give these appropriate min/max values and data types (Integer or Double) then create a device based on this template.
In the Device > Device Info screen copy the Firmware Configuration and paste ot at the top of your sketch.

Then, in the app, add widgets to this device dashboard and configure them correctly.

In your sketch you should change this:

[quote=“Metin_Tataroglu, post:50, topic:42269”]

BLYNK_CONNECTED() {
  Blynk.syncAll();
  
}

so that instead of Blynk.syncAll(); you use Blynk.syncVirtual(V5);

You also need to comment-out this line…

Once you have it working, you should read this about how to send notifications in Blynk IoT…

Pete.

i don’t use led, so i erase it…
i only use WidgetLCD lcd(V1); isn’t it?

Isn’t my “Blynk.begin” command already written after?

because i write with slider, and read on gauge with V5.

V15 is external button in my app. i added it, may be manuel open/close to the relay. but it isn’t run. so i don’t use it.

I will try your suggestions first. Then I can ask for your support again. thank you :slight_smile:

That’s not true…

No….

It’s not necessary to write the value back to the pin to make it appear on the gauge. Delete this line of code to prove that to yourself.

It doesn’t make any difference. Your if statements are using the value of 15 whenever you place “V15” within an if logical test. You need to edit your if statements.

Pete.

my code is last version is in there;

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

  You can use this sketch as a debug tool that prints all incoming values
  sent by a widget connected to a Virtual Pin 1 in the Blynk App.

  App project setup:
    Slider widget (0...100) on V1
 *************************************************************/

// 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           "TMPLbyzZk8ht"
#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
float VOLTAGE = 0;
float TEMPERATURE = 0;
float SET_TEMP = 0;
int INCOMING_DATA = 0;
#define RELAY 9
const int LM35 = A0;
int UpdateFrequency = 5000L;
int Hysteresis = 1;

BlynkTimer timer;
bool result = Blynk.connected();

// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1

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");
}


BLYNK_WRITE(V10)
{
  int pinValue = param.asInt(); // assigning incoming value from pin V1 to a variable
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  Serial.print("V10 Slider value is: ");
  Serial.println(pinValue);
}

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);
}

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(V5, TEMPERATURE);
}

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);
  timer.setInterval(1000L, myTimerEvent);
}

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

but i can’t read analog signal. how can i read A0 (LM35). i couldn’t manage it by myself

Kinda like before. You are sending a value to V5, and trying to read a value from V5.

If V5 is a gauge as you stated get rid of the code that reads it.

i.e. get rid of this

or send your temperature value to a different pin.

So, instead of taking my advice of fixing these issues in your original sketch then…

Instead you’ve used your other code, which is cluttered with other problems and uses different virtual pins.

I can’t help you if you don’t take my advice.

Pete.

1 Like

but i used it before, i can’t understand what is change… i can try in evening

but i shared with you old program, because you want it. it was run with old Blynk app. but it no run with Blynk IOT.
i am only use V5 for home actuel temperuture and V10 for set temperature.
i create new template and add old program’s section. but i can try it in evening again.

hi @PeteKnight and @Toro_Blanco ;
my simple code 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           "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

#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
  // You can also use:
  // String i = param.asStr();
  // double d = param.asDouble();
  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;

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

// 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);
  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);
}

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!
}

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…