basic wifi connection on arduino
This commit is contained in:
parent
a5e0f81930
commit
eb3dbcaffc
5 changed files with 104 additions and 0 deletions
7
SourceCode/arduino/.gitignore
vendored
Normal file
7
SourceCode/arduino/.gitignore
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
|
||||
include/theSecrets.h
|
23
SourceCode/arduino/include/theWifi.h
Normal file
23
SourceCode/arduino/include/theWifi.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef THEWIFI_H
|
||||
#define THEWIFI_H
|
||||
|
||||
#include "esp32-hal-log.h"
|
||||
#include "WiFi.h"
|
||||
#include "theSecrets.h"
|
||||
|
||||
const char *serverIp;
|
||||
|
||||
void connectWifi()
|
||||
{
|
||||
log_i("Attempting to connect to WPA SSID: %s", ssid);
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, psk);
|
||||
while (WiFi.status() != WL_CONNECTED)
|
||||
{
|
||||
delay(1000);
|
||||
}
|
||||
serverIp = WiFi.localIP().toString().c_str();
|
||||
log_i("Connected, IP Address: %s", serverIp);
|
||||
}
|
||||
|
||||
#endif
|
46
SourceCode/arduino/lib/README
Normal file
46
SourceCode/arduino/lib/README
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
16
SourceCode/arduino/platformio.ini
Normal file
16
SourceCode/arduino/platformio.ini
Normal file
|
@ -0,0 +1,16 @@
|
|||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp32-evb]
|
||||
platform = espressif32
|
||||
board = esp32-evb
|
||||
framework = arduino
|
||||
monitor_speed = 115200
|
||||
build_flags = -DCORE_DEBUG_LEVEL=3
|
12
SourceCode/arduino/src/main.cpp
Normal file
12
SourceCode/arduino/src/main.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <Arduino.h>
|
||||
#include "theWifi.h"
|
||||
|
||||
void setup()
|
||||
{
|
||||
connectWifi();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
Reference in a new issue