From 01f5f1b5ba7349622fd9bb4647dbc705e54f58fe Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Sat, 22 Jan 2022 00:01:32 -0800 Subject: [PATCH 1/4] initial dockerfile and notes --- Dockerfile | 16 ++++++++++++++++ docker.txt | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 Dockerfile create mode 100644 docker.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..2f9c3a604 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu +MAINTAINER Kevin Hester + +RUN apt-get update +RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install wget python3 g++ zip python3-venv git vim +RUN wget https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py -O get-platformio.py; chmod +x get-platformio.py +RUN python3 get-platformio.py +RUN git clone https://github.com/meshtastic/Meshtastic-device.git +RUN cd Meshtastic-device; git submodule update --init --recursive +# only build the simulator +RUN sed -i 's/^BOARDS_ESP32.*/BOARDS_ESP32=""/' Meshtastic-device/bin/build-all.sh +RUN sed -i 's/^BOARDS_NRF52.*/BOARDS_NRF52=""/' Meshtastic-device/bin/build-all.sh +RUN sed -i 's/echo "Building SPIFFS.*/exit/' Meshtastic-device/bin/build-all.sh +RUN . ~/.platformio/penv/bin/activate; cd Meshtastic-device; ./bin/build-all.sh + +CMD ["/Meshtastic-device/release/latest/bins/universal/meshtasticd_linux_amd64"] diff --git a/docker.txt b/docker.txt new file mode 100644 index 000000000..af2c9c0b0 --- /dev/null +++ b/docker.txt @@ -0,0 +1,17 @@ +To build: + docker build -t meshtastic/device . + +To run: + docker run --rm -p 4403:4403 meshtastic/device +or, to get a shell on the docker image: + docker run -it meshtastic/device bash + +To use python cli against it: + meshtastic --info --host localhost + +To stop: + # run this to get id + docker ps + # tip: you can just use the first few characters of the id in the next command + docker kill + From bfd9938507d8be612fb9fa2c8f1a27db510505d2 Mon Sep 17 00:00:00 2001 From: Vladislav Osmanov <7123463+osmanovv@users.noreply.github.com> Date: Sat, 22 Jan 2022 16:13:52 +0300 Subject: [PATCH 2/4] RFM95/SX127x support in DIY --- variants/meshtastic_diy_v1/variant.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/variants/meshtastic_diy_v1/variant.h b/variants/meshtastic_diy_v1/variant.h index 8dbfe0e47..d1724340e 100644 --- a/variants/meshtastic_diy_v1/variant.h +++ b/variants/meshtastic_diy_v1/variant.h @@ -24,6 +24,7 @@ #define RF95_NSS 18 // supported modules list +#define USE_RF95 // RFM95/SX127x #define USE_SX1262 #define USE_SX1268 #define USE_LLCC68 @@ -36,6 +37,10 @@ #define SX126X_RXEN 14 #define SX126X_TXEN 13 +// RX/TX for RFM95/SX127x +#define RF95_RXEN 14 +#define RF95_TXEN 13 + #ifdef EBYTE_E22 // Internally the TTGO module hooks the SX126x-DIO2 in to control the TX/RX switch // (which is the default for the sx1262interface code) From 16ee75313a6d6b95559406f0c0f54452c3809884 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 22 Jan 2022 15:09:17 -0600 Subject: [PATCH 3/4] BME280 support for environment and screen re-org (#1129) --- platformio.ini | 1 + proto | 2 +- src/mesh/generated/radioconfig.pb.h | 8 ++-- .../esp32/EnvironmentalMeasurementPlugin.cpp | 38 ++++++++++++++++--- .../esp32/EnvironmentalMeasurementPlugin.h | 3 ++ 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/platformio.ini b/platformio.ini index a9a1903ab..faef20896 100644 --- a/platformio.ini +++ b/platformio.ini @@ -123,6 +123,7 @@ lib_deps = h2zero/NimBLE-Arduino@1.3.4 tobozo/ESP32-targz@^1.1.4 arduino-libraries/NTPClient#531eff39d9fbc831f3d03f706a161739203fbe2a + adafruit/Adafruit BME280 Library@^2.2.2 # Hmm - this doesn't work yet # board_build.ldscript = linker/esp32.extram.bss.ld diff --git a/proto b/proto index 62cb78fcb..60cf05456 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 62cb78fcbe2563f48b190b67cb6fc19fc463064d +Subproject commit 60cf0545612bde3daf53f319db1b72d053f870d3 diff --git a/src/mesh/generated/radioconfig.pb.h b/src/mesh/generated/radioconfig.pb.h index c48224585..3b71a7629 100644 --- a/src/mesh/generated/radioconfig.pb.h +++ b/src/mesh/generated/radioconfig.pb.h @@ -95,7 +95,9 @@ typedef enum _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType { RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20 = 1, RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12 = 2, RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21 = 3, - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 = 4 + RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 = 4, + RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280 = 5, + RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680 = 6 } RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType; /* Struct definitions */ @@ -220,8 +222,8 @@ typedef struct _RadioConfig { #define _InputEventChar_ARRAYSIZE ((InputEventChar)(InputEventChar_KEY_BACK+1)) #define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 -#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22+1)) +#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680 +#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME680+1)) #ifdef __cplusplus diff --git a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp index 08056ea5b..8545b3769 100644 --- a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp +++ b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp @@ -11,10 +11,13 @@ #include #include #include +#include +#include #define DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 #define DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 #define DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 +#define BME280_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS 1000 #define FAILED_STATE_SENSOR_READ_MULTIPLIER 10 #define DISPLAY_RECEIVEID_MEASUREMENTS_ON_SCREEN true @@ -50,11 +53,12 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() radioConfig.preferences.environmental_measurement_plugin_recovery_interval = 60; radioConfig.preferences.environmental_measurement_plugin_display_farenheit = false; radioConfig.preferences.environmental_measurement_plugin_sensor_pin = 13; + radioConfig.preferences.environmental_measurement_plugin_sensor_type = RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType:: - RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20; + RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280; */ - + if (!(radioConfig.preferences.environmental_measurement_plugin_measurement_enabled || radioConfig.preferences.environmental_measurement_plugin_screen_enabled)) { // If this plugin is not enabled, and the user doesn't want the display screen don't waste any OSThread time on it @@ -96,6 +100,17 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() DEBUG_MSG("EnvironmentalMeasurement: Opened DHT21/DHT22 on pin: %d\n", radioConfig.preferences.environmental_measurement_plugin_sensor_pin); return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280: + unsigned bmeStatus; + // Default i2c address for BME280 + bmeStatus = bme.begin(0x76); + if (!bmeStatus) { + DEBUG_MSG("Could not find a valid BME280 sensor, check wiring, address, sensor ID!"); + // TODO more verbose diagnostics + } else { + DEBUG_MSG("EnvironmentalMeasurement: Opened BME280 on default i2c bus"); + } + return (BME280_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); default: DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin"); return (INT32_MAX); @@ -146,6 +161,8 @@ int32_t EnvironmentalMeasurementPlugin::runOnce() case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21: case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22: return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280: + return (BME280_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); default: return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS); } @@ -223,10 +240,10 @@ void EnvironmentalMeasurementPlugin::drawFrame(OLEDDisplay *display, OLEDDisplay last_temp = String(CelsiusToFarenheit(lastMeasurement.temperature), 0) + "°F"; ; } - - display->drawString(x, y += fontHeight(FONT_MEDIUM), - lastSender + ": " + last_temp + "/" + String(lastMeasurement.relative_humidity, 0) + "%(" + - String(agoSecs) + "s)"); + display->drawString(x, y += fontHeight(FONT_MEDIUM) - 2, "From: " + lastSender + "(" + String(agoSecs) + "s)"); + display->drawString(x, y += fontHeight(FONT_SMALL) - 2,"Temp/Hum: " + last_temp + " / " + String(lastMeasurement.relative_humidity, 0) + "%"); + if (lastMeasurement.barometric_pressure != 0) + display->drawString(x, y += fontHeight(FONT_SMALL),"Press: " + String(lastMeasurement.barometric_pressure, 0) + "hPA"); } bool EnvironmentalMeasurementPlugin::handleReceivedProtobuf(const MeshPacket &mp, EnvironmentalMeasurement *p) @@ -242,6 +259,7 @@ bool EnvironmentalMeasurementPlugin::handleReceivedProtobuf(const MeshPacket &mp DEBUG_MSG("EnvironmentalMeasurement: Received data from %s\n", sender); DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", p->relative_humidity); DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", p->temperature); + DEBUG_MSG("EnvironmentalMeasurement->barometric_pressure: %f\n", p->barometric_pressure); lastMeasurementPacket = packetPool.allocCopy(mp); @@ -289,6 +307,12 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des m.relative_humidity = this->dht->readHumidity(); m.temperature = this->dht->readTemperature(); break; + case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_BME280: + m.temperature = bme.readTemperature(); + m.relative_humidity = bme.readHumidity(); + // TODO Work out standard units for pressure. This is in hPa from the Adafruit example + m.barometric_pressure = bme.readPressure() / 100.0F; + break; default: DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin"); return false; @@ -296,6 +320,7 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des DEBUG_MSG("EnvironmentalMeasurement->relative_humidity: %f\n", m.relative_humidity); DEBUG_MSG("EnvironmentalMeasurement->temperature: %f\n", m.temperature); + DEBUG_MSG("EnvironmentalMeasurement->barometric_pressure: %f\n", m.barometric_pressure); sensor_read_error_count = 0; @@ -303,6 +328,7 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des p->to = dest; p->decoded.want_response = wantReplies; + DEBUG_MSG("EnvironmentalMeasurement: Sending packet to mesh"); service.sendToMesh(p); return true; } diff --git a/src/plugins/esp32/EnvironmentalMeasurementPlugin.h b/src/plugins/esp32/EnvironmentalMeasurementPlugin.h index e60a84c8b..9eed72c8f 100644 --- a/src/plugins/esp32/EnvironmentalMeasurementPlugin.h +++ b/src/plugins/esp32/EnvironmentalMeasurementPlugin.h @@ -6,6 +6,8 @@ #include #include #include +#include +#include class EnvironmentalMeasurementPlugin : private concurrency::OSThread, public ProtobufPlugin { @@ -36,6 +38,7 @@ class EnvironmentalMeasurementPlugin : private concurrency::OSThread, public Pro DHT *dht; OneWire *oneWire; DS18B20 *ds18b20; + Adafruit_BME280 bme; const MeshPacket *lastMeasurementPacket; uint32_t sensor_read_error_count = 0; }; \ No newline at end of file From 61e1b8d8592044d9c5912d13876f47b37212e4d8 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sat, 22 Jan 2022 19:24:47 -0600 Subject: [PATCH 4/4] Set lastMeasurementPacket as one we're sending (#1130) --- src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp index 8545b3769..3e6e6152d 100644 --- a/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp +++ b/src/plugins/esp32/EnvironmentalMeasurementPlugin.cpp @@ -328,6 +328,7 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des p->to = dest; p->decoded.want_response = wantReplies; + lastMeasurementPacket = packetPool.allocCopy(*p); DEBUG_MSG("EnvironmentalMeasurement: Sending packet to mesh"); service.sendToMesh(p); return true;