customized email alerts
in
Integration and Hardware
•
1 year ago
Hi guys
I am newbie at arduino. I am working with Arduino Uno (EtherTen) and SHT15 (temperature and humidity sensor).
I have got the sensor working, also got the sensor sending email alert but the email alert is not sending the preferred values. The sensor is communicating via the serial port. I am using Windows XP machine.
Below are the bits of code used.
****************************************************************************************************************************************
****************************************************************************************************************************************
#include <SHT1x.h>
// Specify data and clock connections and instantiate SHT1x object
#define dataPin 10
#define clockPin 11
SHT1x sht1x(dataPin, clockPin);
void setup()
{
Serial.begin(38400); // Open serial connection to report values to host
Serial.println("Starting up");
}
void loop()
{
float temp_c;
float temp_f;
float humidity;
// Read values from the sensor
temp_c = sht1x.readTemperatureC();
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();
// Print the values to the serial port
Serial.print("Temperature: ");
Serial.print(temp_c, DEC);
Serial.print("C / ");
Serial.print(temp_f, DEC);
Serial.print("F. Humidity: ");
Serial.print(humidity);
Serial.println("%");
delay(2000);
}
****************************************************************************************************************************************
****************************************************************************************************************************************
****************************************************************************************************************************************
****************************************************************************************************************************************
import processing.serial.*;
import javax.mail.*;
import javax.mail.internet.*;
int val=0;
Serial myPort; // The serial port object
void setup() {
size(200,200);
println(Serial.list());
myPort = new Serial(this, Serial.list()[1], 38400);
// Function to check mail
//checkMail();
// Function to send mail
//sendMail();
//noLoop();
}
void draw() {
//Set the background
// background(val);
}
//Called whenever there is something available to read
void serialEvent(Serial port) {
val = port.read();
// For debugging
println( "Raw Input:" + val);
if (val == 10)
{
sendMail();
val=0;
}
}
****************************************************************************************************************************************
****************************************************************************************************************************************
Please advice on how to change the sensed values which are "float" to a string, separate the values required put them into different variables and then compare with set threshold values (using if loops), to send out various alerts.
Is this the simplest way to approach this project? If any one has done something similar, please point me in the right direction, that should be of huge help :)
1