Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to MQTT using Home Assistant #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vessosa
Copy link

@vessosa vessosa commented Jan 25, 2022

-code refactor adding mqtt and replacing the sequencer from thingspeak to mqtt.
-changed delay to 10s to publish to mqtt
-added comments of how to get the mqtt key

-code refactor adding mqtt and replacing the sequencer from thingspeak to mqtt.
-changed delay to 10s to publish to mqtt
-added comments of how to get the mqtt key
@vessosa vessosa changed the title -removed thingspeak as it's not necessary anymore Added support to MQTT using Home Assistant Jan 25, 2022
@vessosa
Copy link
Author

vessosa commented Jan 25, 2022

image

@vessosa
Copy link
Author

vessosa commented Jan 25, 2022

more info

@Tokugero
Copy link

Tokugero commented Sep 4, 2022

FWIW I just tested this and it worked flawlessly. Great writeup and submission, please merge!

@Assunto
Copy link

Assunto commented Feb 4, 2023

Hi!

I'm back to searching for a way to get my co2/air temp sensor to actually power on properly and send values in Home Assistant (it's an aquaponics kit) when I happened across this Pull Request. For some reason all the other sensors power on and work as expected, but the co2 sensor does not. I believe it has to do with the amount of power it receives not being enough... so I have been trying to figure out if it's possible to delay the startup of all the other sensors so that the co2 sensor can start with all the power the huzzah32 can provide.

My question: If you're using Home Assistant, why aren't you going through ESPHome? Also, because ESPHome integrates with Arduino code, is there anyway to merge your improvements with them so that both thingspeak and Arduino are no longer necessary and those using Home Assistant can keep all the programming in-house via ESPHome?

Thanks!

@Lasakro
Copy link

Lasakro commented Apr 30, 2023

Help please, novice with Github here.

I'm having difficulty with one sentence from the write up: "Check out the library for Atlas Scientific EZO devices in I2C mode at #16".

There is no download option here. I installed gh CLI on Ubuntu, logged in, ran gh pr checkout 16 and received not a git repo.

Where can I find hydroponics_mqtt.ino, pool_mqtt.ino (preferably) along with Adruino_mqtt.h?

@Atlas-Scientific
Copy link
Owner

@Lasakro you can download or clone the fork itself from https://github.com/vessosa/Ezo_I2c_lib/tree/hydroponics_kit_mqtt

@Lasakro
Copy link

Lasakro commented May 2, 2023

I'm obviously newer to both Github & Arduino. Hardware not so much software. I'm starting with a new Adafruit HUZZAH32 to make sure I can get it to do what I what before purchasing the Hydroponics Kit. It does work fine with the default code.

I followed the EZO instructions, Installed esp32, skipped ThingSpeak and the default EZO_and installed this library from the zip. Opened Example hydroponics_kit_mqtt. I set my Wifi & mqtt details but receive the following errors when compiling. Any idea?

