// send all AI void setup() { Serial.begin(9600); } String readTime = ""; long acttime = 0; long lasttime = 0; long sendfrq = 5000; // millisec int channels = 6; //_____________________________________________________________ void maketime() { int days = 0; int hours = 0; int minutes = 0; int seconds = 0; long workm = acttime / 1000; days = workm/60/60/24; hours = (workm - days*60*60*24)/60/60; minutes = (workm - days*60*60*24 - hours*60*60)/60; seconds = workm - days*60*60*24 - hours*60*60 - minutes*60; readTime = "2016-04-"; days += 15; // kll dirty for test only later use RTC readTime += days; readTime += " "; readTime += hours; readTime += ":"; readTime += minutes; readTime += ":"; readTime += seconds; } //_____________________________________________________________ void loop() { // form a JSON-formatted string like: // {"time":"10:30:00","A0":"669","A1":"0","A2":"1021","A3":"686","A4":"1018","A5":"1018"} acttime = millis(); if ( acttime - lasttime > sendfrq ) { lasttime = acttime; maketime(); /* that is the named list style String jsonString = "{\"time\":\""; jsonString += readTime; for ( int i=0; i<6; i++ ) { jsonString += "\",\"A"; jsonString += i; jsonString += "\":\""; jsonString += analogRead(i); } // end loop over Ains jsonString +="\"}"; */ String jsonString = ""; jsonString += "{\"CHANNELS\":"; jsonString += channels; jsonString += ",\"TIME\":\""; jsonString += readTime; jsonString += "\",\"AIN\":["; for ( int i=0; i