temp sensor and battery level

This commit is contained in:
Just Call Me Koko
2020-04-15 12:33:41 -04:00
parent 35b10ac9be
commit 1e1f6f6b19
10 changed files with 185 additions and 10 deletions
+2 -1
View File
@@ -3,7 +3,7 @@
<!---[![Build Status](https://travis-ci.com/justcallmekoko/ESP32Marauder.svg?branch=master)](https://travis-ci.com/justcallmekoko/ESP32Marauder)--->
<!---Shields/Badges https://shields.io/--->
# ESP32 Marauder v0.6.2
# ESP32 Marauder v0.6.3
<p align="center"><img alt="Marauder logo" src="https://github.com/justcallmekoko/ESP32Marauder/blob/master/pictures/marauder3L.jpg?raw=true" width="300"></p>
<p align="center">
<b>A suite of WiFi/Bluetooth offensive and defensive tools for the ESP32</b>
@@ -135,6 +135,7 @@ If you own an ESP32 Marauder (v0.4.0 or later) and have not build the project, y
- Marauder will automatically reboot once the update has been applied
### SD Update
*Using a Samsung MicroSD card will cause Marauder not to boot*
1. Download the [latest release](https://github.com/justcallmekoko/ESP32Marauder/releases/latest) of the Marauder firmware
2. Copy the bin file you downloaded to the root of an SD card
3. Rename the bin file on the SD card to `update.bin`
+43
View File
@@ -0,0 +1,43 @@
#include "BatteryInterface.h"
BatteryInterface::BatteryInterface() {
}
void BatteryInterface::main(uint32_t currentTime) {
if (currentTime != 0) {
if (currentTime - initTime >= 3000) {
//Serial.println("Checking Battery Level");
this->initTime = millis();
int8_t new_level = this->getBatteryLevel();
//this->battery_level = this->getBatteryLevel();
if (this->battery_level != new_level) {
Serial.println("Battery Level changed: " + (String)new_level);
this->battery_level = new_level;
}
}
}
}
void BatteryInterface::RunSetup() {
Wire.begin(I2C_SDA, I2C_SCL);
this->initTime = millis();
}
int8_t BatteryInterface::getBatteryLevel() {
Wire.beginTransmission(IP5306_ADDR);
Wire.write(0x78);
if (Wire.endTransmission(false) == 0 &&
Wire.requestFrom(0x75, 1)) {
this->i2c_supported = true;
switch (Wire.read() & 0xF0) {
case 0xE0: return 25;
case 0xC0: return 50;
case 0x80: return 75;
case 0x00: return 100;
default: return 0;
}
}
this->i2c_supported = false;
return -1;
}
+27
View File
@@ -0,0 +1,27 @@
#ifndef BatteryInterface_h
#define BatteryInterface_h
#include <Arduino.h>
#include <Wire.h>
#define I2C_SDA 33
#define I2C_SCL 22
#define IP5306_ADDR 0x75
class BatteryInterface {
private:
uint32_t initTime = 0;
public:
int8_t battery_level = 0;
bool i2c_supported = false;
BatteryInterface();
void RunSetup();
void main(uint32_t currentTime);
int8_t getBatteryLevel();
};
#endif
+4
View File
@@ -40,6 +40,10 @@ void Display::RunSetup()
//tft.fillScreen(TFT_BLACK);
clearScreen();
Serial.println("SPI_FREQUENCY: " + (String)SPI_FREQUENCY);
Serial.println("SPI_READ_FREQUENCY: " + (String)SPI_READ_FREQUENCY);
Serial.println("SPI_TOUCH_FREQUENCY: " + (String)SPI_TOUCH_FREQUENCY);
// Initialize file system
// This should probably have its own class
+1 -1
View File
@@ -56,7 +56,7 @@ class Display
TFT_eSPI tft = TFT_eSPI();
TFT_eSprite img = TFT_eSprite(&tft);
TFT_eSPI_Button key[BUTTON_ARRAY_LEN];
String version_number = "v0.6.2";
String version_number = "v0.6.3";
bool printing = false;
bool loading = false;
+33
View File
@@ -0,0 +1,33 @@
#include "TemperatureInterface.h"
#ifdef __cplusplus
extern "C" {
#endif
uint8_t temprature_sens_read();
#ifdef __cplusplus
}
#endif
uint8_t temprature_sens_read();
TemperatureInterface::TemperatureInterface() {
}
void TemperatureInterface::RunSetup() {
this->initTime = millis();
this->current_temp = this->getCurrentTemp();
}
uint8_t TemperatureInterface::getCurrentTemp() {
return ((temprature_sens_read() - 32) / 1.8);
}
void TemperatureInterface::main(uint32_t currentTime) {
if (currentTime != 0) {
if (currentTime - initTime >= 3000) {
//Serial.println("Checking Battery Level");
this->initTime = millis();
this->current_temp = this->getCurrentTemp();
}
}
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef TemperatureInterface_h
#define TemperatureInterface_h
#include <Arduino.h>
class TemperatureInterface {
private:
uint32_t initTime = 0;
public:
TemperatureInterface();
uint8_t current_temp = 0;
uint8_t getCurrentTemp();
void RunSetup();
void main(uint32_t currentTime);
};
#endif
+17 -7
View File
@@ -272,20 +272,30 @@ void WiFiScan::RunInfo()
//display_obj.tft.println(" Station MAC: " + sta_mac);
//display_obj.tft.println(" AP MAC: " + ap_mac);
display_obj.tft.println(" Firmware: Marauder");
display_obj.tft.println(" Version: " + display_obj.version_number + "\n");
display_obj.tft.println(" " + free_ram);
display_obj.tft.println(" Firmware: Marauder");
display_obj.tft.println(" Version: " + display_obj.version_number + "\n");
display_obj.tft.println(" " + free_ram);
if (sd_obj.supported) {
display_obj.tft.println(" SD Card: Connected");
display_obj.tft.print("SD Card Size: ");
display_obj.tft.println(" SD Card: Connected");
display_obj.tft.print(" SD Card Size: ");
display_obj.tft.print(sd_obj.card_sz);
display_obj.tft.println("MB");
}
else {
display_obj.tft.println(" SD Card: Not Connected");
display_obj.tft.println("SD Card Size: 0");
display_obj.tft.println(" SD Card: Not Connected");
display_obj.tft.println(" SD Card Size: 0");
}
battery_obj.battery_level = battery_obj.getBatteryLevel();
if (battery_obj.i2c_supported) {
display_obj.tft.println(" IP5306 I2C: supported");
display_obj.tft.println(" Battery Lvl: " + (String)battery_obj.battery_level + "%");
}
else
display_obj.tft.println(" IP5306 I2C: not supported");
display_obj.tft.println("Internal temp: " + (String)temp_obj.current_temp + " C");
}
void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color)
+4
View File
@@ -14,6 +14,8 @@
#include "Display.h"
#include "SDInterface.h"
#include "Buffer.h"
#include "BatteryInterface.h"
#include "TemperatureInterface.h"
//#include "MenuFunctions.h"
#define bad_list_length 3
@@ -39,6 +41,8 @@
extern Display display_obj;
extern SDInterface sd_obj;
extern Buffer buffer_obj;
extern BatteryInterface battery_obj;
extern TemperatureInterface temp_obj;
esp_err_t esp_wifi_80211_tx(wifi_interface_t ifx, const void *buffer, int len, bool en_sys_seq);
+33 -1
View File
@@ -23,14 +23,29 @@ https://www.online-utility.org/image/convert/to/XBM
#include "SDInterface.h"
#include "Web.h"
#include "Buffer.h"
#include "BatteryInterface.h"
#include "TemperatureInterface.h"
//#include "icons.h"
/*
#ifdef __cplusplus
extern "C" {
#endif
uint8_t temprature_sens_read();
#ifdef __cplusplus
}
#endif
uint8_t temprature_sens_read();
*/
Display display_obj;
WiFiScan wifi_scan_obj;
MenuFunctions menu_function_obj;
SDInterface sd_obj;
Web web_obj;
Buffer buffer_obj;
BatteryInterface battery_obj;
TemperatureInterface temp_obj;
uint32_t currentTime = 0;
@@ -54,6 +69,8 @@ void setup()
Serial.println(" By: justcallmekoko\n");
Serial.println("--------------------------------\n\n");
//Serial.println("Internal Temp: " + (String)((temprature_sens_read() - 32) / 1.8));
// Do some SD stuff
if(sd_obj.initSD())
Serial.println("SD Card supported");
@@ -65,12 +82,25 @@ void setup()
// Build menus
menu_function_obj.RunSetup();
// Battery stuff
battery_obj.RunSetup();
// Temperature stuff
temp_obj.RunSetup();
battery_obj.battery_level = battery_obj.getBatteryLevel();
if (battery_obj.i2c_supported) {
Serial.println("IP5306 I2C Supported: true");
}
else
Serial.println("IP5306 I2C Supported: false");
}
void loop()
{
// get the current time
//if ((wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM))
currentTime = millis();
@@ -83,6 +113,8 @@ void loop()
display_obj.main();
wifi_scan_obj.main(currentTime);
sd_obj.main();
battery_obj.main(currentTime);
temp_obj.main(currentTime);
//if ((wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM))
if ((wifi_scan_obj.currentScanMode != WIFI_PACKET_MONITOR) &&
(wifi_scan_obj.currentScanMode != WIFI_SCAN_EAPOL))