Hallo Forengemeinde.
Ich hab ein Problem.
Ich verwende einen ESP 8266 Wlanchip
https://www.mikrocontroller.net/articles/ESP8266
in der NodeMCU Ausführung.
http://www.ebay.de/itm/2x-NodeMcu-ESP8266-CH340G-IoT-32bit-WIFI-Internet-Development-Board-Module-TE689-/252795156724?hash=item3adbc3f8f4:g:xoEAAOSw2gxYuGo5
Ich verwende Blynk (http://docs.blynk.cc/) um Analogdaten am Handy
anzuzeigen.
Dies funktioniert ohne Probleme. Auch das Senden einer Mail funktioniert
einwandfrei. allerdings möchte ich das kombinieren das er mir bei
unterschreiten eines Wertes eine Mail sendet. das bekomm ich nicht hin.
könntet ihr einen kurzen Blick auf den Code werfen?
danke Marian
/*************************************************************
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapphttp://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
Simple e-mail example
App project setup:
E-mail Widget
Connect a button to digital pin 2 and GND
Pressing this button will send an e-mail
WARNING: You are limited to send ONLY ONE E-MAIL PER 15 SECONDS!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
/* Set this to a bigger number, to enable sending longer messages */
//#define BLYNK_MAX_SENDBYTES 128
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
int pinValue =0;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "***********"; //mein Token
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "HWx";
char pass[] = "";
// This function will be called every time Slider Widget
// in Blynk app writes values to the Virtual Pin 1
BlynkTimer timer;
// This function sends Arduino's up time every second to Virtual Pin
(5).
// In the app, Widget's reading frequency should be set to PUSH. This
means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(V5, millis() / 1000);
if(V5 < 50)
Blynk.email("Mail@mail.at", "Subject: Turbine", "Grenzwert
unterschritten %n" V5);
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server:
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
// Send e-mail when your hardware gets connected to Blynk Server
// Just put the recepient's "e-mail address", "Subject" and the
"message body"
Blynk.email("Mail@mail.at", "Subject: Turbine", "System wieder
online.");
}
void loop()
{
Blynk.run();
timer.run();
}
Ich kenne mich mit Deiner Library nicht groß aus. Finde ich aber
prinzipiell interessant und werde es mir einmal ansehen.
Was funktioniert denn derzeit genau nicht? Sofern die erste E-Mail
(System wieder online) durch geht, die regelmäßige Updatemeldung aber
nicht, würde ich mal vermuten, dass das Timer-Event nicht richtig
registriert wurde.
Kommt der Code so aus einer GUI heraus, oder hast Du den selbst
geschrieben?
Marian G. schrieb:> void setup()> {> // Debug console> Serial.begin(9600);>> Blynk.begin(auth, ssid, pass);> // You can also specify server:> //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);> //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);>> // Send e-mail when your hardware gets connected to Blynk Server> // Just put the recepient's "e-mail address", "Subject" and the> "message body"> Blynk.email("Mail@mail.at", "Subject: Turbine", "System wieder> online.");>> }
Ich sehe da nirgends eine Timer-Initialisierung:
Hallo.
Danke für die Tipps. der Code sieht jetzt zwar komplett anders aus aber
jetzt funktioniert er.
Nun noch eine Frage. Wie kann ich denn den Analogwert bei dem die Mail
gesendet wird in die Mail einbinden?
danke schonmal.
Marian
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>
SimpleTimer timer;
int current_comparator_level = LOW;
int previous_comparator_level = LOW;
const int comparator_high_thresh = 410;
const int comparator_low_thresh = 250;
char BlynkAuth[] = "";
char WiFiNetwork[] = "";
char WiFiPassword[] = "";
void read_photodiode_sensor()
{
int current_analog = analogRead(A0);
Serial.println(current_analog);
previous_comparator_level = current_comparator_level;
if(current_analog > comparator_high_thresh)
{
current_comparator_level = HIGH;
}
if(current_analog < comparator_low_thresh)
{
current_comparator_level = LOW;
}
if( current_comparator_level==LOW && previous_comparator_level==HIGH
)
{
Blynk.email("mail@gmx.net", "Turbine", "Grenzwert unterschritten");
}
}
void setup()
{
// Initialize hardware
Serial.begin(9600); // Serial
// Initialize Blynk
Blynk.begin(BlynkAuth, WiFiNetwork, WiFiPassword);
timer.setInterval(1L * 2500L, read_photodiode_sensor);
}
void loop()
{
Blynk.run();
timer.run();
}
Oh, Du hättest durchaus beim BlinkyTimer bleiben können. Wird von denen
sogar empfohlen, da er wohl einige Sachen besser macht als der
SimpleTimer. Kannst einfach wieder ersetzen und dann den Include der
simpleTimer.h wieder heraus nehmen. Die Befehle sind ansonsten wohl
identisch.
Um den Wert mit in die E-Mail zu schreiben, musst Du einfach folgende
Zeile modifizieren:
Super, Danke euch allen für die schnelle Unterstützung!
Eigentlich kann ich mir bei genauerer Betrachtung der Problemstellung
den Analogwert in der Mail sparen, da es ja sowiso vom Schmitttrigger
vorgegeben ist wann die Mail gesendet wird.
Jedenfalls vielen Dank :)
Ich hoffe ich kann mich einmal revangieren :)
Marian G. schrieb:> Nun noch eine Frage. Wie kann ich denn den Analogwert bei dem die Mail> gesendet wird in die Mail einbinden?
Die Lösung hattest du schon in deinem ersten Posting drin