Notifications
Clear all

How to display a measurement in Ardunio

9 Posts
3 Users
0 Likes
1,222 Views
(@cfso017)
Member
Joined: 2 years ago
Posts: 5
Topic starter  

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.


   
Quote
Atul Ravi
(@atulravi)
Member
Joined: 2 years ago
Posts: 10
 

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!


   
ReplyQuote
(@cfso017)
Member
Joined: 2 years ago
Posts: 5
Topic starter  

@esccrasci 

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..


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@cfso017 

Try

String body = "Strength is " + String(WiFi.RSSI());

message.text.content = body.c_str();

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Atul Ravi
(@atulravi)
Member
Joined: 2 years ago
Posts: 10
 

@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.


   
ReplyQuote
(@cfso017)
Member
Joined: 2 years ago
Posts: 5
Topic starter  

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...


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@cfso017 

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.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@cfso017)
Member
Joined: 2 years ago
Posts: 5
Topic starter  

Here is the command that works.  Thank you very much for your lead.

String body = "Strength is " + String(WiFi.RSSI());

smtpData.setMessage(body,false);

 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2531
 

@cfso017 

Excellent !

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote