I am running this program on my Spark Core; basically, just copied over from here,
http://docs.spark.io/firmware/#communication-tcpserver
TCPServer webServer = TCPServer(80);
TCPClient webClient;
void setup() {
webServer.begin();
}
void loop() {
if (webClient.connected() && webClient.available()) {
serveWebpage();
}
else {
webClient = webServer.available();
}
}
void serveWebpage() {
//TODO: read in the request to see what page they want:
//TODO: retrieve larger content from flash?
webClient.println("<html>I'm serving a webpage!</html>\n\n");
webClient.flush();
webClient.stop();
delay(200);
}
Spark core is powered by a 10,000 mAh Anker battery. the input of a Charger Doctor is connected to the battery and the output connected to the Spark Core USB port. The battery indicates 3/4 capacity. The current and voltage readings from the battery tend to fluctuate from around 5.0 to 5.2V and 110 to 160mA. If I move the Core to a PC USB port, the readings remain virtually constant at 5.06V and 150mA. Spark Core is connected as indicated by breathing cyan.
The problem is that the Core periodically drops the connection when powered from either USB or by battery. The following patterns are observed on the status LED. Pattern 1 is observed rarely.
Pattern 1
blinking cyan
LED goes off several seconds (maybe more)
blinking green
a couple of blinks red
LED comes back blinking cyan
LED starts breathing cyan
Pattern 2
blinking cyan
steady cyan for several seconds or more
LED starts breathing cyan
Pattern 3
blinking cyan
LED goes off several seconds
Steady cyan for several seconds or more
led starts breathing cyan
So my question is: what could be causing this behaviour? It could be my router, but I don’t think so. I have an ASUS RT-N56U router and it is pretty rock solid for all of my other clients; VoIp ATA, Netduino Plus 2, PCs, tablets, etc. Also, power doesn’t seem to be a problem. I suspect something is wrong with the program (or, maybe the firmware).