NRF24 to blynk

I’m trying to connect my Arduino UNO to blynk app using ENC28J60
I opened blynk LED example and it works fine
BUT when I’m changing the example to DHT11 it does not connect to the server

[0] Getting IP...
[5323] IP:
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.5.0 on Arduino Uno

[5433] Connecting to blynk - cloud . com:8442
[6576] Ready (ping: 329ms).
[11593] Connecting to blynk - cloud . com :8442
[16584] Connecting to blynk - cloud . com: 8442
[23412] Connecting to blynk - cloud . com: 8442
[29231] Connecting to blynk - cloud . com: 8442
[30354] Ready (ping: 318ms).
[35357] Connecting to blynk - cloud . com: 8442
[41181] Connecting to blynk - cloud . com: 8442
[42295] Ready (ping: 314ms).

and again connecting…or sometimes it says package is too long!
but I didn’t changed the example except token

You could try to add this at the beginning of the sketch to win 1.2k space.

#define BLYNK_NO_BUILTIN // Disable built-in analog & digital pin operations to spare flash space
#define BLYNK_NO_INFO // Skip device info to spare flash space

1 Like

Or to spare again more space ->

  Download latest Blynk library here:

  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials:
    Sketch generator: 
    Blynk community:  
    Follow us:        

  Blynk library is licensed under MIT license
  This example code is in public domain.

  For this example you need UIPEthernet library:

  Typical wiring would be:
   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.

  For this example you'll need Adafruit DHT sensor libraries:

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

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

#define BLYNK_NO_BUILTIN        // Disable built-in analog & digital pin operations to spare flash space
#define BLYNK_NO_INFO           // Skip device info to spare flash space

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

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

unsigned long lastRunTime = 0;
unsigned long currentTime = 0;
float h;
float t;

#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

//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()
  h = dht.readHumidity();
  t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
  // 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

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


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

void loop()

currentTime = millis();

  if ((currentTime - lastRunTime >= 10000) ){     //timer low-cost  
    lastRunTime = currentTime;
    Blynk.virtualWrite(V5, h);  
    Blynk.virtualWrite(V6, t);      


You are connecting… but then something is contributing to the disconnection… probably poor code :wink:

You DON’T want sensor reads or widget writes in the main void loop() but to use proper timers instead.

Paste your sketch here… properly formatted for forum viewing please… as shown here.

Blynk - FTFC

failure to provide the network details for the ENC.

Possibly… who knows… the only code here is an irrelevant (to the OP issue) posting about saving memory :stuck_out_tongue:

thanks alot for helping me
actually I’m new to blynk
DHT11 is just example for me to start
I want to use NRF24 mesh and connect all of them to the master (gateway) that is connected to the internet using ENC and bylnk to control slave NRFs which are transfering data like soil humidy and relay controling in each of them
is there any example like this? “send and recive data from nrf24 to blynk”

1 Like

Forget NRF24 until you have a basic sketch running reliably with the ENC.

1 Like

I was about to say… starts off with “can’t start my car” and followed up with “how do I fly my car to the moon” :stuck_out_tongue:

But seriously @tsunami a NRF24 mesh itself will have almost nothing to do with Blynk, so start with learning one then the other… then combine.

1 Like

I DIG IT @GunnerTechTools btw I’m trying to learn blynk first.
this is my code for displaying temp(DS18B20) and controlling a relay with button.

#define BLYNK_PRINT Serial 
#include <UIPEthernet.h>
#include <BlynkSimpleUIPEthernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>
int relay = 4;

char auth[] = "Token";
int DS18S20_Pin = 7;
OneWire ds(DS18S20_Pin);

float temperature;

void setup()


pinMode(relay, OUTPUT);


void sendUptime()
float temperature = getTemp();

Blynk.virtualWrite(0, temperature); // Virtual 0

void loop()
int temperature =getTemp(); //float is too big for sketch frowning; // Initiates Blynk
Blynk.virtualWrite(0, temperature); // Virtual 0
//; // Initiates SimpleTimer

float getTemp(){
//returns the temperature from one DS18B20 in DEG Celsius

byte data[12];
byte addr[8];

if ( ! {
//no more sensors on chain, reset search
return 100; //+100C

if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return 100; //+100C

if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return 100; //+100C



byte present = ds.reset();;
ds.write(0xBE); // Read Scratchpad

for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] =;

  pinMode(relay, INPUT);

 if (digitalRead(relay == 0))
    digitalWrite(relay, HIGH);    

     if(digitalRead(relay == 1)) {

    digitalWrite(relay, LOW);


byte MSB = data[1];
byte LSB = data[0];

float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;

return TemperatureSum;

problem is when I push button to ON/OFF relay, it just quickly ON and then OFF
how can I code to check “Button” state?
and any suggestion to save space in this code?

Still not sure what your issue is… if you want a switch, set the widget to switch mode


The code will be the same for either button or switch mode, just one immediately sends both ON then OFF states as you press and release, the other requires a separate press for each state change.

Don’t get too caught up on space yet… your sketch is nowhere near big enough to worry about :stuck_out_tongue_winking_eye:

Hmmm… although it turns out your code is all wrong :stuck_out_tongue:

Proper way of reacting to the button/switch is as follows…

BLYNK_WRITE(V1) { // This function gets called every state change of the Button Widget.
  if (param.asInt() == 1) {  // If button state is 1 (HIGH) then...
   digitalWrite(relay, HIGH);
  } else {  // If button state is 0 (LOW) then...
   digitalWrite(relay, LOW);

Pinmode goes in your void setup()

All the rest seems to be just flapping in the breeze??

For learning Arduino code… checkout the Arduino site

‘param’ was not declared in this scope :expressionless: :pensive:
what should do for this error?

when I push button to ON (in push or switch mode) the button show “ON” but relay itself is not fixed and it quickly changes the state from ON to OFF every time I set button ON.

Well, you have several problems with what code you have shown, so no doubt you will have all sorts of issues.

We are not a code factory here, but post your entire updated code (including the fixes I mentioned. And block out any personal WiFi credentials and Auth code) and perhaps someone will take a further look.

ok thanks anyway dude
maybe some related links or examples could help me to find out what I need to do insted of telling what I know!
still I couldn’t solve “param” issue

This forum is littered with hundreds of examples and full projects of code… they all follow the same syntax and contain the same type of functions and formats as required for Blynk.

And there is the Docs, Help Center and Sketch Builder links at the top of this page.

As for the param.asInt(), it is part of the fundamentals of Blynk functions, so the error is most likely due to something wrong in your code, but I can’t easily guess.or look over your shoulder to see the issue.

1 Like

Thank u @GunnerTechTools I will use examples and what u said to improve my poor codes and lern about that :blush: :kissing_heart:

I honestly had not known about the upcoming launch of the SpaceX Falcon Heavy at the time of that writing… I don’t really follow the news much :blush: … but at least now we all know there is a way :stuck_out_tongue_winking_eye:

1 Like