Here's the draw loop of my program. The call to capacitiveSensor is using this library Arduino Playground - HomePage
void loop() {
long capacitance = cs_4_2.capacitiveSensor(30);
capacitances[capacitancesIndex++] = capacitance;
Serial.println(capacitance);
if (capacitancesIndex < 20) {
delay(200);
} else {
capacitancesIndex = 0;
sendToServer();
}
}
The sendToServer
method first makes sure that the Wi-Fi shield is still connected to the network (and reconnects if it is not) and then tries to send the array of integer values read over HTTP to my server. That's not working so I have put in lots of Serial.println
to diagnose what is happening.
String httpMssg = "GET /default.aspx?store=[{name:\"";
Serial.println(httpMssg);
httpMssg = httpMssg + plateName;
Serial.println(httpMssg);
httpMssg = httpMssg + "\",values=[";
Serial.println(httpMssg);
for(int i = 0; i < 19; i++) {
httpMssg = httpMssg + capacitances[i] + ",";
Serial.println(httpMssg);
}
httpMssg = httpMssg + capacitances[19] + "]}] HTTP/1.1";
Serial.println(httpMssg);
In the first run my array of capacitance values is [0, 31, 33, 0, 77, 70, 39, 47, 57, 23, 17, 61, 0, 88, 84, 62, 63, 98, 4, 42] and so the results of all those println calls that I expect to see is:
GET /default.aspx?store=[{name:"
GET /default.aspx?store=[{name:"DefaultPlate
GET /default.aspx?store=[{name:"DefaultPlate",values=[
GET /default.aspx?store=[{name:"DefaultPlate",values=[0,
[...]
GET /default.aspx?store=[{name:"DefaultPlate",values=[0,31,33,0,77,70,39,47,57,23,17,61,0,88,84,62,63,98,4,42]}] HTTP/1.1
But what I actually see is
(N.B. I cannot it paste from the serial monitor, some of it is unpastable bytes.) It looks like I have multiple threads writing at once, is that the case? Where are thy coming from? Is 'loop' called by more than one thread? I am stumped; any help gratefully received.