diff --git a/code-snippets/client/main_client_station/.gitignore b/code-snippets/client/main_client_station/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..89cc49cbd652508924b868ea609fa8f6b758ec56 --- /dev/null +++ b/code-snippets/client/main_client_station/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/code-snippets/client/main_client_station/.vscode/extensions.json b/code-snippets/client/main_client_station/.vscode/extensions.json new file mode 100644 index 0000000000000000000000000000000000000000..080e70d08b9811fa743afe5094658dba0ed6b7c2 --- /dev/null +++ b/code-snippets/client/main_client_station/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/code-snippets/client/main_client_station/.vscode/settings.json b/code-snippets/client/main_client_station/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..691a8f68f405ccdc2ba08296bd21c804bbec2ff3 --- /dev/null +++ b/code-snippets/client/main_client_station/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "C_Cpp.errorSquiggles": "Disabled" +} \ No newline at end of file diff --git a/code-snippets/client/main_client_station/README.md b/code-snippets/client/main_client_station/README.md new file mode 100644 index 0000000000000000000000000000000000000000..56969c608fe5ba87344dc2e9902dcdea7bb96215 --- /dev/null +++ b/code-snippets/client/main_client_station/README.md @@ -0,0 +1,6 @@ +# Main client station + +This is the main client station which has a solar and +-humidity sensor +-rain precipitation +-solarRadiation diff --git a/code-snippets/client/main_client_station/include/README b/code-snippets/client/main_client_station/include/README new file mode 100644 index 0000000000000000000000000000000000000000..194dcd43252dcbeb2044ee38510415041a0e7b47 --- /dev/null +++ b/code-snippets/client/main_client_station/include/README @@ -0,0 +1,39 @@ + +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 usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +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/code-snippets/client/main_client_station/include/forte_sensor.hpp b/code-snippets/client/main_client_station/include/forte_sensor.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4ca8e39602ae03062a79a2acb8c25e634521f8b8 --- /dev/null +++ b/code-snippets/client/main_client_station/include/forte_sensor.hpp @@ -0,0 +1,15 @@ +#ifndef _FORTE_SENSOR +#define _FORTE_SENSOR + +// #include "Message.hpp" +template <class T> +class Forte_Sensor { + public: + virtual T read_data() = 0; + virtual void setup() = 0; + //virtual Message build_message() = 0; + + private: +}; + +#endif \ No newline at end of file diff --git a/code-snippets/client/main_client_station/platformio.ini b/code-snippets/client/main_client_station/platformio.ini new file mode 100644 index 0000000000000000000000000000000000000000..e372635876a999ffe1f6f5fa720e6888020d1b13 --- /dev/null +++ b/code-snippets/client/main_client_station/platformio.ini @@ -0,0 +1,23 @@ +; 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:esp32-c3-devkitm-1] +platform = espressif32 +board = esp32-c3-devkitm-1 +;board = esp32dev +framework = arduino +lib_deps = + plerup/EspSoftwareSerial@^6.16.1 + 4-20ma/ModbusMaster@^2.0.1 + adafruit/RTClib@^2.1.1 + sensirion/arduino-sht@^1.2.2 + robtillaart/SHT85@^0.3.2 + fbiego/ESP32Time@^2.0.0 +monitor_speed = 115200 diff --git a/code-snippets/client/main_client_station/src/main.cpp b/code-snippets/client/main_client_station/src/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1b54f6cb59d64730a6e366509db2c849d7a28f35 --- /dev/null +++ b/code-snippets/client/main_client_station/src/main.cpp @@ -0,0 +1,40 @@ +#include "Arduino.h" +#include "rs485.hpp" +#include "ESPNow.hpp" + +Forte_RS485 rs485; +void setup(){ + rs485.setup(); + espnow_setup(); +} + +void loop() +{ + out_data_rs485 data_rs485= rs485.read_data(); + Serial.println("***********************************************************"); + Serial.print("Moisture: "); + Serial.println(data_rs485.moisture); + Serial.print("Moisture Temperature: "); + Serial.println(data_rs485.moisture_temperature); + Serial.print("Solar: "); + Serial.println(data_rs485.solarRadiation); + Serial.print("Rain mm: "); + Serial.println(data_rs485.precipitation); + + //send the data + //moistere 1 + //moisture_temperature 2 + //solarRadiation 3 + //precipitation 4 + + Message new_data = Message{}; + new_data.add_data(data_rs485.moisture,1); + new_data.add_data(data_rs485.moisture_temperature, 2); + new_data.add_data(data_rs485.solarRadiation,3); + new_data.add_data(data_rs485.precipitation,4); + espnow_send_message(new_data); + + + delay(5000); + +} diff --git a/code-snippets/client/main_client_station/test/README b/code-snippets/client/main_client_station/test/README new file mode 100644 index 0000000000000000000000000000000000000000..9b1e87bc67c90e7f09a92a3e855444b085c655a6 --- /dev/null +++ b/code-snippets/client/main_client_station/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html