Things used in this project

Schematics

Schematic
Schematic bb egovvk2pzt

Code

First PhotonC/C++
#include <stdio.h>
#include <stdlib.h>

int counter = 0;
char *message;

void setup() {
    Particle.publish("test", "This is a test");
    Particle.subscribe("test2", handler);
    Particle.variable("Message", message);
}

void loop() {
    
    while(1){
        char buffer[32];
        char *str_counter = itoa(counter, buffer, 10);
        Particle.publish("test", str_counter);
        counter++;
        delay(5000);
    }
}

void handler(const char *event, const char *data){
    if(data){
        message = const_cast<char*> (data);
    }
}
Second PhotonC/C++
#include <stdio.h>
#include <stdlib.h>

int counter = 0;
char *message;

void setup() {
    Particle.publish("test2", "This is a test");
    Particle.subscribe("test", handler);
    Particle.variable("Message", message);
}

void loop() {
    while(1){
        char buffer[32];
        char *str_counter = itoa(counter, buffer, 10);
        Particle.publish("test", str_counter);
        counter++;
        delay(5000);
    }
}

void handler(const char *event, const char *data){
    if(data){
        message = const_cast<char*> (data);
    }
}

Credits

Download
Arduino “having11” Guy
24 projects • 153 followers
I love creating cloud solutions that can interact with hardware along with using Arduino boards and Raspberry Pis to create new projects.
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login