Arduino uno & ethernet shield W5100 (wasnt online yet)

Normally, I’d suggest that you start by reading this:

However, your code is such a mess that you should probably start by looking at one of the thermostat examples that are on this forum and get that running with your hardware, then modify it to do exactly what you want.

Pete.

@PeteKnight thanks for your answer. I tried again

hi, me again :slight_smile:
my new code as follow:
i think this time OK, what do you think for this??

i want to set with slider of temp (V5), until synchronized with TEMPERATURE (V10).

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#define W5100_CS  10
#define SDCARD_CS 4

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;


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_WRITE(V5)
{
 SET_TEMP = param.asInt();
 Blynk.virtualWrite(V5,SET_TEMP);
}

void sendUpTEMPERATURE()
{
  
 Blynk.virtualWrite(V10, TEMPERATURE);

INCOMING_DATA = analogRead(LM35);
VOLTAGE = (INCOMING_DATA / 1023.0) * 5000;
TEMPERATURE = VOLTAGE / 10.0;
 
 if (SET_TEMP < TEMPERATURE){
  digitalWrite(RELAY,LOW);
  led1.off();
 }

 else if (SET_TEMP >= (TEMPERATURE + Hysteresis)){
  digitalWrite(RELAY,HIGH);
  led1.on();
 }
if (TEMPERATURE > SET_TEMP){
  Blynk.notify("ACTUEL TEMPERATURE IS OVER THAN SET_TEMP!!");
  Blynk.notify("PLEASE RELAY OFF MANUEL!!");
 }
 }

void loop()
{
  Blynk.run();

  timer.run();
}

That looks much better, but what is the purpose of this line in the BLYNK_WRITE(V5) callback?

You obviously don’t have any code to read the actual temperature from your sensor yet. I assume that this will go at the beginning of your sendUpTEMPERATURE function?
Personally, I’d change the timer on this to at least 5 seconds.

Pete.

I want to set temp, with slider of (V5). the RELAY is HIGH until V5=V10 (SET_TEMP=TEMPERATURE). what am I doing wrong or missing.
or how set to wanted temp?

Looking at your code you seem to have an LM35 sensor attached to pin A0.

I assumed that you will be asking this sensor what the actual room temperature is on a regular basis, and comparing this to the target temperature which you’ve set using a slider in Blynk.

There is currently no process for getting the current room temperature from the LM35 sensor into your code, so the TEMPERATURE variable will always be 0.

Pete.

But my TEMPERATURE is show real TEMP, look same this and temp value iş correct :


I dont set TEMP with slider only, with my previous program.
I tried with my new program in this night

I’m sorry, but I don’t understand what you’re saying here.

Is the code that you posted above the code that is giving the results in the app screenshot? The screenshot appears to show an LCD widget that isn’t in your code, plus a button that isn’t in the code either.

Pete.

I will set the desired temperature with SET_TEMP (V5), with the help of slider.
TEMPERATURE is my home actuel room temperature from LM35.
EXTERNAL_RELAY is my boiler contactor.
LED is my EXTERNAL_RELAY 's active / pasive status.
LCD widget is only visual of SET_TEMP and ROOM TEMPERATURE.
which button isnt in my code?

Okay, it seems that as well as using a virtual pin for your slider widget, you are using direct pin manipulation (digital pins) for your buttons. Personally, I NEVER use digital (or analogue for that matter) pins in my app - it severely limits what you are able to do in terms do control, and, from what others say, can lead to some unreliability.

Are you using Eventor to handle your LCD display? I can’t see how this is displaying the data otherwise.

And, I still can’t see how your temperature readings are making their way into the sketch.

What happens if you unplug the Ethernet cable from your Arduino? Does the Arduino still control your relay when the temperature is above or below the target?
If not, is it important to you that the relay is controlled correctly when the internet or the Blynk cloud server is down?

Pete.

I am using a virtual pin so I can use the slider on BLYNK for setting, is there another way to do this? I think this is enough for me because there will not be a very comprehensive application.

i dont use eventor for LCD, i used virtual pin of V5 and V10.

I can’t try this program right now, because I can’t get online to my app, with the network at work :slight_smile:
i think, this is my home temperature reading:

void sendUpTEMPERATURE()
{
  
 Blynk.virtualWrite(V10, TEMPERATURE);

I don’t know what to do if my internet connection is broken, but I wish control my network, but how??

My lcd monitor’s setting is like this and show actual temperature in my room. but there is +1 degree difference between mechanique termometer

how do you use analog or digital pins?

I’m sorry, but I don’t understand what you’re saying here.

void sendUpTEMPERATURE()
{
  
 Blynk.virtualWrite(V10, TEMPERATURE);

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

i am sorry, i missed it. because i cant try my last program…
and now, no network in my arduino, but my relay is HIGH… Is my program wrong? or no network connection??
what can i do for my relay be OFF, when my network has broken??

Hi Pete,
My arduino is online now, I see actuel temperature, but my relay iş working reverse :frowning:

When set_temp > TEMPERATURE , relay is low
When set_temp < TEMPERATURE, relay is high

It’s extremely difficult to help you when you miss out important sections of your code, and when I point-out that the code is incomplete you still don’t recognise fact.

Pete.

You are right, I didnt pay attention, so sorry. But i forget it, when i was editing new code.
I still do not recognise fact, because it works in my previous code, and i dont look that again. Sorry :frowning:

Hi,
Why does my working device go offline? About 10 hours online, after offline… is the server close ?

Scroll to the bottom of this page and you’ll see cloud server uptime information:

As yoou’ll see, there has bee no downtime recently…

The disconnections are most likely caused by your own network settings, or by the board itself. You can check the DHCP lease time setting in the router to see if that corresponds with the disconnection frequency. If it does then moving to a static IP or your device may help.
If your device isn’t reconnecting automatically then look at adding a routine to check for this and attempt to do a reconnection. There are plenty of examples for WiFi boards on the forum, but probably fewer for Ethernet.

But, in my experience over a 6-month period, these Ethernet shields are notoriously unreliable and will eventually get to a point where a physical reset (via the reset button or pulling the reset pin low) is the only option, and even then multiple attempts are often required. This is the reason why I swapped to NodeMCU devices.

Pete.

I updated and reloaded the libraries that can be updated, my arduino communicated but I need to find a solution for reconnection. I continue to research, thanks…

void loop()
{
 
 timer.run();

 Blynk.run();


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

}

is this a solution ?

so i think,
if my Blynk is connected, arduino is run.
if not connected, my relay off and blynk reconnect.

could this be the right method??