Initial ESP32 code

master
Tait Hoyem 2 years ago
parent 0349249527
commit 74639700a6

@ -0,0 +1,43 @@
LIBS := EspSoftwareSerial AsyncTCP_SSL TinyGPSPlus-ESP32 HardwareSerial_RS485
DEFAULT_PORT := /dev/ttyUSB0
BAUD_RATE := 9600
SUCCESS_MSG := "SUCCESS!"
LIBRARIES_DIR := ${HOME}/Arduino/libraries
AC := arduino-cli
AC_FLAGS := --libraries "${LIBRARIES_DIR}"
ESP32_BOARD_CAT := esp32:esp32
ESP32_BOARD_ID := esp32:esp32:esp32doit-devkit-v1
CONFIG_FILE := config.yaml
# attempt to compile program
default:
$(AC) compile --clean --fqbn ${ESP32_BOARD_ID} ${AC_FLAGS} .
echo ${SUCCESS_MSG}
new-serial:
echo "You may leave the serial view at any time with the key combo control+b, then press d"
sleep 5
tmux new -ds _serial; tmux send-keys -t _serial '# you may exit any time with control+d, then x' Enter 'screen ${DEFAULT_PORT} ${BAUD_RATE}' Enter
tmux a -t _serial
join-serial:
tmux a -t _serial
kill-serial:
tmux send-keys -t _serial C-a
tmux send-keys -t _serial k
tmux send-keys -t _serial y
tmux send-keys -t _serial exit Enter
# upload files to the specified port
upload:
$(AC) compile --clean --fqbn ${ESP32_BOARD_ID} ${AC_FLAGS} --port ${DEFAULT_PORT} --upload .
echo ${SUCCESS_MSG}
# install all dependencies needed for the project
install-deps:
$(AC) core update-index --config-file ${CONFIG_FILE}
$(AC) core install $(ESP32_BOARD_CAT)
$(AC) lib install ${LIBS}
cd ${LIBRARIES_DIR}/ && wget https://github.com/me-no-dev/AsyncTCP/archive/refs/heads/master.zip && unzip master.zip
echo ${SUCCESS_MSG}

@ -0,0 +1,35 @@
# ESP32 Code
If you would like to edit the code, feel free to edit `esp32.c`
Feel free to change any options in the Makefile to help it work for your system.
For example, where the Arduino libraries are held, the connecting baud rate, etc.
Should work by default in most distributions.
## Installing Dependencies
To install the dependencies for the board, use the `make install-deps` command.
You will also need to manually install the following packages/libraries:
* `pyserial`, a Python library
* `pip install pyserial`
* `tmux` and `screen` for serial viewing
* `apt install tmux screen`
* `pacman -S tmux screen`
* etc.
* `arduino-cli` from your package manager
## Compiling The Code
To compile the source file, run the following command: `make`
## Upload the code
If you would like to upload the code to a connected device, use the `make upload` command.
## Troubleshooting
If you recieve an error about the `serial` package is not found, use the following command to install Python's serialization library:
```bash
$ pip install pyserial

@ -0,0 +1,4 @@
board_manager:
additional_urls:
- https://dl.espressif.com/dl/package_esp32_index.json

@ -0,0 +1,58 @@
#include <Arduino.h>
#include <types.h>
#include <TinyGPS++.h> // the TinyGPS++ librarie
//#include <HardwareSerial.h> // to convert serial from the GPS into something TinyGPS can understand
#include <WiFi.h> // from the ESP32 plugin
#include <AsyncTCP.h> // for basic TCP t/rx
#include <ESPAsyncWebServer.h> // for web server impl.
//#include <SoftwareSerial.h> // to send data back over USB
#define GPS_TX_PIN 1
#define GPS_RX_PIN 3
const char* SSID = "Bytetools Technologies Inc.";
const char* PASS = "Fuck commies #69420!";
AsyncWebServer server(80);
TinyGPSPlus gps;
//HardwareSerial SerialGPS(1);
// Load variables into globals
void setup() {
Serial.begin(9600);
//SerialGPS.begin(9600, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
WiFi.begin(SSID, PASS);
Serial.print("Connecting to wifi");
Serial.print(".");
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.print(".");
}
Serial.println(WiFi.localIP());
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
request->send(200, "text/plain", "HELO");
});
server.begin();
}
// loop forever
void loop() {
/*
//while (SerialGPS.available() > 0) {
//gps.encode(SerialGPS.read());
if (gps.location.isUpdated()) {
Serial.println("HELLO");
Serial.print("LAT=");
Serial.println(gps.location.lat());
Serial.print("LON=");
Serial.println(gps.location.lng());
Serial.print("ALT=");
Serial.println(gps.altitude.meters());
} else {
Serial.println("INVALID LOCATION");
}
//}
*/
//Serial.println("Nothing in buffer.");
//delay(1000);
}
Loading…
Cancel
Save