BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Arduino mkr 1010 rimane nel setup - Troubles using Blynk.config()

arduino
#4

Scusa ma non parlo inglese .
Premetto che il programma funziona bene quando si connette al server.
La mia domanda e se posso eseguire lo sketch di arduino anche se non si connette a server di blynk.

0 Likes

#5
#define BLYNK_PRINT Serial
#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>
char auth[] = "4136235385";
char ssid[] = "Vo71";
char pass[] = "N5";
WidgetLCD blynk_lcd(V31);
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
//#include <EEPROM.h>



#define BANCONOTA5    5
#define BANCONOTA10   6
#define BANCONOTA20   7
#define BANCONOTA50   8
#define BANCONOTA100  9
#define RESET         10
int key[6] = {HIGH,HIGH,HIGH,HIGH,HIGH,HIGH};
int pin[6]= {BANCONOTA5,BANCONOTA10, BANCONOTA20, BANCONOTA50,BANCONOTA100,RESET, };
int  banconota5  = 0;
int  banconota10  = 0;
int  banconota20  = 0;
int  banconota50  = 0;
int  banconota100  = 0;

int  sommapar = 0;
int addr_c = 30;
void setup()
{
  Blynk.begin(auth, ssid, pass);
  lcd.init();
  lcd.backlight();
  lcd.setCursor(1,0);
  lcd.print("WIN GAMES");
  lcd.setCursor(0,1);
  lcd.print("TOTALI");
  blynk_lcd.clear();
  blynk_lcd.print(1, 0,sommapar );
  blynk_lcd.print(1, 1, "TOTALI1");
  blynk_lcd.clear(); 
  
 // EEPROM.get  (addr_c,sommapar); 

  for (int i= 0;i<6 ; i++)
  {
    pinMode(pin[i],INPUT_PULLUP);
  }
  Serial.begin(9600);
   Blynk.begin(auth, ssid, pass);
}

void loop() 
{
  int k;
  
  for (int i= 0;i<6 ; i++)
  {
    k = digitalRead(pin[i]);
    if ( key[i] != k ) 
    { 
      if ( key[i] == HIGH && k == LOW )
      {
        Serial.print("PIN");
        Serial.print(pin[i]);

        switch (pin[i]) 
       {
        case BANCONOTA5:
          banconota5 = banconota5 + 5;
          sommapar = banconota5 +  banconota10 + banconota20 + banconota50 + banconota100;
         // EEPROM.put(addr_c,sommapar);
          Serial.println(" BANCONOTA 5");
          break;
        case BANCONOTA10:
          banconota10 = banconota10 + 10;
         sommapar = banconota5 +  banconota10 + banconota20 + banconota50 + banconota100;
         
          Serial.println(" BANCONOTA 10");
          break;
        case BANCONOTA20:
          banconota20 = banconota20 + 20;
         sommapar = banconota5 +  banconota10 + banconota20 + banconota50 + banconota100;
          Serial.println(" BANCONOTA 20");
          break;
        case BANCONOTA50:
          banconota50 = banconota50 + 50;
          sommapar = banconota5 +  banconota10 + banconota20 + banconota50 + banconota100;
          Serial.println(" BANCONOTA 50");
          break;
        case BANCONOTA100:
          banconota100 = banconota100 + 100;
          sommapar = banconota5 +  banconota10 + banconota20 + banconota50 + banconota100;
          Serial.println(" BANCONOTA 100");
          break;
        case RESET:
        banconota5   = 0;
        banconota10  = 0;
        banconota20  = 0; 
        banconota50  = 0; 
        banconota100 = 0;
        sommapar     = 0;
          Serial.println(" AZZERAMENTO TOTALI");
          break;  
        }
        Serial.print("Totale = ");
        Serial.println(sommapar);
         blynk_lcd.print(4, 0,sommapar ); 
          blynk_lcd.print(4, 1, " TOTALI ");    
      }
      key[i] = k;
    }

  lcd.setCursor(8, 1);  
  lcd.print(sommapar); 
  }
  Blynk.run();
}
0 Likes

#6

As I said before, if you use Blynk.begin and it can’t connect to the Blynk server then your void loop will never be executed.

If you use Blynk.config and Blynk.connect then if you can’t connect to the Blynk server then the code will carry-on without being connected to Blynk and will execute your void loop.

Pete.

0 Likes

#7

come ti ha detto Pete, usa prima Blynk.config e poi Blynk.connect invece di Blynk.begin(). In questo modo non si blocca nell setup se il MKR resta senza connessione. Prova a vedere come viene usato nel link che ti ho dato io (scusa il mio italiano, pero’ sono un po arrugginito :nerd_face: )

