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

About the command "String msg ="{xxxx}"; #1916

Open
jmguilbert opened this issue Mar 16, 2024 · 2 comments
Open

About the command "String msg ="{xxxx}"; #1916

jmguilbert opened this issue Mar 16, 2024 · 2 comments

Comments

@jmguilbert
Copy link

Hello and thank you for your often quick and helpful responses.
I need to better understand a command you use in the "temperature" example on a DIY sensor.
This is the one I would like to adapt to other sensors:
String msg = "{"model":"ESP32TEMP","id":"" + NodeId + "","tempc":" + String(temp) + "}";

1- I understand that this line sends a message to OMG so that it translates the sensor data into MQTT.

  • the "temp" variable comes from float.
    But where does “tempc” come from?
    Is this a “topic” that OMG can recognize?
    If so, what other topics could we use?
    For example to send a weight collected by HX711.

2- More generally, could you direct me to a doc so that I can learn how to form a "String msg" by myself without disturbing you.

A big thank you from France.
Jean Marc.

@1technophile
Copy link
Owner

But where does “tempc” come from?

tempc is the key used by OMG to understand that this is a temperature in Celsius

All the properties used in the Theengs decoder could be used, example:
https://github.com/theengs/decoder/blob/121e69989bdfa5831b2f91d181bb838b8e115097/src/devices/XMTZC05HMKG_json.h#L39

In your case it could be:

String msg = "{"model":"ESP32WGHT","id":"" + NodeId + "","weight":" + String(weight) + "}";

@jmguilbert
Copy link
Author

Many thanks.

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

No branches or pull requests

2 participants