Example #1
0
/**
 * @breaf read the temperature on analog pins (10K termistor) and send sms with
 * teaded temperature
 *
 * @param smsc_nr: sms center number
 * 		  nrtel: number hu recive sms
 */
static void StareTMP(char *smsc_nr, char *nrtel)
{
	char mesage[64];
	char buffer[18];
	char tmpe[32];
	memset(mesage, 0, sizeof(mesage));
	memset(buffer, 0, sizeof(buffer));
	memset(tmpe, 0, sizeof(tmpe));
	int tmp, tmp1, tmp2;

	tmp = Thermistor(PC0);
	_delay_ms(30);
	tmp1 = Thermistor(PC0);
	_delay_ms(30);
	tmp2 = Thermistor(PC0);
	tmp = (tmp + tmp1 + tmp2) / 3;

	ReadEprom(buffer, 288); //18 * 16
	if (strlen(buffer) != 0)
	{
		sprintf(tmpe, "%s: %d %s", buffer, tmp, "C\r\n");
		strcat(mesage, tmpe);
	}

	tmp = Thermistor(PC1);
	_delay_ms(30);
	tmp1 = Thermistor(PC1);
	_delay_ms(30);
	tmp2 = Thermistor(PC1);
	tmp = (tmp + tmp1 + tmp2) / 3;

	ReadEprom(buffer, 306); //18 * 17
	if (strlen(buffer) != 0)
	{
		sprintf(tmpe, "%s: %d %s", buffer, tmp, "C\r\n");
		strcat(mesage, tmpe);
	}

	tmp = Thermistor(PC2);
	_delay_ms(30);
	tmp1 = Thermistor(PC2);
	_delay_ms(30);
	tmp2 = Thermistor(PC2);
	tmp = (tmp + tmp1 + tmp2) / 3;

	ReadEprom(buffer, 324); //18 * 18
	if (strlen(buffer) != 0)
	{
		sprintf(tmpe, "%s: %d %c", buffer, tmp, 'C');
		strcat(mesage, tmpe);
	}
	if (strlen(mesage) != 0)
		uart_sendsms(smsc_nr, nrtel, mesage);

}
Example #2
0
void StareTMP(char *nrtel)
{
	char mesage[120];
	char buffer[18];
	char tmpe[32];
	int tmp, tmp1, tmp2;

	tmp = Thermistor(PC0);
	delay(10);
	tmp1 = Thermistor(PC0);
	delay(10);
	tmp2 = Thermistor(PC0);
	tmp = (tmp + tmp1 + tmp2) / 3;

	ReadEprom(buffer, 18 * 18);
	if (strlen(buffer) != 0)
	{
		sprintf(tmpe, " %s: %d %s", buffer, tmp, "C\r\n");
		strcat(mesage, tmpe);
	}

	tmp = Thermistor(PC1);
	delay(10);
	tmp1 = Thermistor(PC1);
	delay(10);
	tmp2 = Thermistor(PC1);
	tmp = (tmp + tmp1 + tmp2) / 3;

	ReadEprom(buffer, 18 * 19);
	if (strlen(buffer) != 0)
	{
		sprintf(tmpe, " %s: %d %s", buffer, tmp, "C\r\n");
		strcat(mesage, tmpe);
	}

	tmp = Thermistor(PC2);
	delay(10);
	tmp1 = Thermistor(PC2);
	delay(10);
	tmp2 = Thermistor(PC2);
	tmp = (tmp + tmp1 + tmp2) / 3;

	ReadEprom(buffer, 18 * 20);
	if (strlen(buffer) != 0)
	{
		sprintf(tmpe, " %s: %d %c", buffer, tmp, 'C');
		strcat(mesage, tmpe);
	}
	if (strlen(mesage) != 0)
		SendSms(nrtel, mesage);

}
void sendSensorsDataXML() {
    /* Send the header directly with print */
    wifly.println(F("HTTP/1.1 200 OK"));
    wifly.println(F("Content-Type: text/xml"));
    wifly.println(F("Transfer-Encoding: chunked"));
    wifly.println();

    /* Send the body using the chunked protocol so the client knows when
     * the message is finished.
     */
    wifly.sendChunkln(F("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
    wifly.sendChunkln(F("<datacollector>"));

	snprintf_P(wbuf, sizeof(wbuf), PSTR("<dcid>%s</dcid>"), macaddr);
    wifly.sendChunkln(wbuf);

    wifly.sendChunkln(F("<geoloc>"));
	int ind;

	char scanbufcpy[500];
	strncpy(scanbufcpy, scanbuf, 500);


	char *ap, *oap;
	char *apdesctok, *apdesc;
	ap = strtok_r(scanbufcpy, "|", &oap);
	while(ap != NULL) {

    	wifly.sendChunkln(F("<ap>"));
		
		ind = 0;
		apdesctok = strtok_r(ap, " ", &apdesc);	
		while(apdesctok != NULL) {
			ind++;
			switch(ind) {
				case 3:
					snprintf_P(wbuf, sizeof(wbuf), PSTR("<channel>%s</channel>"), apdesctok);
    				wifly.sendChunkln(wbuf);
					break;
				case 4:
					snprintf_P(wbuf, sizeof(wbuf), PSTR("<rssi>%s</rssi>"), apdesctok);
    				wifly.sendChunkln(wbuf);
					break;
				case 6:
					snprintf_P(wbuf, sizeof(wbuf), PSTR("<mac>%s</mac>"), apdesctok);
    				wifly.sendChunkln(wbuf);
					break;
				default:
					;
			}
			apdesctok = strtok_r(NULL, " ", &apdesc);	
		}

    	wifly.sendChunkln(F("</ap>"));
		
		//Serial.println();
		ap = strtok_r(NULL, "|", &oap);
	}
    wifly.sendChunkln(F("</geoloc>"));

    wifly.sendChunkln(F("<sensors>"));

    /* Include readings from Analog pins */
	dtostrf(Thermistor(analogRead(ThermistorPIN)), 5,2, convbuf);
    snprintf_P(wbuf, sizeof(wbuf), PSTR("<sensor><type>temp</type><value>%s</value></sensor>"), convbuf);
#ifdef DEBUG
    Serial.println(wbuf);
#endif
    wifly.sendChunkln(wbuf);

	dtostrf(Photoresistor(analogRead(PhotoresistorPIN)), 5,2, convbuf);
    snprintf_P(wbuf, sizeof(wbuf), PSTR("<sensor><type>light</type><value>%s</value></sensor>"), convbuf);
#ifdef DEBUG
    Serial.println(wbuf);
#endif
    wifly.sendChunkln(wbuf);
    
	sprintf(convbuf,"NA");
	snprintf_P(wbuf, sizeof(wbuf), PSTR("<sensor><type>humidity</type><value>%s</value></sensor>"), convbuf);
#ifdef DEBUG
    Serial.println(wbuf);
#endif
    wifly.sendChunkln(wbuf);
	
	sprintf(convbuf,"NA");
	snprintf_P(wbuf, sizeof(wbuf), PSTR("<sensor><type>pressure</type><value>%s</value></sensor>"), convbuf);
#ifdef DEBUG
    Serial.println(wbuf);
#endif
    wifly.sendChunkln(wbuf);

    wifly.sendChunkln(F("</sensors>"));
    wifly.sendChunkln(F("</datacollector>"));
    wifly.sendChunkln();

}
Example #4
0
void sendSensorValues(){
    
    // Using the following protocol defined by Francis Papineau in conjunction with Thai Nguyen:
    
    //  -> "!Lig:00.00Tem:00.00ECG:00.00POT:00.00BAT:00.00IRL:00.00LOW:00.00RES:00.00ArT:00.00\n"
    
    // The system then reads values to send via the Serial port defined.
    
    // The header for the receiving end of the Serial Network
    HOSTXbee.print("!");
    
    // The Light value
    HOSTXbee.print("Lig:");
    tempLight = analogRead(Light);
    HOSTXbee.print(tempLight);
    
    // The tympanic temperature
    HOSTXbee.print("Tem:");
    temp = getTermocoupleValue();
    HOSTXbee.print(temp);
    
    // The ECG Voltage Level
    HOSTXbee.print("ECG:");
    tempECG = analogRead(ECG);
    HOSTXbee.print(tempECG);
    
    // The SPO2 Base Measurement using Red Light (approx. 620nm)
    // The measurment is done between a flikr of the LED
    HOSTXbee.print("POT:");
    
    // LED ON
    digitalWrite(redLED, HIGH);
    tempRed = pulseIn(PulseOx, HIGH);
    HOSTXbee.print(tempRed);
    
    // LED OFF
    digitalWrite(redLED, LOW);
    
    // The Battery Voltage Level
    HOSTXbee.print("BAT:");
    tempBat = analogRead(Battery);
    HOSTXbee.print(tempBat);
    
    // The SPO2 Measurment using IR Light (approx. 960nm)
    // The measurment is done between a flikr of the LED
    HOSTXbee.print("IRL:");
    
    // LED ON
    digitalWrite(irLED, HIGH);
    tempIr = pulseIn(PulseOx, HIGH);
    HOSTXbee.print(tempIr);
    
    // LED OFF
    digitalWrite(irLED, LOW);
    
    // The SPO2 Measurement using Ambient Light
    // -> this is used in a proprietary algorithm to cancel
    // the effect of ambient light in the SPO2 measurement
    HOSTXbee.print("LOW:");
    tempError = pulseIn(PulseOx, HIGH);
    HOSTXbee.print(tempError);
    
    // The Respiration sensor measurments
    HOSTXbee.print("RES:");
    tempRESP = analogRead(Resp);
    HOSTXbee.print(tempRESP);
    
    // The Ambient Temperature Reading
    HOSTXbee.print("ArT:");
    AmbientTemp = Thermistor(analogRead(AmbTemp));
    HOSTXbee.print(AmbientTemp);
    
    // The Checksum Character.
    HOSTXbee.print("\n");
    
    // Make sure the signals got sent
    delay(10);
    
}