0 Likes

#8

Grazie domani provo devo andare a lavoro buona serata.

1 Like

#9

Yes… as stated above. And here is an example…

0 Likes

#10

Grazie a tutti per i consigli ma non riesco a modificare il mio codice che ho postato
potreste cortesemente modificare il mio codice ?
Vi ringrazio anticipatamente:pleading_face:

0 Likes

#11

buona sera a tutti ho modificato il codice ma si blocca tutto errore usb

0 Likes

#12

salve con arduino mkr1010 mi sembra che la funzione Blynk.config() funziona anche se dopo qualche ora si disconnette .
Ora sto provando con arduino yun ma non funziona con Blynk.config()

0 Likes

#13

cosi si connette .

 #define BLYNK_PRINT Serial
#include <Bridge.h>
#include <BlynkSimpleYun.h>
char auth[] = "413f5b4a3a7535385"; 

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

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

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

#14

invece cosi non funziona.

#define BLYNK_PRINT Serial
#include <Bridge.h>
#include <BlynkSimpleYun.h>
char auth[] = "4136"; 

void setup()
{
 Serial.begin(9600);
     Blynk.config(auth);
     Blynk.connect();
  //Blynk.begin(auth);
  // You can also specify server:
 // Blynk.begin(auth, "blynk-cloud.com", 80);
  //Blynk.begin(auth, IPAddress(192,168,1,100), 8080);
}

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

#15

Unless someone has the same board type as you, to test your code with, all we can to is guess.

0 Likes

#16

Salve non riesco a far funzionare arduino yun con la funzione
Blynk.config()
cioè se non si connette al server continua ad eseguire lo sketck

0 Likes

#17

Please don’t create new topics when you already have a related topic going. I merged your post back here.

As stated in the Docs, Blynk.config() assumes you have ALREADY connected your device to your network by whatever means it can (not Blynk related). So figure out how that needs to be done… and the Blynk connection will follow.

0 Likes

#18

Dove posso trovare un esempio funzionante sono 2 mesi che non riesco a far funzionare
arduino in assenza di connessione .
ho provato con arduino mkr1010,arduino yun’,arduino mega con ethernet w5100
ma niente non riesco a proseguire.
Se cortesamente potreste consigliarmi uno skecth già fatto solo da copia e incolla .

0 Likes

#19

If you want to use Blynk.config() you will need to set-up your network connection manually before you call Blynk.connect().
How you do that will depend on the specific hardware (shield and Ethernet/Wi-Fi adaptor) you are using.

You will need to be clearer about EXACTLY which hardware you plant to test this with.

Pete.

0 Likes

#20

@Wingames Since you already have a topic about this, I merged them together.

This is not always possible… each type of hardware device has a different way of connecting… not to mention your networking will be different then others, etc.

Blynk.config() examples are seemingly more for WiFi connections as that is the most commonly used for IoT, but it can often be used with other methods as well… But as already referenced in this topic, for someone to assist with your particular hardware, they probably need the same hardware to test… and thus provide requested code.

1 Like

#21

Salve come già scritto ho tutti i tipi di arduino e tutti si connettono al server di Blynk
con la funzione Blynk.begin(); e riesco a settarli sia wifi che con ethernet
ma come modifico il codice con Blynk.config(); seguito da Blynk.connect();
resta bloccato nel setup.
In questo forum come posso postare il codice corretamente ?

0 Likes

#22

And again we answer… this depends on your hardware…

For example with WiFi you need to set that up first…

  WiFi.begin(ssid, pass);  // This sets up the WiFi network
  Blynk.config(auth, server, port);  //  This sets up Blynk - Non-blocking if no WiFi available
  Blynk.connect();  // This attempts to connect to the Server - Non-blocking if no WiFi available

Find out how to connect your hardware to the network first, then follow up with Blynk.config() and Blynk.connect()

0 Likes

#23

The process is:

  • Add the necessary libraries to allow your hardware to connect to the internet (these will vary depending on your hardware and connection method)
  • Set-up a connection to the internet (this will vary depending on your hardware, whether you are a using static or DHCP allocated IP address, whether your devices requires a MAC address to be specified etc.)
  • Define your Blynk connection credentials in Blynk.config()
  • Connect to Blynk using Blynk.connect()

After you’ve set-up the internet connection you should be able to ping the device and use the device to ping external IP addresses. You should also be able to see the device in your router admin screen.

Rather than saying “I have lots of devices, lots of connection methods, and have tried lots of code”, I would suggest that you focus on one device, one connection method and share the details and the code you’ve tried, along with any useful information such as serial monitor output, ping results etc.

Pete.

1 Like