|
| 1 | +/* |
| 2 | +A DIY, easy, no PCB, basic but powerful node based on E22 900M33S and |
| 3 | +Pro Micro compatible NRF52840 dev boards such as the Tenstar Robot |
| 4 | +Supermini or Nice Nano. |
| 5 | +
|
| 6 | +Without adding GPS or other peripherals, this node should run about 45 |
| 7 | +hours on a 1S 1000 mAh battery. |
| 8 | +
|
| 9 | +This node can be constructed by directly soldering the development |
| 10 | +board directly to an EBYTE E22 900m30S. There will be 7 directly |
| 11 | +soldered pads, 3 header pins, and only 1 wire connection required. |
| 12 | +
|
| 13 | +You can power the node via USB or a battery, or you can install a power |
| 14 | +connector on the GND and VCC pads of the E22; a JST PH or XH socket |
| 15 | +should fit. It may be easiest to install this first if you want it. |
| 16 | +
|
| 17 | +Note that the E22-900M33S will output near it's specified power level |
| 18 | +only when supplied with 5-5.5 volts. If you take advantage of the |
| 19 | +battery charger on the Pro Micro board and power everything from a 1S |
| 20 | +Lithium battery, the E22-900M33S will output a maximum of about 1 |
| 21 | +Watt. |
| 22 | +
|
| 23 | +Be sure to perform the initial flash of the Meshtastic firmware before |
| 24 | +proceeding with the assembly to protect the E22 and ensure that the |
| 25 | +TXEN pad is not driven when it shouldn't be. |
| 26 | +
|
| 27 | +Detailed build instructions can be found here: |
| 28 | +https://github.com/brad112358/easy_E22?tab=readme-ov-file#easy-diy-e22-nrf52840-build-instructions |
| 29 | +
|
| 30 | +*/ |
| 31 | + |
| 32 | +#ifndef _VARIANT_EASY_PROMICRO_DIY_ |
| 33 | +#define _VARIANT_EASY_PROMICRO_DIY_ |
| 34 | + |
| 35 | +/** Master clock frequency */ |
| 36 | +#define VARIANT_MCK (64000000ul) |
| 37 | + |
| 38 | +// #define USE_LFXO // Board uses 32khz crystal for LF |
| 39 | +#define USE_LFRC // Board uses RC for LF |
| 40 | + |
| 41 | +#define PROMICRO_DIY_TCXO |
| 42 | + |
| 43 | +/*---------------------------------------------------------------------------- |
| 44 | + * Headers |
| 45 | + *----------------------------------------------------------------------------*/ |
| 46 | + |
| 47 | +#include "WVariant.h" |
| 48 | + |
| 49 | +#ifdef __cplusplus |
| 50 | +extern "C" { |
| 51 | +#endif // __cplusplus |
| 52 | + |
| 53 | +/* |
| 54 | +E22/NRF52 PRO MICRO PIN ASSIGNMENT |
| 55 | +
|
| 56 | +| Pin | Function | | Pin | Function | |
| 57 | +| ----- | ----------- | --- | -------- | ------------ | |
| 58 | +| Gnd | | | vbat | | |
| 59 | +| P0.06 | Serial2 RX | | vbat | | |
| 60 | +| P0.08 | Serial2 TX | | Gnd | | |
| 61 | +| Gnd | | | reset | | |
| 62 | +| Gnd | GND | | ext_vcc | *see 0.13 | |
| 63 | +| P0.17 | Free pin | | P0.31 | BATTERY_PIN | |
| 64 | +| P0.20 | Free pin | | P0.29 | DI01 | |
| 65 | +| P0.22 | Free pin | | P0.02 | BUSY | |
| 66 | +| P0.24 | Free pin | | P1.15 | NRST | |
| 67 | +| P1.00 | TXEN | | P1.13 | MISO | |
| 68 | +| P0.11 | RXEN | | P1.11 | MOSI | |
| 69 | +| P1.04 | SDA | | P0.10 | SCK | |
| 70 | +| P1.06 | SCL | | P0.09 | NSS | |
| 71 | +| | | | | | |
| 72 | +| | Mid board | | | Internal | |
| 73 | +| P1.01 | Free pin | | 0.15 | LED | |
| 74 | +| P1.02 | GPS_RX | | 0.13 | 3V3_EN | |
| 75 | +| P1.07 | GPS_TX | | | | |
| 76 | +*/ |
| 77 | + |
| 78 | +// Number of pins defined in PinDescription array |
| 79 | +#define PINS_COUNT (48) |
| 80 | +#define NUM_DIGITAL_PINS (48) |
| 81 | +#define NUM_ANALOG_INPUTS (1) |
| 82 | +#define NUM_ANALOG_OUTPUTS (0) |
| 83 | + |
| 84 | +// Pin 13 enables 3.3V periphery. |
| 85 | +// #define PIN_3V3_EN (0 + 13) // P0.13 |
| 86 | + |
| 87 | +// Battery |
| 88 | +#define BATTERY_PIN (0 + 31) // P0.31 |
| 89 | +#define ADC_CHANNEL ADC1_GPIO4_CHANNEL |
| 90 | +#define ADC_RESOLUTION 14 |
| 91 | +#define BATTERY_SENSE_RESOLUTION_BITS 12 |
| 92 | +#define BATTERY_SENSE_RESOLUTION 4096.0 |
| 93 | +// Definition of milliVolt per LSB => 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096 |
| 94 | +#define VBAT_MV_PER_LSB (0.73242188F) |
| 95 | +// Voltage divider value => 1.5M + 1M voltage divider on VBAT = (1.5M / (1M + 1.5M)) |
| 96 | +#define VBAT_DIVIDER (0.6F) |
| 97 | +// Compensation factor for the VBAT divider |
| 98 | +#define VBAT_DIVIDER_COMP (2.02) // 2 + magic for current drain of input |
| 99 | +// Fixed calculation of milliVolt from compensation value |
| 100 | +#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) |
| 101 | +#undef AREF_VOLTAGE |
| 102 | +#define AREF_VOLTAGE 3.0 |
| 103 | +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 |
| 104 | +#define ADC_MULTIPLIER VBAT_DIVIDER_COMP // REAL_VBAT_MV_PER_LSB |
| 105 | +#define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x) |
| 106 | + |
| 107 | +// WIRE IC AND IIC PINS |
| 108 | +#define WIRE_INTERFACES_COUNT 1 |
| 109 | + |
| 110 | +#define PIN_WIRE_SDA (32 + 4) // P1.04 |
| 111 | +#define PIN_WIRE_SCL (32 + 6) // P1.06 |
| 112 | + |
| 113 | +// LED |
| 114 | +#define PIN_LED1 (0 + 15) // P0.15 |
| 115 | +#define LED_BUILTIN PIN_LED1 |
| 116 | +// Actually red |
| 117 | +#define LED_BLUE PIN_LED1 |
| 118 | +#define LED_STATE_ON 1 // State when LED is lit |
| 119 | + |
| 120 | +// Button |
| 121 | +#define BUTTON_PIN (-1) // no button |
| 122 | + |
| 123 | +// GPS |
| 124 | +#define PIN_GPS_TX (32 + 7) // P1.07 |
| 125 | +#define PIN_GPS_RX (32 + 2) // P1.02 |
| 126 | + |
| 127 | +#define PIN_GPS_EN (0 + 13) // P0.13 3.3V enable |
| 128 | +#define GPS_POWER_TOGGLE |
| 129 | +#define GPS_UBLOX |
| 130 | +// define GPS_DEBUG |
| 131 | + |
| 132 | +// UART interfaces |
| 133 | +#define PIN_SERIAL1_RX PIN_GPS_TX |
| 134 | +#define PIN_SERIAL1_TX PIN_GPS_RX |
| 135 | + |
| 136 | +#define PIN_SERIAL2_RX (0 + 6) // P0.06 |
| 137 | +#define PIN_SERIAL2_TX (0 + 8) // P0.08 |
| 138 | + |
| 139 | +// Serial interfaces |
| 140 | +#define SPI_INTERFACES_COUNT 1 |
| 141 | + |
| 142 | +#define PIN_SPI_MISO (32 + 13) // P1.13 |
| 143 | +#define PIN_SPI_MOSI (32 + 11) // P1.11 |
| 144 | +#define PIN_SPI_SCK (0 + 10) // P0.10 |
| 145 | + |
| 146 | +#define LORA_MISO PIN_SPI_MISO |
| 147 | +#define LORA_MOSI PIN_SPI_MOSI |
| 148 | +#define LORA_SCK PIN_SPI_SCK |
| 149 | +#define LORA_CS (0 + 9) // P0.09 NSS |
| 150 | + |
| 151 | +// LORA MODULE |
| 152 | +#define USE_SX1262 |
| 153 | + |
| 154 | +#define LORA_DIO0 (0 + 2) // P0.02 BUSY |
| 155 | +#define LORA_DIO1 (0 + 29) // P0.29 IRQ |
| 156 | +#define LORA_RESET (32 + 15) // P1.15 NRST |
| 157 | + |
| 158 | +// SX126X CONFIG |
| 159 | +#undef TX_GAIN_LORA |
| 160 | +#define TX_GAIN_LORA 22 // 8 for E22 900M30S, 25 for 900M33S, 22 for 3.7V battery powered 900M33S, 0 for 900M22S |
| 161 | +#define SX126X_MAX_POWER 8 // 8 for 900M33S, 22 for 900M30S and 900M22S; defaults to 22 if not defined |
| 162 | + |
| 163 | +#define SX126X_CS LORA_CS |
| 164 | +#define SX126X_DIO1 LORA_DIO1 |
| 165 | +#define SX126X_BUSY LORA_DIO0 |
| 166 | +#define SX126X_RESET LORA_RESET |
| 167 | +#define SX126X_RXEN (0 + 11) // P0.11 |
| 168 | +#define SX126X_TXEN (32 + 0) // P1.00 |
| 169 | + |
| 170 | +/* |
| 171 | +| Mfr | Module | TCXO | RF Switch | Notes | |
| 172 | +| ------------ | ---------------- | ---- | --------- | ------------------------------------- | |
| 173 | +| Ebyte | E22-900M22S | Yes | Ext | | |
| 174 | +| Ebyte | E22-900M30S | Yes | Ext | | |
| 175 | +| Ebyte | E22-900M33S | Yes | Ext | MAX_POWER must be set to 8 for this! | |
| 176 | +
|
| 177 | +On the SX1262, DIO3 sets the voltage for an external TCXO, if one is present. If one is not present, use TCXO_OPTIONAL to try both |
| 178 | +settings. |
| 179 | +*/ |
| 180 | + |
| 181 | +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 |
| 182 | +#define TCXO_OPTIONAL // make it so that the firmware can try both TCXO and XTAL |
| 183 | + |
| 184 | +#ifdef __cplusplus |
| 185 | +} |
| 186 | +#endif |
| 187 | + |
| 188 | +/*---------------------------------------------------------------------------- |
| 189 | + * Arduino objects - C++ only |
| 190 | + *----------------------------------------------------------------------------*/ |
| 191 | + |
| 192 | +#endif |
0 commit comments