Hi, i use this code to check if i have wifi at home.
I will change the purpose later.
For the moment i want
-Have one wifi connection (this part works)
Turn on a led wen i have internet connection and turn off when I don’t have. (this work too)
The idea was to send a email when i have internet connection again.
So i use this code to send the email, but he don’t work.
char ssid[] = “ma-maison”; // your network SSID (name)
char pass[] = “4445555SSSSEER???”; // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0; // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS; //connection status
WiFiServer server(80); //server socket
//mod ping
String hostName = “www.google.fr”;
int pingResult;
// fin mod ping
// mod mail
//EMailSender emailSend(“sergio”, “dddd1111?”, “sergio@gmail.com”, “smtp.gmail.com”, 465); i have tried this combination too
EMailSender emailSend(“sergio”, “dddd1111?”);
// fin mod mail
WiFiClient client = server.available();
int ledPin = 2;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
while (!Serial);
void printWifiStatus() {
// print the SSID of the network you’re attached to:
Serial.print(“SSID: “);
Serial.println(WiFi.SSID());
// print your board’s IP address:
IPAddress ip = WiFi.localIP();
Serial.print(“IP Address: “);
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print(“signal strength (RSSI):”);
Serial.print(rssi);
Serial.println(” dBm”);
Serial.print(“To see this page in action, open a browser to http://”);
Serial.println(ip);
}
void enable_WiFi() {
// check for the WiFi module:
if (WiFi.status() == WL_NO_MODULE) {
Serial.println(“Communication with WiFi module failed!”);
// don’t continue
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv < “1.0.0”) {
Serial.println(“Please upgrade the firmware”);
}
}
void connect_WiFi() {
// attempt to connect to Wifi network:
while (status != WL_CONNECTED) {
Serial.print(“Attempting to connect to SSID: “);
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
}
void sergio(){
// mod ping
Serial.print(“Pinging “);
Serial.print(hostName);
Serial.print(“: “);
pingResult = WiFi.ping(hostName);
if (pingResult >= 0) {
Serial.print(“SUCCESS! RTT = “);
Serial.print(pingResult);
Serial.println(” ms”);
digitalWrite(ledPin, HIGH);
} else {
Serial.print(“FAILED! Error code: “);
Serial.println(pingResult);
digitalWrite(ledPin, LOW);
}
delay(5000);
}
——————————- end code——————–
I have this result
Attempting to connect to SSID: ma-maison
SSID: ma-maison
IP Address: 002.01.0.30
signal strength (RSSI):-37 dBm
Sending status:
2
Could not connect to mail server
0
Maintaining a repository (or site or forum) is a lot like tending to a garden - it requires constant care and attention to keep it thriving. If you're a skilled gardener (or coder!) and want to help keep our repository blooming, we'd love to have you on board! We're also looking for talented writers and forum moderators to help us grow our community. Interested in joining our team? Don't hesitate to reach out and let us know how you can contribute!
Are you a fan of electronics or programming? Share your knowledge with others, write a simple tutorial or how to make a great project Contact me: share_your_ideas@mischianti.org
The content displayed on this website is protected under a CC BY-NC-ND license. Visitors are prohibited from using, redistributing, or altering any content from this website for commercial purposes, including generating revenue through advertising. Any unauthorized use is a violation of the license terms and legal action may be taken against individuals or entities found to be in violation.
You must also provide the link to the source.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional
Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.