I would like to display the WiFi rssi signal level on my dashboard with a gauge or numerical indicator. I am using a Nano IoT 33, I have the RSSI level in "-xxdBm" being presented to the serial port and read it on the IDE monitor. I would like to send this to the dashboard.
According to the reference library which I have incorporated in my sketch,
[WiFi - WiFi.RSSI() WiFi - WiFi.RSSI() - Arduino Reference , rssi is a a "long" number. When adding variables, if you select the gauge, then the variable, "rssi", it does not have "long" as a data type to select.
I have also tried the data type "cloudPower" , it will not work either. I see that cloudPower is used for much higher power levels, "Watts" which would normally be a positive number. RSSI is a negative number in dBm, like -80dBm to 0dBm. My dashboard displays are always "0", as to say, no data. I am assuming that there may be a data type incompatibility I have not solved ? I would like to display in the actual value of "-xxdBm" on the dashboard. I have looked through the forum and as yet, have not found this in any discussions, sorry if there is this topic and I have missed it. Looking for some guidance to solve this, thanks for reading.
Did you ever figure out how to display the WiFi RSSI in your dashboard? I'm trying to do the same thing and can't even get my sketch to compile always getting the error message:
"/... In function 'void loop()': ...:60:13: error: cannot resolve overloaded function 'RSSI' based on conversion to type 'int' rssi=WiFi.RSSI; ^~~~ Error during build: exit status 1
/*
Arduino sketch to read temperature and humidity from DHT20 sensor attached to MKR 1010 and send over
WiFi to IoT cloud. Display temperature and humidity using Dashboard widgets.
Control1 still TBD.
Sketch generated by the Arduino IoT Cloud Thing "MKRIoTEnv"
https://create.arduino.cc/cloud/things/fa8b93f5-90e6-4f4b-888c-3e0904e9a621
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float humidity;
float temperature;
int rssi;
bool control1;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include <DFRobot_DHT20.h>
DFRobot_DHT20 dht20;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
//Get temperature and humidity
float tempread = dht20.getTemperature();
float humidread = dht20.getHumidity()*100;
//Round to 1 decimal place
temperature=round(tempread*10)/10;
humidity=round(humidread*10)/10;
//Get RSSI
rssi=WiFi.RSSI;
}
/*
Since Control1 is READ_WRITE variable, onControl1Change() is
executed every time a new value is received from IoT Cloud.
*/
void onControl1Change() {
// Add your code here to act upon Control1 change
}
Yes I did, I received this from Eric at Arduino, many thanks to Eric !
Yes, you would need to create a variable or "thing" that is read by the gauge. In your case, it looks like you're using the ArduinoCloud.addProperty
method to create a property that can be read by the gauge.
Regarding the error message you're receiving ("redefinition of 'int rssiInt'"), this means that you've defined the rssiInt
variable twice in your code, which is not allowed. You only need to define the variable once and then use it wherever necessary. Here's an example of how you can update your code:
int rssiInt; // declare the rssiInt variable
void setup() {
// add the rssiInt property to the Arduino Cloud
ArduinoCloud.addProperty(rssiInt, READ, 1 * SECONDS, NULL);
}
void loop() {
// read the WiFi RSSI value and convert it to an integer
long rssiValue = WiFi.RSSI(); // get the RSSI value
rssiInt = (int)rssiValue; // convert the RSSI value to an integer
}
In this example, we declare the rssiInt
variable outside of the setup
and loop
functions and initialize it to 0 (or any other default value). Then, inside the setup
function, we add the rssiInt
property to the Arduino Cloud.
In the loop
function, we read the WiFi RSSI value and convert it to an integer using the code you provided. We then assign this value to the rssiInt
variable, which is already defined outside of the function. This will update the value of the rssiInt
property in the Arduino Cloud, which can be read by the gauge or value display.
I hope this helps you with your issue. Let me know if you have any further questions or concerns.
Best regards,
Eric Chavez, Support Team
Best Regards
Chris Moyer
chrismoyer223@gmail.com
Cell: 480-540-0972
Works! Thanks everyone.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.