From 2bbe486c825fb8ed36a0dbd5b0306c3f3025d4cb Mon Sep 17 00:00:00 2001 From: Lazarewicz Julien Date: Wed, 21 May 2025 17:11:56 +0200 Subject: [PATCH] Oups no files --- .clang-format | 57 +++++++++++++++++++++++++++++++++++++++++++ include/README | 37 ++++++++++++++++++++++++++++ include/config.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++ include/version.h | 1 + lib/README | 46 +++++++++++++++++++++++++++++++++++ platformio.ini | 21 ++++++++++++++++ src/main.cpp | 41 +++++++++++++++++++++++++++++++ 7 files changed, 264 insertions(+) create mode 100644 .clang-format create mode 100644 include/README create mode 100644 include/config.h create mode 100644 include/version.h create mode 100644 lib/README create mode 100644 platformio.ini create mode 100644 src/main.cpp diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..974946b --- /dev/null +++ b/.clang-format @@ -0,0 +1,57 @@ +--- +BasedOnStyle: Mozilla +AccessModifierOffset: '-4' +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: 'true' +AlignConsecutiveDeclarations: 'true' +AlignOperands: 'true' +AlignTrailingComments: 'true' +AllowAllParametersOfDeclarationOnNextLine: 'true' +AllowShortBlocksOnASingleLine: 'true' +AllowShortCaseLabelsOnASingleLine: 'false' +AllowShortFunctionsOnASingleLine: Empty +AllowShortLoopsOnASingleLine: 'false' +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Allman +BreakBeforeTernaryOperators: 'true' +BreakConstructorInitializers: AfterColon +BreakStringLiterals: 'false' +ColumnLimit: '100' +ConstructorInitializerAllOnOneLineOrOnePerLine: 'false' +ConstructorInitializerIndentWidth: '0' +ContinuationIndentWidth: '4' +Cpp11BracedListStyle: 'false' +DerivePointerAlignment: 'false' +DisableFormat: 'false' +ExperimentalAutoDetectBinPacking: 'true' +IndentCaseLabels: 'true' +IndentWidth: '4' +IndentWrappedFunctionNames: 'false' +JavaScriptQuotes: Single +KeepEmptyLinesAtTheStartOfBlocks: 'false' +Language: Cpp +MaxEmptyLinesToKeep: '2' +NamespaceIndentation: None +ObjCBlockIndentWidth: '4' +ObjCSpaceAfterProperty: 'false' +ObjCSpaceBeforeProtocolList: 'false' +PointerAlignment: Left +ReflowComments: 'true' +SortIncludes: 'false' +SpaceAfterCStyleCast: 'true' +SpaceBeforeAssignmentOperators: 'true' +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: 'false' +SpacesBeforeTrailingComments: '2' +SpacesInAngles: 'false' +SpacesInCStyleCastParentheses: 'false' +SpacesInContainerLiterals: 'false' +SpacesInParentheses: 'false' +SpacesInSquareBrackets: 'false' +Standard: Cpp11 +TabWidth: '4' +UseTab: Always + +... diff --git a/include/README b/include/README new file mode 100644 index 0000000..49819c0 --- /dev/null +++ b/include/README @@ -0,0 +1,37 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the convention is to give header files names that end with `.h'. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/include/config.h b/include/config.h new file mode 100644 index 0000000..e7a2612 --- /dev/null +++ b/include/config.h @@ -0,0 +1,61 @@ +// AHT20 SENSOR ENABLE / DISABLE +#define AHT20_ENABLE true + +// SGP40 SENSOR ENABLE / DISABLE +#define SGP40_ENABLE true + +// BH1750 SENSOR ENABLE / DISABLE +#define BH1750_ENABLE true + +// BATTERY TESTING ENABLE / DISABLE +#define BAT_TEST_ENABLE true + +// Thingsboard library debug +#define THINGSBOARD_ENABLE_DEBUG true + +// Serial debug output +#define SERIAL_DEBUG true +#if SERIAL_DEBUG +#define SERIAL_PRINT_SENSOR_VALUES false +#endif + +constexpr char WIFI_SSID[] = "thingsboard"; +constexpr char WIFI_PASSWORD[] = "thingsboard"; + +// See https://thingsboard.io/docs/getting-started-guides/helloworld/ +// to understand how to obtain an access token +constexpr char TOKEN[] = "HOMECTRL"; +// constexpr char mqtt_attribute_topic[] = "v1/devices/me/attributes"; + +// Thingsboard we want to establish a connection too +constexpr char THINGSBOARD_SERVER[] = "10.42.0.1"; + +// Whether the given script is using encryption or not, +// generally recommended as it increases security (communication with the server is not in clear +// text anymore), it does come with an overhead tough as having an encrypted session requires a lot +// of memory, which might not be avaialable on lower end devices. +#define ENCRYPTED false + +// While we wait for Feather ESP32 V2 to get added to the Espressif BSP, +// we have to select PICO D4 and UNCOMMENT this line! +#define ADAFRUIT_FEATHER_ESP32_V2 + +// Sending data can either be done over MQTT and the PubSubClient +// or HTTPS and the HTTPClient, when using the ESP32 or ESP8266 +#define USING_HTTPS false + +// Enables the ThingsBoard class to be fully dynamic instead of requiring template arguments to +// statically allocate memory. If enabled the program might be slightly slower and all the memory +// will be placed onto the heap instead of the stack. +#define THINGSBOARD_ENABLE_DYNAMIC 1 + +// If the THINGSBOARD_ENABLE_DYNAMIC 1 setting causes this error log message to appear [TB] Unable +// to de-serialize received json data with error (DeserializationError::NoMemory). Simply add this +// configuration line as well. +// #define THINGSBOARD_ENABLE_PSRAM 0 + +// Enables sending messages that are bigger than the predefined message size, +// where the message will be sent byte by byte as a fallback instead. +// Requires an additional library, see https://github.com/bblanchon/ArduinoStreamUtils for more +// information. Simply install that library and the feature will be enabled automatically. +#define THINGSBOARD_ENABLE_STREAM_UTILS 0 \ No newline at end of file diff --git a/include/version.h b/include/version.h new file mode 100644 index 0000000..af8db4f --- /dev/null +++ b/include/version.h @@ -0,0 +1 @@ +#define VERSION "0.0.2" \ No newline at end of file diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..9379397 --- /dev/null +++ b/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into the executable file. + +The source code of each library should be placed in a separate directory +("lib/your_library_name/[Code]"). + +For example, see the structure of the following example libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +Example contents of `src/main.c` using Foo and Bar: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +The PlatformIO Library Dependency Finder will find automatically dependent +libraries by scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..5ac0da4 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,21 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32dev] +platform = https://github.com/pioarduino/platform-espressif32/releases/download/stable/platform-espressif32.zip +board = adafruit_feather_esp32_v2 +framework = arduino +lib_deps = + thingsboard/ThingsBoard@^0.15.0 + adafruit/Adafruit AHTX0@^2.0.5 + adafruit/Adafruit SGP40 Sensor@^1.1.3 + adafruit/Adafruit NeoPixel@^1.12.5 + starmbi/hp_BH1750@^1.0.2 +upload_port = /dev/cu.usbserial-59170079101 diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..9c0da05 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,41 @@ +#include "config.h" +#include "version.h" + +#include "driver/rtc_io.h" + +#define USE_EXT0_WAKEUP 0 + +#include +#include +#include + +#include +#include + +// AHT20 Temperature & Humidity sensor +#if AHT20_ENABLE +#include +#endif + +// SGP40 Air Quality Sensor +#if SGP40_ENABLE +#include +#endif + +// BH1750 Luxmeter +#if BH1750_ENABLE +#include +#endif + +// Battery pin +#define VBATPIN A13 + + + +void setup() +{ + +} + +void loop() {} +