Last active
May 18, 2018 13:49
-
-
Save shirish47/9f39f9e4ac9f7447f530d3f0e3f81c68 to your computer and use it in GitHub Desktop.
ESP32 RAM max array test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Author: Shirish Jadav | |
* Date: 2, May 2018 | |
* | |
* This code shows basic TCP connection over WIFI. | |
* update variables ssid, pass, HOST, PORT before uploading | |
*/ | |
#include <WiFi.h> | |
#include <WiFiMulti.h> | |
char* ssid = "yourWifiName"; // Your wifi access point name you want to connect to | |
// Make sure you don't have Mac Filtering on AP | |
char* pass = "password";// Your Wifi password | |
char* HOST = "YourIpAddress"; // Your PC's IP where your server is running | |
int PORT = 3004; // Port number on which your server is listening | |
WiFiMulti WifiMulti; // references: https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/examples/WiFiMulti/WiFiMulti.ino | |
WiFiClient client; // references: https://www.arduino.cc/en/Reference/WiFi | |
int itr = 0; // a variable we will update and send to server | |
#define Size (10600000) | |
typedef struct data{ | |
uint16_t x; | |
uint16_t y; | |
uint16_t z; | |
}data_t; | |
static data_t a_data[Size]; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); | |
WifiMulti.addAP( ssid, pass ); | |
delay(10000); | |
Serial.print("MAC ID: ");Serial.println(getMacAddress()); | |
Serial.println("Wait for WiFi... "); | |
Serial.print(Size);Serial.println(" Samples"); | |
Serial.print(Size*sizeof(a_data));Serial.println(" Bytes"); | |
Serial.print("SAMPlE Time(1600BW): ");Serial.println(Size/(1600*2)); | |
Serial.print("SAMPlE Time(800BW): ");Serial.println(Size/(800*2)); | |
while(WifiMulti.run() != WL_CONNECTED) { | |
Serial.print("."); | |
delay(500); | |
} | |
if(WifiMulti.run()==WL_CONNECTED) { //if wifi Connects | |
Serial.println("WiFi connected"); | |
Serial.print("IP address: "); | |
Serial.println(WiFi.localIP()); | |
}else{ | |
Serial.println("Wifi Failed to Connect"); | |
} | |
if(client.connect( HOST, PORT) == 1) { | |
Serial.println("Connected to Server"); | |
Serial.println("Check on server you will receive hello world"); | |
}else{ | |
Serial.println("Failed to Connect to Server"); | |
} | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
if(client.connected()){ //if we are connected to client | |
client.print(a_data[itr].x); | |
client.print(" "); | |
client.print(a_data[itr].y); | |
client.print(" "); | |
client.println(a_data[itr].z); | |
itr++; | |
if(itr>Size) | |
while(1); | |
} | |
} | |
void fillarray() | |
{ | |
while(itr<Size) | |
} | |
String getMacAddress() { | |
uint8_t baseMac[6]; | |
// Get MAC address for WiFi station | |
esp_read_mac(baseMac, ESP_MAC_WIFI_STA); | |
char baseMacChr[18] = {0}; | |
sprintf(baseMacChr, "%02X-%02X-%02X-%02X-%02X-%02X", baseMac[0], baseMac[1], baseMac[2], baseMac[3], baseMac[4], baseMac[5]); | |
return String(baseMacChr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment