ESP32 Classic MQTT Publisher & Home Assistant

Started by Graham, February 13, 2020, 05:58:57 PM

Previous topic - Next topic

Urayoan

#75
Hello Graham:
  Setting up the ESP32 and men, how easy it was. Since I am using it, I noted the stage of the Classic never change from resting.

  One idea, is it possible to send to the ESP32 the wake command and then connect to the Classic if necessary? And if still connected keep the connection alive?

  I think with that approach, the modes side of the Classic is not blocked and let the LA run if the mobile app is closed


Thanks

PD. Just in case this helps, the JSON from the broker

{
   "BatTemperature":31.61,
   "NetAmpHours":0,
   "ChargeState":0,
   "InfoFlagsBits":-1308610556,
   "ReasonForResting":1,
   "NegativeAmpHours":0,
   "BatVoltage":54.11,
   "PVVoltage":141.01,
   "VbattRegSetPTmpComp":56.9,
   "TotalAmpHours":200,
   "WhizbangBatCurrent":0.01,
   "BatCurrent":9.81,
   "PVCurrent":3.91,
   "ConnectionState":0,
   "EnergyToday":0.21,
   "EqualizeTime":0,
   "SOC":100,
   "Aux1":false,
   "Aux2":false,
   "Power":533.01,
   "FETTemperature":46.91,
   "PositiveAmpHours":0,
   "TotalEnergy":1231.61,
   "FloatTimeTodaySeconds":5,
   "RemainingAmpHours":200,
   "AbsorbTime":7198,
   "ShuntTemperature":-49.99,
   "PCBTemperature":51.91
}

Graham

Quote from: Urayoan on October 03, 2020, 07:41:32 AM
Hello Graham:
  Setting up the ESP32 and men, how easy it was. Since I am using it, I noted the stage of the Classic never change from resting.

  One idea, is it possible to send to the ESP32 the wake command and then connect to the Classic if necessary? And if still connected keep the connection alive?

  I think with that approach, the modes side of the Classic is not blocked and let the LA run if the mobile app is closed


Thanks


Hi Urayoan

I fixed the issue with the charge state with the esp32 version of the ClassicMQTT publisher. see https://github.com/ClassicDIY/ClassicMQTT/releases/tag/1.3.3

The modbus library I'm using for the ESP32 does not expose a disconnect method, I tried deleting the object but it wouldn't release the classic...

BTW: If you're interested I could add you as a dev on the ClassicDIY repo


Graham

Off-Grid Island cottage, Lac Simon QC Canada
370 Ahrs @ 24V (4 8L16 batteries)
4 x 250watt panels on dual axis trackers http://tinyurl.com/hfpkgr5
Classic 150, Whizbang Jr.
Android Monitor: http://tinyurl.com/lomzq3s

Urayoan

Thank you Graham, did the update and works like a charm!

Ill be honored if you add me to the contributors

Thank you again @Urayoan

mcsarge

Note, in the python version of the ClassicMQTT (run on a raspberry pi or other SBC), it connects, collects the modbus data and disconnects so you are able to sneak the LA in there between polling when you need to.

Matt
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

Urayoan

Thanks Matt. That means y need to acquire some kind of pi to experiment too!

mcsarge

It works on a Pi Zero - getting the Wifi version is the easiest. If you have trouble getting one, I have a ton I can send you one - for the cause!

Matt
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

Urayoan

Quote from: mcsarge on October 08, 2020, 10:30:09 AM
It works on a Pi Zero - getting the Wifi version is the easiest. If you have trouble getting one, I have a ton I can send you one - for the cause!

Matt

Oh Thank you! Let me check first if i can find it and i let you know. When you mean the WiFi version, is because there is separate module to that? Like a hat (is that how is called?)

ClassicCrazy

Quote from: Urayoan on October 08, 2020, 10:41:44 AM
Quote from: mcsarge on October 08, 2020, 10:30:09 AM
It works on a Pi Zero - getting the Wifi version is the easiest. If you have trouble getting one, I have a ton I can send you one - for the cause!

Matt

Oh Thank you! Let me check first if i can find it and i let you know. When you mean the WiFi version, is because there is separate module to that? Like a hat (is that how is called?)

There is the Pi Zero that has no wifi and the Pi Zero W  which has the built in wifi.

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

Urayoan


Frenergy

I seem to be cursed on this exercise.   

I tried first the ESP32 method and everything worked fine. Flashed the module, got success, reset the board and entered my SSID and PW - SAVE.   The port monitor showed the entries but then noting happened. I waited a long time and still nothing. I did the whole procedure 3 times. Always the same result. The Flasher does not invoke a browser window for me to complete the setup and I could never find the ESP32 device anywhere on my wi-fi network with a LAN scanner app, on the PC or tablet.   So ....

Being determined I figured I'd use the pi publisher version,  following the instructions provided.  Everything seemed to work fine until I entered the command (using my own proper variables of course):

"python3 classic_mqtt.py --classic <ClassicHost> --classic_port <502> ........................"

and got this response ....

Traceback (most recent call last):
File "classic_mqtt.py", line 3, in <module>
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
ModuleNotFoundError: No module named 'pymodbus'


I'm not hugely Linux savvy so maybe it's a PATH issue.  One problem I have when I install stuff is I have no idea where the program files have been put. 

Anyway, can anyone help please?  Providing precise Linux CLI commands to solve would be appreciated. Also, I need it to run every time I boot the Rpi3B+. 

TIA


Graham

Quote from: Frenergy on December 03, 2020, 12:27:18 PM
I seem to be cursed on this exercise.   

