Skip to content

Add ESP8285 ELRS receiver as board #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions boards/esp8285-8285.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"comment": "From ExpressLRS project, https://github.com/ExpressLRS/ExpressLRS/blob/master/src/boards/esp8285-8285.json: esp8285 variant for ExpressLRS that uses variant=esp8285 instead of variant=generic",
"build": {
"arduino": {
"ldscript": "eagle.flash.1m256.ld"
},
"core": "esp8266",
"extra_flags": "-DESP8266 -DESP8285 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_ESP01",
"f_cpu": "80000000L",
"f_flash": "40000000L",
"flash_mode": "dout",
"mcu": "esp8266",
"variant": "esp8285"
},
"connectivity": [
"wifi"
],
"frameworks": [
"arduino",
"espidf",
"esp8266-rtos-sdk",
"esp8266-nonos-sdk"
],
"name": "Generic ESP8285 Module",
"upload": {
"maximum_ram_size": 81920,
"maximum_size": 1048576,
"require_upload_port": true,
"resetmethod": "ck",
"speed": 115200
},
"url": "http://www.esp8266.com/wiki/doku.php?id=esp8266-module-family",
"vendor": "Espressif"
}
70 changes: 60 additions & 10 deletions examples/companion_radio/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <InternalFileSystem.h>
#elif defined(ESP32)
#include <SPIFFS.h>
#elif defined(ESP8285) || defined(ESP866)
#include <FS.h>
#endif

#define RADIOLIB_STATIC_ONLY 1
Expand Down Expand Up @@ -92,6 +94,10 @@
#include <helpers/nrf52/TechoBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
static TechoBoard board;
#elif defined(ESP8285)
#include <helpers/ESP8285Board.h>
#include <helpers/CustomSX1276Wrapper.h>
static ESP8285Board board;
#else
#error "need to provide a 'board' object"
#endif
Expand Down Expand Up @@ -244,7 +250,12 @@ class MyMesh : public BaseChatMesh {

void loadContacts() {
if (_fs->exists("/contacts3")) {
File file = _fs->open("/contacts3");

#if defined(ESP8285)
File file = _fs->open("/contacts3", "r");
#else
File file = _fs->open("/contacts3");
#endif
if (file) {
bool full = false;
while (!full) {
Expand Down Expand Up @@ -280,7 +291,11 @@ class MyMesh : public BaseChatMesh {
File file = _fs->open("/contacts3", FILE_O_WRITE);
if (file) { file.seek(0); file.truncate(); }
#else
#if defined(ESP8285)
File file = _fs->open("/contacts3", "w");
#else
File file = _fs->open("/contacts3", "w", true);
#endif
#endif
if (file) {
ContactsIterator iter;
Expand Down Expand Up @@ -316,7 +331,11 @@ class MyMesh : public BaseChatMesh {
sprintf(path, "/bl/%s", fname);

if (_fs->exists(path)) {
File f = _fs->open(path);
#if defined(ESP8285)
File f = _fs->open(path, "r");
#else
File f = _fs->open(path);
#endif
if (f) {
int len = f.read(dest_buf, 255); // currently MAX 255 byte blob len supported!!
f.close();
Expand All @@ -337,8 +356,12 @@ class MyMesh : public BaseChatMesh {
#if defined(NRF52_PLATFORM)
File f = _fs->open(path, FILE_O_WRITE);
if (f) { f.seek(0); f.truncate(); }
#else
#if defined(ESP8285)
File f = _fs->open(path, "w");
#else
File f = _fs->open(path, "w", true);
#endif
#endif
if (f) {
int n = f.write(src_buf, len);
Expand Down Expand Up @@ -657,7 +680,11 @@ class MyMesh : public BaseChatMesh {

// load persisted prefs
if (_fs->exists("/node_prefs")) {
File file = _fs->open("/node_prefs");
#if defined(ESP8285)
File file = _fs->open("/node_prefs", "r");
#else
File file = _fs->open("/node_prefs");
#endif
if (file) {
uint8_t pad[8];

Expand Down Expand Up @@ -731,7 +758,11 @@ class MyMesh : public BaseChatMesh {
File file = _fs->open("/node_prefs", FILE_O_WRITE);
if (file) { file.seek(0); file.truncate(); }
#else
#if defined(ESP8285)
File file = _fs->open("/node_prefs", "w");
#else
File file = _fs->open("/node_prefs", "w", true);
#endif
#endif
if (file) {
uint8_t pad[8];
Expand Down Expand Up @@ -1211,6 +1242,17 @@ class MyMesh : public BaseChatMesh {
#include <helpers/ArduinoSerialInterface.h>
ArduinoSerialInterface serial_interface;
#endif
#elif defined(ESP8285)
#ifdef WIFI_SSID
#ifndef TCP_PORT
#define TCP_PORT 5000
#endif
#include <helpers/esp8285/SerialWifiInterface.h>
SerialWifiInterface serial_interface(TCP_PORT); // Pass TCP_PORT to the constructor
#else
#include <helpers/ArduinoSerialInterface.h>
ArduinoSerialInterface serial_interface;
#endif
#elif defined(NRF52_PLATFORM)
#ifdef BLE_PIN_CODE
#include <helpers/nrf52/SerialBLEInterface.h>
Expand All @@ -1224,15 +1266,15 @@ class MyMesh : public BaseChatMesh {
#endif

#if defined(NRF52_PLATFORM)
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#elif defined(LILYGO_TLORA)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#elif defined(LILYGO_TLORA) || defined(ESP8285)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
#elif defined(P_LORA_SCLK)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
StdRNG fast_rng;
SimpleMeshTables tables;
Expand All @@ -1245,6 +1287,7 @@ void halt() {
void setup() {
Serial.begin(115200);


board.begin();
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
Expand All @@ -1255,6 +1298,8 @@ void setup() {
#if defined(NRF52_PLATFORM)
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
#elif defined(ESP8285)
spi.begin();
#elif defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
Expand Down Expand Up @@ -1304,6 +1349,11 @@ void setup() {
SPIFFS.begin(true);
the_mesh.begin(SPIFFS, trng);

#elif defined(ESP8285)
SPIFFS.begin();
the_mesh.begin(SPIFFS, trng);


#ifdef WIFI_SSID
WiFi.begin(WIFI_SSID, WIFI_PWD);
serial_interface.begin(TCP_PORT);
Expand Down
24 changes: 21 additions & 3 deletions examples/simple_repeater/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <InternalFileSystem.h>
#elif defined(ESP32)
#include <SPIFFS.h>
#elif defined(ESP8285) || defined(ESP866)
#include <FS.h>
#endif

#define RADIOLIB_STATIC_ONLY 1
Expand Down Expand Up @@ -96,6 +98,10 @@
#include <helpers/nrf52/TechoBoard.h>
#include <helpers/CustomSX1262Wrapper.h>
static TechoBoard board;
#elif defined(ESP8285)
#include <helpers/ESP8285Board.h>
#include <helpers/CustomSX1276Wrapper.h>
static ESP8285Board board;
#else
#error "need to provide a 'board' object"
#endif
Expand Down Expand Up @@ -224,6 +230,8 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
File openAppend(const char* fname) {
#if defined(NRF52_PLATFORM)
return _fs->open(fname, FILE_O_WRITE);
#elif defined(ESP8285)
return _fs->open(fname, "a");
#else
return _fs->open(fname, "a", true);
#endif
Expand Down Expand Up @@ -566,7 +574,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
bool formatFileSystem() override {
#if defined(NRF52_PLATFORM)
return InternalFS.format();
#elif defined(ESP32)
#elif defined(ESP32) || defined(ESP8285)
return SPIFFS.format();
#else
#error "need to implement file system erase"
Expand Down Expand Up @@ -598,7 +606,11 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
}

void dumpLogFile() override {
File f = _fs->open(PACKET_LOG_FILE);
#if defined(ESP8285)
File f = _fs->open(PACKET_LOG_FILE, "r");
#else
File f = _fs->open(PACKET_LOG_FILE);
#endif
if (f) {
while (f.available()) {
int c = f.read();
Expand Down Expand Up @@ -632,7 +644,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {

#if defined(NRF52_PLATFORM)
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
#elif defined(LILYGO_TLORA)
#elif defined(LILYGO_TLORA) || defined(ESP8285)
SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
#elif defined(P_LORA_SCLK)
Expand Down Expand Up @@ -678,6 +690,8 @@ void setup() {
#if defined(NRF52_PLATFORM)
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
#elif defined(ESP8285)
spi.begin();
#elif defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
Expand Down Expand Up @@ -712,6 +726,10 @@ void setup() {
SPIFFS.begin(true);
fs = &SPIFFS;
IdentityStore store(SPIFFS, "/identity");
#elif defined(ESP8285)
SPIFFS.begin();
fs = &SPIFFS;
IdentityStore store(SPIFFS, "/identity");
#else
#error "need to define filesystem"
#endif
Expand Down
4 changes: 3 additions & 1 deletion examples/simple_secure_chat/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

#if defined(NRF52_PLATFORM)
#include <InternalFileSystem.h>
#elif defined(ESP32)
#elif defined(ESP32)
#include <SPIFFS.h>
#elif defined(ESP8285) || defined(ESP866)
#include <FS.h>
#endif

#define RADIOLIB_STATIC_ONLY 1
Expand Down
64 changes: 64 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -948,3 +948,67 @@ build_src_filter = ${LilyGo_Techo.build_src_filter}
lib_deps =
${LilyGo_Techo.lib_deps}
densaugeo/base64 @ ~1.4.0


; ----------------- ELRS ESP8285---------------------

[esp82xx_base]
platform = espressif8266
extends = arduino_base
board = esp8285-8285
build_flags =
${arduino_base.build_flags}
-D ESP8285
-D PLATFORM_ESP8266=1
build_src_filter = ${arduino_base.build_src_filter}
monitor_filters = esp8266_exception_decoder
upload_resetmethod = nodemcu

; -- pin defs from https://github.com/ExpressLRS/targets/blob/master/RX/Generic%20900.json
[ELRS_ESP8285_RX]
extends = esp82xx_base
build_flags =
${esp82xx_base.build_flags}
-D RADIO_CLASS=CustomSX1276
-D WRAPPER_CLASS=CustomSX1276Wrapper
-D LORA_TX_POWER=20
-D SERIAL_INTERFACE=Serial
-D P_LORA_DIO_0=4
-D P_LORA_DIO_1=5
-D P_LORA_NSS=15
-D P_LORA_RESET=2
-D P_LORA_SCLK=14
-D P_LORA_MISO=12
-D P_LORA_MOSI=13
-D PIN_RX=3
-D PIN_TX=1
-D PIN_LED_BUILTIN=16
build_src_filter = ${esp82xx_base.build_src_filter}

[env:ELRS_ESP8285_RX_companion_radio_usb]
extends = ELRS_ESP8285_RX
build_flags =
${ELRS_ESP8285_RX.build_flags}
-D MAX_CONTACTS=25 ; crash = 50, 40,
-D MAX_GROUP_CHANNELS=1
build_src_filter =
${ELRS_ESP8285_RX.build_src_filter}
+<src/helpers/*.cpp>
+<../examples/companion_radio/main.cpp>
lib_deps =
${arduino_base.lib_deps}
densaugeo/base64 @ ~1.4.0

[env:ELRS_ESP8285_RX_repeater]
extends = ELRS_ESP8285_RX
build_flags =
${ELRS_ESP8285_RX.build_flags}
-D ADVERT_NAME="\"ELRSRX Repeater\""
-D ADVERT_LAT=-37.0
-D ADVERT_LON=145.0
-D ADMIN_PASSWORD="\"password\""
; -D MESH_PACKET_LOGGING=1
; -D MESH_DEBUG=1
build_src_filter =
${ELRS_ESP8285_RX.build_src_filter}
+<../examples/simple_repeater/main.cpp>
12 changes: 10 additions & 2 deletions src/helpers/CommonCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ static uint32_t _atoi(const char* sp) {

void CommonCLI::loadPrefs(FILESYSTEM* fs) {
if (fs->exists("/node_prefs")) {
File file = fs->open("/node_prefs");
#if defined(ESP8285)
File file = fs->open("/node_prefs", "r");
#else
File file = fs->open("/node_prefs");
#endif
if (file) {
uint8_t pad[8];

Expand Down Expand Up @@ -63,7 +67,11 @@ void CommonCLI::savePrefs(FILESYSTEM* fs) {
File file = fs->open("/node_prefs", FILE_O_WRITE);
if (file) { file.seek(0); file.truncate(); }
#else
File file = fs->open("/node_prefs", "w", true);
#if defined(ESP8285)
File file = fs->open("/node_prefs", "w");
#else
File file = fs->open("/node_prefs", "w", true);
#endif
#endif
if (file) {
uint8_t pad[8];
Expand Down
Loading