diff --git a/prototype/esp32/Makefile b/prototype/esp32/Makefile new file mode 100644 index 0000000..d126128 --- /dev/null +++ b/prototype/esp32/Makefile @@ -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} diff --git a/prototype/esp32/README.md b/prototype/esp32/README.md new file mode 100644 index 0000000..a258362 --- /dev/null +++ b/prototype/esp32/README.md @@ -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 diff --git a/prototype/esp32/config.yaml b/prototype/esp32/config.yaml new file mode 100644 index 0000000..7b63f79 --- /dev/null +++ b/prototype/esp32/config.yaml @@ -0,0 +1,4 @@ +board_manager: + additional_urls: + - https://dl.espressif.com/dl/package_esp32_index.json + diff --git a/prototype/esp32/esp32.ino b/prototype/esp32/esp32.ino new file mode 100644 index 0000000..a0d830f --- /dev/null +++ b/prototype/esp32/esp32.ino @@ -0,0 +1,58 @@ +#include +#include +#include // the TinyGPS++ librarie +//#include // to convert serial from the GPS into something TinyGPS can understand +#include // from the ESP32 plugin +#include // for basic TCP t/rx +#include // for web server impl. +//#include // 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); +}