I tried first the ESP32 method and everything worked fine. Flashed the module, got success, reset the board and entered my SSID and PW - SAVE.   The port monitor showed the entries but then noting happened. I waited a long time and still nothing. I did the whole procedure 3 times. Always the same result. The Flasher does not invoke a browser window for me to complete the setup and I could never find the ESP32 device anywhere on my wi-fi network with a LAN scanner app, on the PC or tablet.   So ....

...

Anyway, can anyone help please?  Providing precise Linux CLI commands to solve would be appreciated. Also, I need it to run every time I boot the Rpi3B+. 

TIA

I can help with the ESP32 version.

If the blue LED is blinking on the ESP then it's in AP mode and needs to be configured to access your wifi. If the flasher program isn't able to send your wifi credentials to the esp you can configure it using a phone.

I made a short video on how to setup the ClassicMQTT using an android phone

https://youtu.be/ya6lDb4gbmk

hope this helps
Graham.
Off-Grid Island cottage, Lac Simon QC Canada
370 Ahrs @ 24V (4 8L16 batteries)
4 x 250watt panels on dual axis trackers http://tinyurl.com/hfpkgr5
Classic 150, Whizbang Jr.
Android Monitor: http://tinyurl.com/lomzq3s

mcsarge

There is alot to unpack there for the python version, I can help.

If you go with the docker solution, it will automatically load all the modules and stuff you need. If you just want to run it, you have to install that stuff yourself.

Have you read this Wiki page? It tells most of the story.

https://github.com/ClassicDIY/ClassicMQTT/wiki/3.-Raspberry-Pi-Classic-MQTT-Publisher

If I were you, I would go with instal #2 "Using Docker"

and make sure that you pay attention to the command that runs the image.
docker run classic_mqtt --classic <ClassicHost> --classic_port <502> --classic_name MyClassic --mqtt <127.0.0.1> --mqtt_port <1883> --mqtt_root <ClassicMQTT> --mqtt_user <username> --mqtt_pass <password>


If you are using Dioty, you need to run it in a similar fashion to this:

docker run classic_mqtt --classic 192.168.0.225 --classic_name MyClassic --mqtt mqtt.dioty.co --mqtt_root /joe.user@gmail.com/ClassicMQTT --mqtt_user joe.user@gmail.com --mqtt_pass <Joe's Dioty password>

If you want, send me the Dioty email message (with password overwritten) and I will build you the commands to run.

Matt

Matt


Quote from: Graham on December 03, 2020, 07:00:08 PM
Quote from: Frenergy on December 03, 2020, 12:27:18 PM
I seem to be cursed on this exercise.   

I tried first the ESP32 method and everything worked fine. Flashed the module, got success, reset the board and entered my SSID and PW - SAVE.   The port monitor showed the entries but then noting happened. I waited a long time and still nothing. I did the whole procedure 3 times. Always the same result. The Flasher does not invoke a browser window for me to complete the setup and I could never find the ESP32 device anywhere on my wi-fi network with a LAN scanner app, on the PC or tablet.   So ....

...

Anyway, can anyone help please?  Providing precise Linux CLI commands to solve would be appreciated. Also, I need it to run every time I boot the Rpi3B+. 

TIA

I can help with the ESP32 version.

If the blue LED is blinking on the ESP then it's in AP mode and needs to be configured to access your wifi. If the flasher program isn't able to send your wifi credentials to the esp you can configure it using a phone.

I made a short video on how to setup the ClassicMQTT using an android phone

https://youtu.be/ya6lDb4gbmk

hope this helps
Graham.
Off Grid Island in Ontario Canada (Beaverstone Bay)
Primary: Classic 150 + wbjr; 3s2p HES 270watt
Winter: SolarBoost 50 MPPT (into wbjr); 2 x Sharp NE-80EJEA 80watt
Pack: 4s2p ROLLS S6-460AGM 6V for 24V pack
Inverter/Charger: Trace DR2424
Call Sign: KG4EUF

ForeverHomestead

I know this is a bit old but I am hoping someone can assist.  I was able to flash my ESP32, when I set up wifi by entering my ssid and password I get it shown on my cmd

{"ssid": "Homestead", "password": "mypassword"}

But the default browser does not open up and I do not see anything connected on my router.  Am I missing something?

Should I see anything else on the cmd interface?

ClassicCrazy

Quote from: ForeverHomestead on January 11, 2021, 03:15:03 PM
I know this is a bit old but I am hoping someone can assist.  I was able to flash my ESP32, when I set up wifi by entering my ssid and password I get it shown on my cmd

{"ssid": "Homestead", "password": "mypassword"}

But the default browser does not open up and I do not see anything connected on my router.  Am I missing something?

Should I see anything else on the cmd interface?
Are you able to get into the Lan list of your router and see if it is showing up there ?
Which IP address did you try connecting to ? 
You will have to connect to the one that is listed on your Lan .
If you see 192.168.4.1 try connecting to that .

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable

ClassicCrazy

Quote from: ForeverHomestead on January 11, 2021, 03:15:03 PM
I know this is a bit old but I am hoping someone can assist.  I was able to flash my ESP32, when I set up wifi by entering my ssid and password I get it shown on my cmd

{"ssid": "Homestead", "password": "mypassword"}

But the default browser does not open up and I do not see anything connected on my router.  Am I missing something?

Should I see anything else on the cmd interface?

Also when I first tried flashing this I found out I needed to hold down the boot button on my ESP32 just before I flashed it - otherwise the flash wouldn't work.

Larry
system 1
Classic 150 , 5s3p  Kyocera 135watt , 12s Soneil 2v 540amp lead crystal for 24v pack , Outback 3524 inverter
system 2
 5s 135w Kyocero , 3s3p 270w Kyocera  to Classic 150 ,   8s Kyocera 225w to Hawkes Bay Jakiper 48v 15kwh LiFePO4 , Outback VFX 3648 inverter
system 3
KID / Brat portable