ElectroPeak
Published © GPL3+

Create a WiFi Heat Map Using ESP8266 & Arduino

In this tutorial, we are going to make a heat map of the surrounding Wi-Fi signals using Arduino and ESP8266.

BeginnerProtip1 hour4,102

Things used in this project

Hardware components

Arduino UNO R3
×1
ElectroPeak 3.5 "TFT Color Display Screen Module
×1
ElectroPeak ESP8266 WiFi Module
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code 1

Arduino
#include "ESP8266WiFi.h"
 
char inByte;
 
void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
}
 
void loop() {
  if (Serial.available() > 0)
  {
    // get incoming byte:
    inByte = Serial.read();
    if (inByte == '1')
    {
      int n = WiFi.scanNetworks();
      if (n == 0) {
        Serial.println("no networks found");
      } else {
        for (int i = 0; i < n; ++i) {
          if (WiFi.SSID(i) == "Specific SSID") {
            Serial.println(WiFi.RSSI(i));
          }
        }
      }
    }
  }
}

Code 2

Arduino
#include "Adafruit_GFX.h"
#include "MCUFRIEND_kbv.h"
MCUFRIEND_kbv tft;
 
int Pa, Pb, Pc, Pd;
int color;
int r = 0, g = 150, b = 200;
int sam, eq;
int r2, b2, g2;
 
void setup() {
  Serial.begin(115200);
  tft.reset();
  uint16_t ID = tft.readID();
  tft.begin(ID);
  tft.setRotation(1);
  tft.invertDisplay(true);
  tft.fillScreen(0x0000);
}
void loop() {
  Serial.println("1");
  delay(1000);
  if (Serial.available() > 0) {
    // get incoming byte:
    Pa = Serial.read();
  }
 
  Serial.println("2");
  delay(1000);
  if (Serial.available() > 0) {
    // get incoming byte:
    Pb = Serial.read();
  }
 
  Serial.println("3");
  delay(1000);
  if (Serial.available() > 0) {
    // get incoming byte:
    Pc = Serial.read();
  }
 
  Serial.println("4");
  delay(1000);
  if (Serial.available() > 0) {
    // get incoming byte:
    Pd = Serial.read();
  }
 
  sam =  (( sqrt(pow(240, 2) + pow(160, 2)) * Pa + sqrt(pow(480 - 240, 2) + pow(160, 2)) * Pb + sqrt(pow(240, 2) + pow(320 - 160, 2)) * Pc + sqrt(pow(480 - 240, 2) + pow(320 - 160, 2)) * Pd ) / ( sqrt(pow(240, 2) + pow(160, 2)) + sqrt(pow(480 - 240, 2) + pow(160, 2)) + sqrt(pow(240, 2) + pow(320 - 160, 2)) + sqrt(pow(480 - 240, 2) + pow(320 - 160, 2)) ) );
 
  for (int y = 0; y < 320; y++)
  { for (int x = 0; x < 480; x++) { eq = (( sqrt(pow(x, 2) + pow(y, 2)) * Pa + sqrt(pow(480 - x, 2) + pow(y, 2)) * Pb + sqrt(pow(x, 2) + pow(320 - y, 2)) * Pc + sqrt(pow(480 - x, 2) + pow(320 - y, 2)) * Pd ) / ( sqrt(pow(x, 2) + pow(y, 2)) + sqrt(pow(480 - x, 2) + pow(y, 2)) + sqrt(pow(x, 2) + pow(320 - y, 2)) + sqrt(pow(480 - x, 2) + pow(320 - y, 2)) ) ); // Serial.println(eq); // delay(20); eq = (eq - sam) * -1; //Serial.println(eq); r2 = r + (10 * eq); b2 = b + (10 * eq); g2 = g + (10 * eq); if (r2 > 255)r2 = 255;
      if (r2 < 0)r2 = 0; if (b2 > 255)b2 = 0;
      if (b2 < 0)b2 = 0; if (g2 > 255)g2 = 0;
      if (g2 < 0)g2 = 0;
 
      color = tft.color565(r2, g2, b2);
      tft.drawPixel(x, y, color);
    }
  }
}

Credits

ElectroPeak
57 projects • 743 followers
At ElectroPeak we want to teach you to enjoy electronics more. We offer Top-notch guides and worry-free shopping experience.
Contact

Comments

Please log in or sign up to comment.