• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

How to send RSSI to Thhingspeak after scan function

Q&A Forum › Category: ESP32 › How to send RSSI to Thhingspeak after scan function
0 Vote Up Vote Down
youness BOUMAALIF asked 7 years ago
Good evening everyone, after performing a Scan to see available Wifi networks, I am interested only in a specific network characterizable by its MAC address, the one I want to communicate his RSSI to Thingspeak server in real time, the problem that he declares me that the variable rssi is not declared ...... Do you have remarks Thank you ...
Here is the code

 

#include <WiFi.h>
#include “esp_deep_sleep.h” //Library needed for ESP32 Sleep Functions
WiFiClient client; // wifi client object

const char *ssid = “ssid”;
const char *password = “xxxxxxxxxx”;
const char *Address_Mac = “AA:BB:CC:DD:EE:FF”;

char ThingSpeakAddress[] = “api.thingspeak.com”; // Thingspeak address
String api_key = “xxxxxxxxxxxxxxxxxxx”; // Thingspeak API WRITE Key for your channel
const int UpdateInterval = 0.33 * 60 * 1000000; 

void UpdateThingSpeak(String DataForUpload);
void scanNetworks() {
 
int numberOfNetworks = WiFi.scanNetworks();
 
Serial.print(“Number of networks found: “);
Serial.println(numberOfNetworks);
 
for (int i = 0; i < numberOfNetworks; i++) {
 
Serial.print(“Network name: “);
Serial.println(WiFi.SSID(i));
if (WiFi.BSSIDstr(i).equals(Address_Mac)){
 
float rssi = WiFi.BSSIDstr(i));

}
 
}
}
void setup() {
Serial.begin(115200);
scanNetworks();
WiFi.begin(ssid, password);
Serial.println(“Start WiFi”);
while (WiFi.status() != WL_CONNECTED ) {Serial.print(“.”); delay(500); }
Serial.println(WiFi.localIP());

UpdateThingSpeak(“field1=”+String(rssi)); //Send the data as text
esp_deep_sleep_enable_timer_wakeup(UpdateInterval);
WiFi.disconnect(true);
Serial.println(“Going to sleep now…”);
esp_deep_sleep_start();
}

void loop() {
 
}

void UpdateThingSpeak(String DataForUpload) {
WiFiClient client;
if (!client.connect(ThingSpeakAddress, 80)) {
Serial.println(“connection failed”);
return;
}
else
{
Serial.println(DataForUpload);
client.print(“POST /update HTTP/1.1\n”);
client.print(“Host: api.thingspeak.com\n”);
client.print(“Connection: close\n”);
client.print(“X-THINGSPEAKAPIKEY: ” + api_key + “\n”);
client.print(“Content-Type: application/x-www-form-urlencoded\n”);
client.print(“Content-Length: “);
client.print(DataForUpload.length());
client.print(“\n\n”);
client.print(DataForUpload);
}
client.stop();
}

1 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 7 years ago

Hello, you need to send the RSSI value in the body of the HTTP POST request. After the host, you can do something like this:

client.print(“POST /update HTTP/1.1\n”);
client.print(“Host: api.thingspeak.com\n”);
client.print(“field1=”);
client.print(rssi );

(…)
I hope that helps. Regards,
Rui

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.