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

MKR1000 and wifi hotspot

Hi dear Blynk users,

I have the following problem and don’t find any answers. When I connect the MKR1000 to my home network there is no problem at all. It stays online like it should be. But when I connect to a hotspot like my iPhone or my Mifi Huawei 4G router, it will connect but that’s it. It keep giving the following errors ;

20:00:24.472 -> [1713] IP: 192.168.8.104
20:00:24.472 -> [1713]
20:00:24.472 -> ___ __ __
20:00:24.472 -> / _ )/ /_ _____ / /__
20:00:24.472 -> / _ / / // / _ / '/
20:00:24.472 -> /
//_, /////_
20:00:24.472 -> /
__/ v0.6.1 on MKR1000
20:00:24.472 ->
20:00:24.472 -> [1714] Connecting to blynk-cloud.com:80
20:00:27.846 -> [5073] Login timeout
20:00:29.837 -> [7073] Connecting to blynk-cloud.com:80
20:00:49.836 -> [27078] Connecting to blynk-cloud.com:80
20:01:09.866 -> [47085] Connecting to blynk-cloud.com:80
20:01:29.834 -> [67092] Connecting to blynk-cloud.com:80

The sketch I use is from the Blynk Example with the DHT22
/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  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: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

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

 *************************************************************

  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
 *************************************************************/

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


#include <SPI.h>
#include <WiFi101.h>
#include <BlynkSimpleWiFiShield101.h>
#include <DHT.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

#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)) {
    SerialUSB.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
  SerialUSB.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, 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();
}

The strange part is that I have an identical setup with an Arduino Uno and ESP8266 ESP01 module, witch connect without any problem to the Wifi hotspot (iPhone and Huawei Mifi router). So my question is

  1. What can cause this ?
  2. Can it be solved ?
  3. How do I solve it ?

Many thanks in advance for the help (if possible)

Keep it safe !

Den Door.

