Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

The pi doesn't send the information to mqtt #6

Open
Idaho947 opened this issue Jan 4, 2023 · 3 comments
Open

The pi doesn't send the information to mqtt #6

Idaho947 opened this issue Jan 4, 2023 · 3 comments

Comments

@Idaho947
Copy link

Idaho947 commented Jan 4, 2023

Hello,

I have installed the program and I can read the value of the consumption index. However, I can't see anything in my MQTT broker (installed via mosquito). I don't see any error lines or problems in my configuration. Where can I look for more information (logs..)?

lit

@mmourcia
Copy link

Hello,
I had the same problem as your description.
I found it was due to missing "client_id" when creating mosquitto client instance (https://mosquitto.org/api/files/mosquitto-h.html#mosquitto_new)

int main(int argc, char *argv[])
{
        struct tmeter_data meter_data;
        struct mosquitto *mosq = NULL;
        char buff[MQTT_MSG_MAX_SIZE];
        char meter_id[12];
        char mqtt_topic[64];

        sprintf(meter_id, "%i_%i", METER_YEAR, METER_SERIAL);


        mosquitto_lib_init();
-        mosq = mosquitto_new(NULL, true, NULL);
+        mosq = mosquitto_new("cc1101", true, NULL);
        if(!mosq){
                fprintf(stderr, "ERROR: Create MQTT client failed..\n");
                mosquitto_lib_cleanup();
                return 1;
        }

After having recompiled, I could get this result :

$ ./everblu_meters 
Client cc1101 sending CONNECT
Client cc1101 received CONNACK (0)
Client cc1101 sending SUBSCRIBE (Mid: 1, Topic: WaterUsage , QoS: 2, Options: 0x00)
Client cc1101 received SUBACK
Subscribed (mid: 1): 2

I hope it will help.

@Idaho947
Copy link
Author

Thanks a lot for your help.

@mmourcia
Copy link

Thanks a lot for your help.

did that help ?

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

No branches or pull requests

2 participants