Juraj:
what baud rate you have set in Serial Monitor? WiFiLinkWebClient prints at 115200 baud
Yes, it was set to 9600. Now it works, but what does this mean? If I have to load any sketch that uses the WifiLink library plus others, what baud rate should I use?
now I hope you do not want to send e-mail over a server which accepts only secure connection. the ATmega has not the resources to encrypt data. (esp has, I think)
I found the following code online for sending emails with the ESP8266WiFi.h library and using the smtp2go.com service to avoid the problem you mentioned.
In your opinion, is it possible to adapt the same code using the WifiLink library? and it is possible to load it in ATmega?
#include <ESP8266WiFi.h> // the ESP8266WiFi.h lib
const char* SSID = "YourSSID";
const char* PASS = "YourPW";
char server[] = "mail.smtpcorp.com";
ADC_MODE(ADC_VCC);
WiFiClient client;
void setup()
{
Serial.begin(115200);
delay(10);
Serial.println("");
Serial.println("");
Serial.print("Connecting To ");
Serial.println(SSID);
WiFi.begin(SSID, PASS);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi Connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
byte ret = sendEmail();
}
void loop()
{
}
byte sendEmail()
{
byte thisByte = 0;
byte respCode;
if (client.connect(server, 2525) == 1) {
Serial.println(F("connected"));
} else {
Serial.println(F("connection failed"));
return 0;
}
if (!eRcv()) return 0;
Serial.println(F("Sending EHLO"));
client.println("EHLO www.example.com");
if (!eRcv()) return 0;
Serial.println(F("Sending auth login"));
client.println("auth login");
if (!eRcv()) return 0;
Serial.println(F("Sending User"));
// Change to your base64, ASCII encoded user
client.println("ZV83MTAwMEBnbWFljC5jb31="); // SMTP UserID
if (!eRcv()) return 0;
Serial.println(F("Sending Password"));
// change to your base64, ASCII encoded password
client.println("X5pqVU9vYlJjY7Bq");// SMTP Passw
if (!eRcv()) return 0;
Serial.println(F("Sending From")); // change to your email address (sender)
client.println(F("MAIL From: yrmail@gmail.com"));// not important
if (!eRcv()) return 0; // change to recipient address
Serial.println(F("Sending To"));
client.println(F("RCPT To: receiver@gmail.com"));
if (!eRcv()) return 0;
Serial.println(F("Sending DATA"));
client.println(F("DATA"));
if (!eRcv()) return 0;
Serial.println(F("Sending email")); // change to recipient address
client.println(F("To: receiver@gmail.com")); // change to your address
client.println(F("From: sender@gmail.com"));
client.println(F("Subject: Emails from ESp8266\r\n"));
client.print(F("Power is: "));
client.print(ESP.getVcc());
client.println(F("mV"));
client.print(F("Device Chip ID: "));
client.println(ESP.getChipId());
Serial.print(F("Voltage is: "));
Serial.print(ESP.getVcc());
client.println(F("."));
if (!eRcv()) return 0;
Serial.println(F("Sending QUIT"));
client.println(F("QUIT"));
if (!eRcv()) return 0;
client.stop();
Serial.println(F("disconnected"));
return 1;
}
byte eRcv()
{
byte respCode;
byte thisByte;
int loopCount = 0;
while (!client.available())
{
delay(1);
loopCount++; // if nothing received for 10 seconds, timeout
if (loopCount > 10000) {
client.stop();
Serial.println(F("\r\nTimeout"));
return 0;
}
}
respCode = client.peek();
while (client.available())
{
thisByte = client.read();
Serial.write(thisByte);
}
if (respCode >= '4')
{
// efail();
return 0;
}
return 1;
}
Juraj:
yes. replace everything from beginning until while (WiFi.status() != WL_CONNECTED) from WiFiLinkWebClient.ino
The code works, e-mail sent correctly
I don't know how I would have done without you!
One last thing: I need to view the data collected by various sensors on a webserver. Do you advise me to use the WifiWebServer.ino sketch of the LinkWifi library?
Michele94:
One last thing: I need to view the data collected by various sensors on a webserver. Do you advise me to use the WifiWebServer.ino sketch of the LinkWifi library?
Yes, you can make a simple web page with it. If you start a web server on port 80 with WiFi Link library, the web panel's webserver stops (it is on port 80 too).
In my project with WiFi Link I have only a REST server on port 81 in ATmega. The web app files (html, js, css) I added to SPIFFS.
If you have time to play more with your Uno WiFi you could make your project as a sketch for the esp on Uno WiFi. Your project is more about networking then about sensor reading. If you put Firmata into ATmega it will be a slave for the esp with FirmataMaster library and you can read ATmega pins from esp sketch.
This weekend I finished a new example for Uno WiFi Serial1 library. It is a Firmata sketch with two small modifications for Uno WiFi. First is a use of Serial1 and the second is automatic bridge for esp flashing from IDE. So you simply write your esp sketch, the you hit Upload and it uploads. After upload the ATmega returns to be Firmata.
It has nothing to do with WiFi Link. This is an Uno WiFi upside down concept, where the 'firmware' is in ATmega and the sketch is in esp.
I thank you for the information on the web server but I have not been able to deepen them as I'm still having problems with the wifi dell'arduino.
In particular, for technical reasons I had to change the PC and the wifi network to work on again. I'm having problems viewing the web panel at the usual address 192.168.240.1. After many attempts with several PCs, only once I was able to reach the web panel but the display of it on the browser was not complete and not interacting.
Could it be again a problem with the SPIFFS file system (for displaying the web panel)? Should I re-run the firmware change procedure again?
Could it affect the fact that the PC with which the procedure ended successfully has windows 8.1 while all the others have windows 10?
Are you referring to the web server?
I have not implemented it yet. I am still in the e-mail code and now I can not substantially change the wifi network to which I connect arduino because I can no longer access the web panel with a different pc.
I'm trying to reload the firmware again following the guide on github but when loading the espProxy.ino there is no longer any writing to decompress #define FLASHING. Do I have to do it or not?
the new version of EspProxy detects the flashing. let it as it is.
but do not upload the firmware again. that will not help.
with EspProxy in ATmega is the Web Panel accessible?
open the Serial Monitor for the boot log to see if the esp restars when the web panel is not accessible