Problems with Arduino Uno with Blynk using ENC28J60

Hi, everyone!! I’m having some troubles to send humidity and temperature data, using a DHT11, to Blynk using an Arduino Uno and Ethernet Shield ENC28J60. I noticed, after some tests, that Arduino get lost his connection with Blynk server, when the BlynkTimer or SimpleTimer server are used in code, not sending any data correctly and losing the connection.

The code used:

#define BLYNK_PRINT Serial

/* Fill-in your Template ID (only if using Blynk.Cloud) */
#define BLYNK_TEMPLATE_ID   "templateID"

#include <SPI.h>
#include <DHT.h>
#include <UIPEthernet.h>
#include <SimpleTimer.h>
#include <BlynkSimpleUIPEthernet.h>

// You should get Auth Token in the Blynk App
char auth[] = "myauth";

#define DHTPIN 6
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

BlynkTimer timer;
//SimpleTimer timer;

//Função do Sensor DHT11
void sensorDHT() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  Blynk.virtualWrite(V6, t);
  Blynk.virtualWrite(V7, h);
}

void setup(){
  Serial.begin(9600);
  dht.begin();

  Blynk.begin(auth);
  timer.setInterval(1000L, sensorDHT);

}

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

Hey there.

First edit your post and add triple backticks at the beginning and the end of your sketch. Triple backticks look like this ```

Second try this sketch :

/*************************************************************
  For this example you need UIPEthernet library:
    https://github.com/UIPEthernet/UIPEthernet

  Typical wiring would be (this is for Arduino UNO,
  search for correct wiring for your board):
   VCC -- 5V
   GND -- GND
   CS  -- D10
   SI  -- D11
   SCK -- D13
   SO  -- D12
   INT -- D2

  This example shows how value can be pushed from Arduino to
  the Blynk App.

  WARNING :
  For this example you'll need Adafruit DHT sensor libraries:
    https://github.com/adafruit/Adafruit_Sensor
    https://github.com/adafruit/DHT-sensor-library

  App project setup:
    Value Display widget attached to V5
    Value Display widget attached to V6
 *************************************************************/

// 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           "TMPLxxxxxx"
#define BLYNK_DEVICE_NAME           "Device"
#define BLYNK_AUTH_TOKEN            "YourAuthToken"


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


#include <UIPEthernet.h>
#include <BlynkSimpleUIPEthernet.h>
#include <DHT.h>

char auth[] = BLYNK_AUTH_TOKEN;

#define DHTPIN 2          // What digital pin we're connected to

// Uncomment whatever type you're using!
#define DHTTYPE DHT11     // DHT 11
//#define DHTTYPE DHT22   // DHT 22, AM2302, AM2321
//#define DHTTYPE DHT21   // DHT 21, AM2301

DHT dht(DHTPIN, DHTTYPE);
BlynkTimer timer;

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendSensor()
{
  float h = dht.readHumidity();
  float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  // You can send any value at any time.
  // Please don't send more that 10 values per second.
  Blynk.virtualWrite(V5, h);
  Blynk.virtualWrite(V6, t);
}

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

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

  dht.begin();

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

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

Hey, John. Thanks for your edit suggestion. :slight_smile:

I’ve tried this Sketch you sent here, but still isn’t sending the DHT11 data to Blynk, not even keeping connection with the Arduino board and the Blynk server.

Try to use
Blynk.begin(auth, “blynk.cloud”, 80);
or
Blynk.begin(auth, IPAddress(192,168,1,100), 8080);
Instead of Blynk.begin(auth)

also try baud rate 9600 instead of 115200

no connection yet and I tried all that

Try different library version and check your connections, make sure that you are using the right pins

The connection is OK, about the used pins, alright… Different library versions didn’t work as well. The Arduino keeps doesn’t connecting to the Blynk and no sending any data. :confused:

I would recommend you to use esp32 or nodemcu instead of Arduino and wifi instead of ethernet.

1 Like

try the EthernetENC library with BlynkSimpleEthernet.h
check the dynamic memory usage. if it is too high modify the EthernetENC library settings.

1 Like

Hey, thanks for suggest, but still not working as well. It’s high the memory usage. :confused:

As I mentioned before, use esp32 and wifi.

did you change the settings?

you should call the sendSensor function to work bro.
void loop(){
sendSenor();
}

add this code from your notebook after look at this.

if still you dont get any value from sensor after delete all timers

after cut down all your sensor code

[Unformatted code removed by moderator]

it will be work %100

have fun

also you dont use pin 2 for sensor select another pin to connect sensor pin like pin4 because enj2860 use pin2 for own ethernet connection.

@svalbard Please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Copy and paste these if you can’t find the correct symbol on your keyboard.

Pete.