Skip to content
Snippets Groups Projects
Commit 3a8fbf45 authored by Bilal Hassan's avatar Bilal Hassan
Browse files

-Refactor the code of Soil Moisture sensor to our sensor interface

-main client with currently the moisture sensor,rain,solar radiation sensors
on it
-the hardware of the main station was dested with the privded code and is on my desk
parent efd8d368
No related branches found
No related tags found
5 merge requests!39Merge Develop into Main,!19development into master,!17Inital Host, initial Client,!12-Refactor the code of Soil Moisture sensor to our sensor interface,!6Espnow
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
{
// 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"
]
}
{
"C_Cpp.errorSquiggles": "Disabled"
}
\ No newline at end of file
# Main client station
This is the main client station which has a solar and
-humidity sensor
-rain precipitation
-solarRadiation
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
#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
; 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
#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);
}
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment