Sparkcore interferes with my usb wifi modem

I guess I’m at a loss as to why your Spark Core may be affecting your specific WiFi modem/hotspot device. Were you just running Tinker on the Spark Core when this happened? I would suspect on the b/g/n mixed mode. dedicated n won’t work.

Try this code and open a serial terminal and press W to connect your Core to WiFi and see if it resets your router on just that command alone. You can then also play with other commands… C to connect to the Spark Cloud. Then T to do some TCP Client file downloading. t to stop downloading. Disconnect from WiFi with w

#include "application.h"

SYSTEM_MODE(MANUAL);

void tcp_connect();
int f(String s);

TCPClient client;

bool doNotProcessMain = true;
uint32_t t = 0;
uint32_t t2 = 0;

void setup()
{
  // Make sure your Serial Terminal app is closed before powering your Core
  Serial.begin(9600);

  Spark.function("f", f);

  Spark.connect();
  while(!Spark.connected()) {
    Spark.process();
    SPARK_WLAN_Loop();
  }

  pinMode(D7,OUTPUT);
}

void loop()
{
  doNotProcessMain = true;
  while(doNotProcessMain) {
    if (Serial.available()) {
      int c = Serial.read();
      switch (c) {
        case 'C': Spark.connect(); break;
        case 'c': Spark.disconnect(); break;
        case 'W': WiFi.connect(); break;
        case 'w': WiFi.disconnect(); break;
        case 'T': tcp_connect(); break;
        case 't': client.stop(); break;
        case 'O': WiFi.on(); break;
        case 'o': WiFi.off(); break;
        case 'L': WiFi.listen(); break;
        case 'x': 
          if(Spark.connected()) Serial.println("Connected"); 
          else Serial.println("Not Connected"); 
          break;
        case 'm': doNotProcessMain = false; break;
        case 's': SPARK_WLAN_Loop(); break;
        case 'p': Spark.process(); break;
      }
    }

    if (client.available())
    {
      char c = client.read();
      Serial.print(c);
    }

    // Blink the D7 LED so we can see when user code is running
    if(Spark.connected()) {
      if (millis() - t2 > 50) {
        t2 = millis();
        digitalWrite(D7, !digitalRead(D7));
      }
    }
    else 
    {
      if (millis() - t2 > 200) {
        t2 = millis();
        digitalWrite(D7, !digitalRead(D7));
      }
    }

    if (millis() - t > 1000) {
      if(Spark.connected()) {
        Serial.println("calling Spark.process()");
        Spark.process();
      }
      t = millis();
    }
  }
}

void tcp_connect() {
  Serial.println("connecting...");

  if (client.connect("www.textfiles.com", 80))
  {
    Serial.println("connected");
    client.println("GET /100/ad.txt HTTP/1.0");
    client.println("Host: www.textfiles.com");
    client.println("Content-Length: 0");
    client.println();
  }
  else
  {
    Serial.println("connection failed");
  }
}

int f(String s) {
  Serial.println("Spark.function running");
  Serial.println(s);
  return 0;
}
1 Like