Ciao a tutti, e buon anno!
Vorrei poter mandare una mail riportando i valori dei miei sensori.
Per il momento riesco a mandare la mail ma non capisco come dirli di mandare il valore dei sensori?
Per ora mi manda solamente quello che scrivo in "SendEmailChoreo.addInput"
Il mio sketch è
#include <DHT.h> //For DHT22 & AM2302 library
#include <OneWire.h> //For DS18B20
#include <LiquidCrystal.h>
#include <Bridge.h>
#include <HttpClient.h>
//**********************GMAIL****************************************************\\
#include <Temboo.h>
#define TEMBOO_ACCOUNT "aaaaaa" // your Temboo account name \
#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name\
#define TEMBOO_APP_KEY "aaaaaaaaaa" // your Temboo app key}
const String GMAIL_USER_NAME = "aaaaaaaaa@gmail.com";
const String GMAIL_PASSWORD = "aaaaaaaaa";
const String TO_EMAIL_ADDRESS = "aaaaaaaa@gmail.com";
boolean success = false; // a flag to indicate whether we've sent the email yet or not
//*******************************************************************************\\
#define DHTPIN 3 //DHT22
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
float h = 0;
float t = 0;
const byte DS18B20_Pin = 4; //DS18B20 Signal pin on digital 4
OneWire ds(DS18B20_Pin); // on digital pin 4
int Calc; //Sensore flusso
volatile int NbTopsFan; //measuring the rising edges of the signal
int hallsensor; //The pin location of the sensor is 2 (int0 on Yun = Pin 2)
void rpm () //This is the function that the interupt calls
{
NbTopsFan++; //This function measures the rising and falling
//edge of the hall effect sensors signal
}
unsigned long ora = 0;
unsigned long ultimaEsecuzione = 0;
long intervalloEsecuzione = 10000;
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup()
{
pinMode(6, OUTPUT); //LED ROSSO ds18b20
// ***For Flow sensor*****************************************
pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
attachInterrupt(1, rpm, RISING); //and the interrupt is attached
// ***********************************************************
// Bridge takes about two seconds to start up
// it can be helpful to use the on-board LED
// as an indicator for when it has initialized
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
Serial.begin(9600);
lcd.begin(16, 2);
dht.begin(); //DHT22
//while (!Serial); // wait for a serial connection
}
void loop()
{
ora = millis();
dht22();
ds18b20();
//flusso();
gmail();
//emoncms();
//emoncms_async();
//delay(1000); //just to slow down the output it's easier to read
}
void gmail()
{
// only try to send the email if we haven't already sent it successfully
if (!success) {
Serial.println("Running SendAnEmail...");
TembooChoreo SendEmailChoreo;
// invoke the Temboo client
// NOTE that the client must be reinvoked, and repopulated with
// appropriate arguments, each time its run() method is called.
SendEmailChoreo.begin();
// set Temboo account credentials
SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);
// identify the Temboo Library choreo to run (Google > Gmail > SendEmail)
SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");
// set the required choreo inputs
// see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/
// for complete details about the inputs for this Choreo
// the first input is your Gmail email address
SendEmailChoreo.addInput("Username", GMAIL_USER_NAME);
// next is your Gmail password.
SendEmailChoreo.addInput("Password", GMAIL_PASSWORD);
// who to send the email to
SendEmailChoreo.addInput("ToAddress", TO_EMAIL_ADDRESS);
// then a subject line
SendEmailChoreo.addInput("Subject", "Stato");
// next comes the message body, the main content of the email
SendEmailChoreo.addInput("MessageBody", "Ciao, come va oggi");
// tell the Choreo to run and wait for the results. The
// return code (returnCode) will tell us whether the Temboo client
// was able to send our request to the Temboo servers
unsigned int returnCode = SendEmailChoreo.run();
// a return code of zero (0) means everything worked
if (returnCode == 0) {
Serial.println("Success! Email sent!");
success = true;
} else {
// a non-zero return code means there was an error
// read and print the error message
while (SendEmailChoreo.available()) {
char c = SendEmailChoreo.read();
Serial.print(c);
}
}
SendEmailChoreo.close();
// do nothing for the next 60 seconds
delay(60000);
}
}
Uso temboo perché ho trovato uno sketch che mi sembrava alla mia portata allora ho provato.
Funziona, la mail esce, ma non capisco come mandare i dati dei sensori?
Il prossimo passo per me sarà di fare in modo che quando io mando una mail alla Yùn, lei mi risponde con i valori dei sensori collegati ad essa...
Devo solo capire come fare ancora.
...Sono un noob.....