I would like to display the value of a measurement, WiFi.RSSI(), in an email body. I have email working just fine with any text body content but I have not figured out how to send a measurement or variable like digitalRead()? Hope I stated this question correctly..
Thanks in advance for any help.
Hello @cfso017,
If you are trying to send values from a sensor over to your email, you could try integrating with a MQTT server like IFTTT which will take care of most of the things for you. There is tons of documentation already available for it.
Coming back to the point, you have to store the digital read value that you get inside a variable. For example
buttonState = digitalRead(buttonPin);
And then try calling the variable inside the email code.
For Example (Not in correct syntax):
sendEmail (body, "Value is:", buttonState);
And such a system should work. It will be even more useful if you could provide a snippet of the code so that helping will be easier.
Into the WIfi.RSSI Code,
This is the sample code given to test the strength of the wifi connection
#include <SPI.h> #include <WiFi.h> //SSID of your network char ssid[] = "yourNetwork"; //password of your WPA Network char pass[] = "secretPassword"; void setup() { WiFi.begin(ssid, pass); if (WiFi.status() != WL_CONNECTED) { Serial.println("Couldn't get a wifi connection"); while(true); } // if you are connected, print out info about the connection: else { // print the received signal strength: long rssi = WiFi.RSSI(); Serial.print("RSSI:"); Serial.println(rssi); } } void loop () {}
Over here, you can see the strength to be stored in the "rssi" variable. Now while using the e-mail library, just call the "rssi" variable like this
//Not in correct syntax for any E-Mailing library sendEmail ( to, "strength is:", rssi);
Hope this gives you an idea of the possible solution.
Cheers!
That did not work for me for I am using smtp.message in the esp32email library that I am using but you
gave me some ideas to try. Thank you..
Try
String body = "Strength is " + String(WiFi.RSSI());
message.text.content = body.c_str();
Experience is what you get when you don't get what you want.
@cfs0012
I just now completed going through the esp32 mail library. You can use what @will has mentioned above since that must work with the code.
This is the error I get when using those commands.
message' was not declared in this scope
Do not spend allot of time on this.
Thanks again...
I used message.text.content to illustrate the layers, not the name of the class instance (message) that you created. You'll have to substitute whatever name you've assigned.
You haven's show any code, so we can't customize it for you, just illustrate the command format.
Experience is what you get when you don't get what you want.
Here is the command that works. Thank you very much for your lead.
String body = "Strength is " + String(WiFi.RSSI());
smtpData.setMessage(body,false);
Excellent !
Experience is what you get when you don't get what you want.