`/home/bob/Arduino/libraries/Ezo_I2c_lib-hydroponics_kit_mqtt/Ezo_i2c.cpp: In member function 'void Ezo_board::send_cmd_with_num(const char*, float, uint8_t)':
/home/bob/Arduino/libraries/Ezo_I2c_lib-hydroponics_kit_mqtt/Ezo_i2c.cpp:37:56: error: call of overloaded 'String(float&, uint8_t&)' is ambiguous
String temp = String(cmd )+ String(num, decimal_amount);
^
In file included from /home/bob/.arduino15/packages/esp32/hardware/esp32/2.0.8/cores/esp32/Arduino.h:176,
from /home/bob/Arduino/libraries/Ezo_I2c_lib-hydroponics_kit_mqtt/Ezo_i2c.h:28,
from /home/bob/Arduino/libraries/Ezo_I2c_lib-hydroponics_kit_mqtt/Ezo_i2c.cpp:2:
/home/bob/.arduino15/packages/esp32/hardware/esp32/2.0.8/cores/esp32/WString.h:79:18: note: candidate: 'String::String(long long unsigned int, unsigned char)'
explicit String(unsigned long long, unsigned char base = 10);
^~~~~~
/home/bob/.arduino15/packages/esp32/hardware/esp32/2.0.8/cores/esp32/WString.h:78:18: note: candidate: 'String::String(long long int, unsigned char)'
explicit String(long long, unsigned char base = 10);
^~~~~~
/home/bob/.arduino15/packages/esp32/hardware/esp32/2.0.8/cores/esp32/WString.h:77:18: note: candidate: 'String::String(double, unsigned int)'
explicit String(double, unsigned int decimalPlaces = 2);
^~~~~~
/home/bob/.arduino15/packages/esp32/hardware/esp32/2.0.8/cores/esp32/WString.h:76:18: note: candidate: 'String::String(float, unsigned int)'
explicit String(float, unsigned int decimalPlaces = 2);
^~~~~~
/home/bob/.arduino15/packages/esp32/hardware/esp32/2.0.8/cores/esp32/WString.h:75:18: note: candidate: 'String::String(long unsigned int, unsigned char)'
explicit String(unsigned long, unsigned char base = 10);
^~~~~~
/home/bob/.arduino15/packages/esp32/hardware/esp32/2.0.8/cores/esp32/WString.h:74:18: note: candidate: 'String::String(long int, unsigned char)'
explicit String(long, unsigned char base = 10);
^~~~~~
/home/bob/.arduino15/packages/esp32/hardware/esp32/2.0.8/cores/esp32/WString.h:73:18: note: candidate: 'String::String(unsigned int, unsigned char)'
explicit String(unsigned int, unsigned char base = 10);
^~~~~~
/home/bob/.arduino15/packages/esp32/hardware/esp32/2.0.8/cores/esp32/WString.h:72:18: note: candidate: 'String::String(int, unsigned char)'
explicit String(int, unsigned char base = 10);
^~~~~~
/home/bob/.arduino15/packages/esp32/hardware/esp32/2.0.8/cores/esp32/WString.h:71:18: note: candidate: 'String::String(unsigned char, unsigned char)'
explicit String(unsigned char, unsigned char base = 10);
^~~~~~

exit status 1

Compilation error: exit status 1`

@Atlas-Scientific
Copy link
Owner

@Lasakro That was fixed in this issue #17. Since this branch takes from an older version of the code it didn't get this fix.

So what you can do is download/clone the main version of this code and make sure that works. Then download this code and take the file hydroponics_kit_mqtt.ino and copy it into your own code. The mqtt library comes from adafruit. We're not officially supporting mqtt right now so its gonna be up to you and others to make sure this code works past a certain point.

@Lasakro
Copy link

Lasakro commented May 3, 2023

@Atlas-Scientific I'd be happy documenting my progress here for a future merge back in. That's a little beyond my knowingness with Github ATM, unless you have a better idea. What's working and where it stops:

1) Follow EZO Instructions & Verify "Sent to ThingSpeak" msg.
2) Install Arduino MQTT Library.
3) File "Open" hydroponics_kit_mqtt.ino. Make changes to Wifi & MQTT. Upload.

Works! "Sending data to mqtt"

As for the Mosquitto broker, HA complains about loading the configuration.yaml changes from this fork but it still loads. See’s it as unsupported/Outdated. This is the updated version showing only one channel. As per HERE.

5) Modify configuration.yaml:
mqtt: sensor: - name: "PM" state_topic: "sensors/hydroponics-kit/ph" unit_of_measurement: "PH" value_template: "{{ value_json.PM }}" availability: - topic: "sensors/hydroponics-kit/ph" payload_available: "online" payload_not_available: "offline" json_attributes_topic: "sensors/hydroponics-kit/ph"

My Mosquitto broker is still is not seeing the EZO device. Reading up HA with Adafruit MQTT next.

MQTT

@Lasakro
Copy link

Lasakro commented May 3, 2023

Update: My Mosquitto broker "Listen to a topic" function does see "sensors/hydroponics-kit/ph". It's that the HA Entity is not being created.

@Lasakro
Copy link

Lasakro commented May 3, 2023

This works. I had a typo and was calling PH instead PM. I saw the entity PM but just pushed this off thinking maybe AM/PM had 2 entities.

So this now works for Hydroponics Kit. Now going to see if I can make it work for what I need, Pool Kit. Changing EC to ORP.

@allover326
Copy link

How can we calibrate the probes via MQTT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants