Coder Social home page Coder Social logo

esp32_to_sma's Introduction

ESP32_to_SMA

This project uses an ESP32 to connect to an SMA SunnyBoy inverter, using Bluetooth.

I have tested it with the SMA Model SB 8000US. This inverter model, circa 2013, has the Bluetooth feature added via an add-on module inside the inverter.

The starting point for this project was the code posted by "stuartpittaway" on github. That really well done project can be found at: https://github.com/stuartpittaway/nanodesmapvmonitor

NOTE: To connect to your ESP32 module, and your inverter, you'll need to change the MAC address constants in the bluetooth.h file, and perhaps the SunnyBoy's login password (contained in the file ESP32_SMA.ino).

CODE CHANGES: I modified / added / subtracted features (compared to nanodesmapvmonitor) in the following ways:

  1. It uses the DOIT ESP32 DEVKIT V1 module by Zerynth, and will probably run on most ESP32 modules. (The nanodesmapvmonitor project uses an Arduino board + USB-to-Bluetooth dongle.)

  2. Does not interfere with, and is not confused by, an existing SMA Sunny Beam display device. No cross-interference.

  3. Removed the PVoutput.org reporting.

  4. I only use the "getInstantACPower()" and "getDailyYield()" functions to extract that information from the inverter. Getting other information from the inverter probably still works, but has not been tested.

  5. Calculates sunrise and sunset times. After sunrise, connects to the SMA inverter. Just before sunset, disconnects the BT connection with the SMA inverter.

NOTES:

  1. In the file ESP32_SMA.ino, there are some commented lines that refer to an Arduino. This refers to a seperate Arduino that is monitoring my house's power consumption, which is an upcoming feature.

TODO:

  1. Fix the code that attempts to use the ESP32 EEPROM to store certain values.

KNOWN BUGS:

  1. The saving of data to EEPROM (via Preferences library) does not work.

esp32_to_sma's People

Contributors

delhatch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

esp32_to_sma's Issues

'class BluetoothSerial' has no member named 'setPin'

This line in bluetooth.ino:

SerialBT.setPin(pin); // pin as in "PIN" This is the BT connection pin, not login pin. ALWAYS 0000, unchangable.

gives an error:

'class BluetoothSerial' has no member named 'setPin'.

I cannot find the cause nor solution. Any idea?

Can't get any byte after connection & connection only last 16 seconds

Hi @delhatch, I was trying out this awesome project but unfortunately I can't get it to work.
I always get this error message: *** FATAL ERROR *** About to do a soft restart of the ESP32 now!

I tried to understand the root cause and found the following:

  • I have to use setPin("0000") otherwise it recognizes 6 zeros instead of 4;
  • Every time, no matter what, when connecting to the SMA it needs to do 10 attempts with BTStart() (is this strange behavior normal?);
  • After it connects successfully it only remains connected for around 16 seconds.

The biggest issue is that I never get any byte from the SMA as after calling initialiseSMAConnection() it waits for SerialBT.available() to become true until the connection drops because of the 16 seconds limit and the fatal error above is returned.

The model of my SMA inverter is SMC 6000A-IT (Sunny Mini Central) and the bluetooth board inside is an SMA Bluetooth Piggy-Back.
I also have an SMA Sunny Beam and that is working fine without any issue, it's NetID is 2.
The software version of the inverter is 12.09.121.R.

Not working with ESP32 2.05 bluetooth

Problem 1: Fail to connect
Bluetooth connect seems to need the name or the MAC with additional arguments
esp_spp_sec_t sec_mask=ESP_SPP_SEC_NONE; // or ESP_SPP_SEC_ENCRYPT|ESP_SPP_SEC_AUTHENTICATE to request pincode confirmation
esp_spp_role_t role=ESP_SPP_ROLE_SLAVE; // or ESP_SPP_ROLE_MASTER
connected = SerialBT.connect(address,0,sec_mask,role);

Problem 2: Returned MAC address is reversed
I have to reverse the order of the check
bool ValidateSenderAddress() {
// Compares the SMA inverter address to the "from" address contained in the message.
// Debug prints "P wrng dest" if there is no match.
return (Level1SrcAdd[5]==smaBTInverterAddressArray[0] &&
Level1SrcAdd[4]==smaBTInverterAddressArray[1] &&
Level1SrcAdd[3]==smaBTInverterAddressArray[2] &&
Level1SrcAdd[2]==smaBTInverterAddressArray[3] &&
Level1SrcAdd[1]==smaBTInverterAddressArray[4] &&
Level1SrcAdd[0]==smaBTInverterAddressArray[5]);
}

Nothing happens from there on.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.