@dendoor 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:
```

Pete.

Done :wink:

Update after hours of searching => If I turn off the WLAN security on the Wifi router, so no WEP WPA or WPA2 then it connects and work, but I have no security anymore, and this with a Blynk sketch. If I don’t use any Blynk Sketch, just test if I can make a secure connection then it connects, even with WPA/WPA2.

#include <SPI.h>
#include <WiFi101.h>

#include "arduino_secrets.h" 
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = "bla bla bal";   //SECRET_SSID;        // your network SSID (name)
char pass[] = "bla bla bla";    // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;     // the WiFi radio's status

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  // attempt to connect to WiFi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }

  // you're connected now, so print out the data:
  Serial.print("You're connected to the network");
  printCurrentNet();
  printWiFiData();

}

void loop() {
  // check the network connection once every 10 seconds:
  delay(10000);
  printCurrentNet();
}

void printWiFiData() {
  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
  Serial.println(ip);

  // print your MAC address:
  byte mac[6];
  WiFi.macAddress(mac);
  Serial.print("MAC address: ");
  printMacAddress(mac);

}

void printCurrentNet() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print the MAC address of the router you're attached to:
  byte bssid[6];
  WiFi.BSSID(bssid);
  Serial.print("BSSID: ");
  printMacAddress(bssid);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.println(rssi);

  // print the encryption type:
  byte encryption = WiFi.encryptionType();
  Serial.print("Encryption Type:");
  Serial.println(encryption, HEX);
  Serial.println();
}

void printMacAddress(byte mac[]) {
  for (int i = 5; i >= 0; i--) {
    if (mac[i] < 16) {
      Serial.print("0");
    }
    Serial.print(mac[i], HEX);
    if (i > 0) {
      Serial.print(":");
    }
  }
  Serial.println();
}

So with this sketch I can connect to the secured MiFi router and it works.

Now I guess that it’s something to do with de Blynk library’s. The moment I try a sketch with a Blynk commando it stops working. I have no solution for this problem. All my other devices can connect without any problem, even the UNO with the ESP822 ESP-01 module. Is it the software or the hardware from the MKR1000 I don’t know, but it really sucks…

If there is no solution, I have to try other boards who will work without these problems and sell the MKR1000 boards :frowning:

Why don’t you simply use Blynk.config and Blynk.begin to establish the connection to the Blynk server once you’ve established the connection to your WiFi hotspot?..

When you’re testing this approach, don’t have this delay in your void loop otherwise you’ll get constant Blynk disconnections…

If you feel the need to call printCurrentNet() on a regular basis then put it in its own function and call that function with a BlynkTimer.#

Pete.

OK, next test to get the time from a server

/*
  MKR1000 - MKR WiFi 1010 - MKR VIDOR 4000 WiFi RTC

  This sketch asks NTP for the Linux epoch and sets the internal Arduino MKR1000's RTC accordingly.

  created 08 Jan 2016
  by Arturo Guadalupi <a.guadalupi@arduino.cc>

  modified 26 Sept 2018

  http://arduino.cc/en/Tutorial/WiFiRTC
  This code is in the public domain.
*/

#include <SPI.h>
#include <WiFi101.h>
//#include <WiFiNINA.h> //Include this instead of WiFi101.h as needed
#include <WiFiUdp.h>
#include <RTCZero.h>

RTCZero rtc;

#include "arduino_secrets.h" 
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;                           // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

const int GMT = 2; //change this to adapt it to your time zone

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

  // check if the WiFi module works
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while (true);
  }

  // attempt to connect to WiFi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }

  // you're connected now, so print out the status:
  printWiFiStatus();

  rtc.begin();

  unsigned long epoch;
  int numberOfTries = 0, maxTries = 6;
  do {
    epoch = WiFi.getTime();
    numberOfTries++;
  }
  while ((epoch == 0) && (numberOfTries < maxTries));

  if (numberOfTries == maxTries) {
    Serial.print("NTP unreachable!!");
    while (1);
  }
  else {
    Serial.print("Epoch received: ");
    Serial.println(epoch);
    rtc.setEpoch(epoch);

    Serial.println();
  }
}

void loop() {
  printDate();
  printTime();
  Serial.println();
  delay(1000);
}

void printTime()
{
  print2digits(rtc.getHours() + GMT);
  Serial.print(":");
  print2digits(rtc.getMinutes());
  Serial.print(":");
  print2digits(rtc.getSeconds());
  Serial.println();
}

void printDate()
{
  Serial.print(rtc.getDay());
  Serial.print("/");
  Serial.print(rtc.getMonth());
  Serial.print("/");
  Serial.print(rtc.getYear());

  Serial.print(" ");
}


void printWiFiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

void print2digits(int number) {
  if (number < 10) {
    Serial.print("0");
  }
  Serial.print(number);
}

This goos perfect with the MKR1000 and de MiFi hotspot

result was =>

6:21:17.461 -> SSID: HUAWEI-0E6B-2.4G_Guest
16:21:17.461 -> IP Address: 192.168.8.103
16:21:17.461 -> signal strength (RSSI):-43 dBm
16:21:17.495 -> Epoch received: 1596378076
16:21:17.495 ->
16:21:17.495 -> 2/8/20 16:21:16
16:21:17.529 ->
16:21:18.545 -> 2/8/20 16:21:17
16:21:18.545 ->
16:21:19.563 -> 2/8/20 16:21:18
16:21:19.597 ->
16:21:20.584 -> 2/8/20 16:21:19
16:21:20.621 ->
16:21:21.622 -> 2/8/20 16:21:20
16:21:21.656 ->
16:21:22.653 -> 2/8/20 16:21:21
16:21:22.691 ->

The security on the MiFi router was WPA2/PSK. The MKR1000 connect without any problem.
So i am pretty sure it has to be something with the Blynk library’s for the Wifi101.h and the MKR1000.

It works on other servers, but NOT with Blynk servers.
I am afraid it’s game over with Blynk for my MKR1000’s en MiFi router :unamused:

Greetings !

If a try to use the Blynk sketch the misery starts again, even with the same login credentials on the MiFi router

[4119] Login timeout
16:42:45.808 -> [6119] Connecting to blynk-cloud.com:80

and keeps on going…

/*************************************************************
  Download latest Blynk library here:
    https://github.com/blynkkk/blynk-library/releases/latest

  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: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

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

 *************************************************************

  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
 *************************************************************/

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


#include <SPI.h>
#include <WiFi101.h>
#include <BlynkSimpleWiFiShield101.h>
#include <DHT.h>

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

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "HUAWEI";
char pass[] = "blablablabla";

#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)) {
    SerialUSB.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
  SerialUSB.begin(9600);

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, 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();
}

So you aren’t interested in trying my suggestion then?

Pete.

Hi Pete,

I be very intrest, but I am afraid my knowledge isn’t. What do you suggest and how do I do it ?

Why don’t you simply use Blynk.config and Blynk.begin to establish the connection to the Blynk server once you’ve established the connection to your WiFi hotspot?..

I can’t find any documentation how to use it. How do I use the config ? What to fill in in the config ?

Many thanks !

I provided you with a link to the documentation.
If you can’t be bothered to follow that link and read what it says, or do a search of the forum and read the numerous posts on the use of Blynk.config and Blynk.connect; then I’d agree that selling your MKR1000’s is probably your best option.

Pete.

Thanks for the answer Pete, I will look at the documentation and try to figure it out. But the main problem is that it is not working from the standard Blynk Examples. This is very frustrating for new users like me who get there first steps into IoT. If it should work out of the box with no problems it would be much beter for everyone, especially the beginners, and would not be so frustrating for hours of searching en testing, even to a time that people will give up.

Greetings !

21:00:02.321 -> [5003] Connecting to blynk-cloud.com:8080
21:00:06.832 -> [9508] Connecting to HUAWEI-0E6B-2.4G_Guest
21:00:07.007 -> [9703] IP: 192.168.8.103
21:00:07.007 -> [9703]
21:00:07.007 -> ___ __ __
21:00:07.007 -> / _ )/ /_ _____ / /__
21:00:07.007 -> / _ / / // / _ / '/
21:00:07.007 -> /
//_, /////_
21:00:07.007 -> /
__/ v0.6.1 on MKR1000
21:00:07.007 ->
21:00:07.007 -> [9704] Connecting to blynk-cloud.com:80
21:00:10.423 -> [13097] Login timeout
21:00:12.419 -> [15097] Connecting to blynk-cloud.com:80
21:00:32.420 -> [35099] Connecting to blynk-cloud.com:80

The result from using Blynk.config

void setup()
{
  // Debug console
  SerialUSB.begin(9600);
  Blynk.config(auth, "blynk-cloud.com", 8080);
  Blynk.connect();

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

Do I have to use Blynk.begin ? If not, where do I put in the SSID and the Pass ?

It does work out of the box for most users, and my guess is that there is something peculiar about your MiFi/iPhone hotspot that doesn’t work with the standard examples.
The MKR1000 isn’t the mainstream hardware used by the majority of Blynk users, if you’re an IoT beginner then hardware like ESP8266 based NodeMCUs or ESP32’s would be a better (and cheaper) starting point.

Pete.

I started with a UNO and did some projects what was fun but I wanted more and was looking for something that I could use with Wifi to monitor some systems when I am not at home. When I was searching for Wifi possibilities I came on the MKR1000, Why ? It looked for me the most ideal solution because many features like the LiPo connection, Wifi onboard, small and strong. Also all in one, so no hassle with connections between the boards etc…

I have a MKR1000 running on my home network without any problems even with a Blynk sketch. So I bought me a second one (because of the features) to monitor the environment in my camper. To do that I would use the same sensors (smoke, temp, PIR, etc…) and the possibility to monitor it on my phone when I am gone and the camper is left alone. So I bought a MiFi router to connect the MKR1000 in the camper. Not knowing that I would run on this problems. It should be a great project, because it’s fail proof ( connection over 4G, both on battery power). That was the reason I bought a second one.

The strange thing is that all my wifi equipment like iPads, iPhone’s, Chromecasts, computers, light systems etc can connect with the MiFi router, and work without any problem on WPA/WPA2 security.

Both MKR1000’s don’t. They connect (I can see that in the MiFi router configuration) and stay connected but refuse to connect to the Blynk servers. First I have a login time-out and the never ending loop Connecting to blynk-cloud.com:80.

And that is what’s frustrating me Pete. I know it CAN work, but it don’t.

I’m going to do so.

Blynk.config(auth2,"blynk-cloud.com", 8080);
      WiFi.begin(ssid,pass);
      Blynk.connect();

I have Arduino mkr wifi 1010.

Thanks for the tip, but same result for me

19:32:40.626 -> [4057] Login timeout
19:32:42.644 -> [6057] Connecting to blynk-cloud.com:8080
19:33:07.628 -> [31059] Connecting to blynk-cloud.com:8080

The strange thing is that it works with a ESP8266 ESP-01 module, and NOT with the MKR1000 board. Same MiFi point, same login…

Hello everyone,

after some serious problems with my project, the MKR1000 and the Huawei MiFi router, I decided to by a new MiFi router, the Netgear Nighthawk M1. A lot more expensive but it was worth the risk. Setup the new router, connected my project to the 4G Nighthawk, same settings in the sketch as before and BINGO ! Project is running without any problems, delays etc. So it was clearly a fault in the Huawei router. What or why, I could’t say it. Checked al the settings, reset it to factory defaults tried again (x10), but still the same miserie. Now with the Nighthawk it runs like a train, so I can finish my project for the camper.

So Pete, at the end you are right :100:
“my guess is that there is something peculiar about your MiFi/iPhone hotspot that doesn’t work”

I am sorry for the many posts about it, but I was very confused why I get those problems and why it didn’t work. So the Huawei is a great 4G router but not for IoT project (with the MKR1000).

Greetings !

1 Like