Skip to content

Commit

Permalink
update to .net 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel committed Dec 24, 2023
1 parent 4730257 commit b85016a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 19 deletions.
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Project Overview

Ve.Direct.InfluxDB.Collector is a dedicated data collector that bridges the gap between Victron SmartSolar MPPT devices and InfluxDB. The primary aim of this project is to collect, process, and store data from Victron SmartSolar MPPT devices using the Ve.Direct protocol into an InfluxDB database. The resulting dataset can then be visualized using a Grafana dashboard, providing users with a detailed, real-time overview of their solar energy system's performance.

[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=DocBrown101_Ve.Direct.InfluxDB.Collector&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=DocBrown101_Ve.Direct.InfluxDB.Collector)
Expand All @@ -10,30 +11,48 @@ Ve.Direct.InfluxDB.Collector is a dedicated data collector that bridges the gap
![Preview](https://github.com/DocBrown101/Ve.Direct.InfluxDB.Collector/blob/main/docs/image2.jpg)

## Requirements

To run the Ve.Direct.InfluxDB.Collector, you will need:
* Grafana and InfluxDB docker images
* [The matching Grafana Dashboard](https://grafana.com/grafana/dashboards/14597)
* [A Victron SmartSolar charge controller](https://www.victronenergy.com/solar-charge-controllers)
* A Raspberry Pi or a 24/7 running PC with .NET or MONO and a serial port
* A Ve.Direct cable for connecting the Victron device to the Raspberry Pi or PC

If there are only a few centimeters between the MPPT and the Raspberry Pi, no USB adapter from Victron is needed!
- [Grafana](https://hub.docker.com/r/grafana/grafana/tags?page=1&ordering=last_updated) and [InfluxDB](https://hub.docker.com/_/influxdb/tags?page=1&name=2) docker images
- [The matching Grafana Dashboard](https://grafana.com/grafana/dashboards/14597)
- [A Victron SmartSolar charge controller](https://www.victronenergy.com/solar-charge-controllers)
- A Raspberry Pi or a 24/7 running PC with [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) and a serial port
- Important! As of version 3, [.NET 8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) is required and mono is no longer supported!
- A Ve.Direct cable for connecting the Victron device to the Raspberry Pi or PC
- If there are only a few centimeters between the MPPT and the Raspberry Pi, no USB adapter from Victron is needed!

![Preview](https://github.com/DocBrown101/Ve.Direct.InfluxDB.Collector/blob/main/docs/No-VEDirect-USB.jpg)

![Preview](https://github.com/DocBrown101/Ve.Direct.InfluxDB.Collector/blob/main/docs/Connect-VEDirect-To-RPi.jpg)

## Example Usage

```
/path/to/Ve.Direct.InfluxDB.Collector.exe -o Influx
```

You can alternatively run this as a crontab.
## Systemd service example

```
@reboot /usr/bin/mono -- /path/to/Ve.Direct.InfluxDB.Collector.exe -o Influx >> /var/log/cron.log 2>&1
[Unit]
Description=SolarMetrics
After=network.target
[Service]
User=currentUser
Environment=DOTNET_ROOT=/home/currentUser/dotnet
Environment=PATH=$PATH:/home/currentUser/dotnet
ExecStart=/home/currentUser/git/Ve.Direct.InfluxDB.Collector/build/Ve.Direct.InfluxDB.Collector -i 10 -p /dev/ttyUSB0 --influxDbBucket solar -o Influx
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
```

## Future Plans

I am always working on improving Ve.Direct.InfluxDB.Collector and adding more features, so I welcome contributions and suggestions from the community to improve the functionality of this tool and make it even more useful for all users.

Inspired by https://github.com/oyebayo/vedirect
2 changes: 1 addition & 1 deletion arm64-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dotnet publish ./src/Ve.Direct.InfluxDB.Collector/Ve.Direct.InfluxDB.Collector.c
--self-contained false \
-c Release \
-v minimal \
-f net7.0 \
-f net8.0 \
-o ./build \
-p:PublishReadyToRun=false \
-p:PublishSingleFile=true \
Expand Down
8 changes: 4 additions & 4 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.4" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/Ve.Direct.InfluxDB.Collector/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static int Main(string[] args)
app.HelpOption();
app.OnExecuteAsync(async cancellationToken =>
{
ConsoleLogger.Init(config.DebugOutput, "2.3.6");
ConsoleLogger.Init(config.DebugOutput, "3.0.0");
ConsoleLogger.Debug($"Current output setting: {config.Output}");

try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472;net6.0;net7.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="InfluxDB.Client" Version="4.13.0" />
<PackageReference Include="InfluxDB.Client" Version="4.14.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.0" />
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
<PackageReference Include="System.IO.Ports" Version="8.0.0" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion win-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dotnet publish "$PSScriptRoot\src\Ve.Direct.InfluxDB.Collector\Ve.Direct.InfluxD
-c Release `
-v minimal `
-o ./build `
-f net7.0 `
-f net8.0 `
-p:PublishReadyToRun=false `
-p:PublishSingleFile=true `
-p:CopyOutputSymbolsToPublishDirectory=false `
Expand Down
2 changes: 1 addition & 1 deletion x64-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dotnet publish ./src/Ve.Direct.InfluxDB.Collector/Ve.Direct.InfluxDB.Collector.c
--self-contained false \
-c Release \
-v minimal \
-f net7.0 \
-f net8.0 \
-o ./build \
-p:PublishReadyToRun=false \
-p:PublishSingleFile=true \
Expand Down

0 comments on commit b85016a

Please sign in to comment.