Is it possible to get the data from particle before the data reaches particle cloud

Hi everyone I’m using particle from past few months the mesh technology using thread is amazing. I need a small clarification I have connected few sensors with my particle xenon and using particle.publish to publish the sensor data and subscribing it using particle.subscribe at argon side. And argon is sending the data to raspberry pi via mqtt. When I do this I am able to see the events in the particle cloud. Is it possible to send or get the data without using particle cloud

You can use TCPServer, TCPClient and UDP.
It also depends what MQTT library you are using on the Particles. I think the most common ones use TCP which doesn’t involve the cloud.
And between mesh devices you can use Mesh.publish() and Mesh.subsribe() which will only be local.

1 Like

Thanks for your response.
U mean using tcp server we can access to the particle Device without involving cloud

I’m using mqtt.h library

If you look in that library you will see this in line 128/129 following

    TCPClient _client;

That tells you that this library does in fact use TCPClient to communicate with the MQTT broker.

And this is the function that does the actual communication

bool MQTT::write(uint8_t header, uint8_t* buf, uint16_t length) {
    uint8_t lenBuf[4];
    uint8_t llen = 0;
    uint8_t digit;
    uint8_t pos = 0;
    uint16_t rc;
    uint16_t len = length;
    do {
        digit = len % 128;
        len = len / 128;
        if (len > 0) {
            digit |= 0x80;
        lenBuf[pos++] = digit;
    } while(len > 0);

    buf[4-llen] = header;
    for (int i = 0; i < llen; i++) {
        buf[5-llen+i] = lenBuf[i];
    rc = _client.write(buf+(4-llen), length+1+llen);

    lastOutActivity = millis();
    return (rc == 1+llen+length);

That’s why using a library is only half the fun - the real fun comes with understanding how it works and learning from it :wink:

Your absolutely ryt. Thanks a lot

1 Like