Skip to content

Commit

Permalink
Merge remote-tracking branch 'tbnobody/OpenDTU/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
helgeerbe committed Oct 31, 2022
2 parents a6d7340 + 3f4b7cb commit 6b4129c
Show file tree
Hide file tree
Showing 19 changed files with 253 additions and 151 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ A heavily incomplete list of trusted hardware shops in germany is:
This list is for your convenience only, the project is not related to any of these shops.

### Power supply
Use a power suppy with 5V and 1A. The USB cable connected to your PC/Notebook may be powerful enough or may be not.
Use a power suppy with 5 V and 1 A. The USB cable connected to your PC/Notebook may be powerful enough or may be not.


## Wiring up
Expand Down Expand Up @@ -146,11 +146,14 @@ This can be achieved by editing the 'platformio.ini' file and add/change one or
* Install git and enable git in vscode - [git download](https://git-scm.com/downloads/) - [Instructions](https://www.jcchouinard.com/install-git-in-vscode/)
* Clone this repository (you really have to clone it, don't just download the ZIP file. During the build process the git hash gets embedded into the firmware. If you download the ZIP file a build error will occur): Inside vscode open the command palette by pressing `CTRL` + `SHIFT` + `P`. Enter `git clone`, add the repository-URL `https://github.com/tbnobody/OpenDTU`. Next you have to choose (or create) a target directory.
* In vscode, choose File --> Open Folder and select the previously downloaded source code. (You have to select the folder which contains the "platformio.ini" file)
* There is a short [Video](https://youtu.be/9cA_esv3zeA) showing these steps.
* Adjust the COM port in the file "platformio.ini" for your USB-serial-converter. It occurs twice:
* upload_port
* monitor_port
* Select the arrow button in the status bar (PlatformIO: Upload) to compile and upload the firmware. During the compilation, all required libraries are downloaded automatically.
* There are two videos showing these steps:
* [Git Clone and compilation](https://youtu.be/9cA_esv3zeA)
* [Full installation and compilation](https://youtu.be/xs6TqHn7QWM)

### on the commandline with PlatformIO Core
* Install [PlatformIO Core](https://platformio.org/install/cli)
* Clone this repository (you really have to clone it, don't just download the ZIP file. During the build process the git hash gets embedded into the firmware. If you download the ZIP file a build error will occur)
Expand Down Expand Up @@ -244,11 +247,11 @@ A documentation of all available MQTT Topics can be found here: [MQTT Documentat
* First: When there is no light on the solar panels, the inverter completely turns off and does not answer to OpenDTU! So if you assembled your OpenDTU in the evening, wait until tomorrow.
* When there is no data received from the inverter(s) - try to reduce the distance between the openDTU and the inverter (e.g. move it to the window towards the roof)
* Under Settings -> DTU Settings you can increase the transmit power "PA level". Default is "minimum".
* The NRF24L01+ needs relatively much current. With bad power supply (and especially bad cables!) a 10uF capacitor soldered directly to the NRF24L01+ board connector brings more stability (pin 1+2 are the power supply). Note the polarity of the capacitor....
* You can try to use an USB power supply with 1A or more instead of connecting the ESP32 to the computer.
* The NRF24L01+ needs relatively much current. With bad power supply (and especially bad cables!) a 10 µF capacitor soldered directly to the NRF24L01+ board connector brings more stability (pin 1+2 are the power supply). Note the polarity of the capacitor
* You can try to use an USB power supply with 1 A or more instead of connecting the ESP32 to the computer.
* Try a different USB cable. Once again, a stable power source is important. Some USB cables are made of much plastic and very little copper inside.
* Double-Check that you have a radio module NRF24L01+ with a plus sign at the end. NRF24L01 module without the plus are not compatible with this project.
* There is no possibility of auto-discovering the inverters. Double-Check you have entered the serial numbers of the inverters correctly.
* Double check that you have a radio module NRF24L01+ with a plus sign at the end. NRF24L01 module without the plus are not compatible with this project.
* There is no possibility of auto-discovering the inverters. Double check you have entered the serial numbers of the inverters correctly.
* OpenDTU needs access to a working NTP server to get the current date & time.
* If your problem persists, check the [Issues on Github](https://github.com/tbnobody/OpenDTU/issues). Please inspect not only the open issues, also the closed issues contain useful information.
* Another source of information are the [Discussions](https://github.com/tbnobody/OpenDTU/discussions/)
Expand Down
2 changes: 1 addition & 1 deletion auto_firmware_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
missing_pkgs = required_pkgs - installed_pkgs

if missing_pkgs:
env.Execute('"$PYTHONEXE" -m pip install dulwich --global-option="--pure"')
env.Execute('"$PYTHONEXE" -m pip install dulwich')

from dulwich import porcelain

Expand Down
5 changes: 5 additions & 0 deletions include/MqttHassPublishing.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "Configuration.h"
#include <Arduino.h>
#include <ArduinoJson.h>
#include <Hoymiles.h>
#include <memory>

Expand Down Expand Up @@ -59,6 +60,10 @@ class MqttHassPublishingClass {

private:
void publishField(std::shared_ptr<InverterAbstract> inv, uint8_t channel, byteAssign_fieldDeviceClass_t fieldType, bool clear = false);
void publishInverterButton(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* icon, const char* category, const char* deviceClass, const char* subTopic, const char* payload);
void publishInverterNumber(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* icon, const char* category, const char* commandTopic, const char* stateTopic, const char* unitOfMeasure, int16_t min = 1, int16_t max = 100);
void publishInverterBinarySensor(std::shared_ptr<InverterAbstract> inv, const char* caption, const char* subTopic, const char* payload_on, const char* payload_off);
void createDeviceInfo(JsonObject& object, std::shared_ptr<InverterAbstract> inv);

bool _wasConnected = false;
bool _updateForced = false;
Expand Down
4 changes: 2 additions & 2 deletions include/MqttSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class MqttSettingsClass {
void init();
void performReconnect();
bool getConnected();
void publish(String subtopic, String payload);
void publishHass(String subtopic, String payload);
void publish(const String& subtopic, const String& payload);
void publishHass(const String& subtopic, const String& payload);

String getPrefix();

Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HM_1CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool HM_1CH::isValidSerial(uint64_t serial)

String HM_1CH::typeName()
{
return String(F("HM-300, HM-350, HM-400"));
return F("HM-300, HM-350, HM-400");
}

const byteAssign_t* HM_1CH::getByteAssignment()
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HM_2CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool HM_2CH::isValidSerial(uint64_t serial)

String HM_2CH::typeName()
{
return String(F("HM-600, HM-700, HM-800"));
return F("HM-600, HM-700, HM-800");
}

const byteAssign_t* HM_2CH::getByteAssignment()
Expand Down
2 changes: 1 addition & 1 deletion lib/Hoymiles/src/inverters/HM_4CH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool HM_4CH::isValidSerial(uint64_t serial)

String HM_4CH::typeName()
{
return String(F("HM-1000, HM-1200, HM-1500"));
return F("HM-1000, HM-1200, HM-1500");
}

const byteAssign_t* HM_4CH::getByteAssignment()
Expand Down
12 changes: 12 additions & 0 deletions lib/Hoymiles/src/inverters/InverterAbstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
InverterAbstract::InverterAbstract(uint64_t serial)
{
_serial.u64 = serial;

char serial_buff[sizeof(uint64_t) * 8 + 1];
snprintf(serial_buff, sizeof(serial_buff), "%0x%08x",
((uint32_t)((serial >> 32) & 0xFFFFFFFF)),
((uint32_t)(serial & 0xFFFFFFFF)));
_serialString = serial_buff;

_alarmLogParser.reset(new AlarmLogParser());
_devInfoParser.reset(new DevInfoParser());
_powerCommandParser.reset(new PowerCommandParser());
Expand All @@ -26,6 +33,11 @@ uint64_t InverterAbstract::serial()
return _serial.u64;
}

const String& InverterAbstract::serialString()
{
return _serialString;
}

void InverterAbstract::setName(const char* name)
{
uint8_t len = strlen(name);
Expand Down
2 changes: 2 additions & 0 deletions lib/Hoymiles/src/inverters/InverterAbstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class InverterAbstract {
explicit InverterAbstract(uint64_t serial);
void init();
uint64_t serial();
const String& serialString();
void setName(const char* name);
const char* name();
virtual String typeName() = 0;
Expand Down Expand Up @@ -64,6 +65,7 @@ class InverterAbstract {

private:
serial_u _serial;
String _serialString;
char _name[MAX_NAME_LENGTH] = "";
fragment_t _rxFragmentBuffer[MAX_RF_FRAGMENT_COUNT];
uint8_t _rxFragmentMaxPacketId = 0;
Expand Down
Loading

0 comments on commit 6b4129c

Please sign in to comment.