In one of my old blog post we already had a introduction about the Particle IoT platform.As we discussed there particle events have many application and can be integrated to many other IoT services like webhooks,Thingspeak,IFTTT,Ubidots, etc.In this post i am going to share that how to create a webhook to thingspeak from particle.
It is very simple ,actually we are just using the particle event (particle.publish) here.No tactical coding is needed to send data to thingspeak from particle using webhook.for demo purpose i am just showing how to visualize varying analog voltage graphically in thingspeak.Here i am using a potentiometer to change the analog voltage.You can change it to any other sensor and visualize data graphically.even you can embed this graph into your personal site.
Wire up your particle photon as shown in the above circuit.Then open particle Web IDE and upload the below code to your photon.The code is simple it is just publish an event which is publishing the analog voltage on pin A0 in every 1 minute.
Now we have published an event named "value". We can see the updates of this event in particle console.
Now we can create new integration .For that select new integration in console and select webhook
You can see the above screen.Now we have to create a channel in thingspeak and fill the data to above form.Now open thingspeak and create a new account if you are new to thingspeak .Then create a new channel and note the channel API
Now we can fill the webhook form in particle console.Fill the boxes like below
It is very simple ,actually we are just using the particle event (particle.publish) here.No tactical coding is needed to send data to thingspeak from particle using webhook.for demo purpose i am just showing how to visualize varying analog voltage graphically in thingspeak.Here i am using a potentiometer to change the analog voltage.You can change it to any other sensor and visualize data graphically.even you can embed this graph into your personal site.
Wire up your particle photon as shown in the above circuit.Then open particle Web IDE and upload the below code to your photon.The code is simple it is just publish an event which is publishing the analog voltage on pin A0 in every 1 minute.
void setup(){
pinMode(A0,INPUT);
}
void loop() {
// Get some data
int value=analogRead(A0);
String val=String(value);
// Trigger the webhook
Particle.publish("value", val, PRIVATE);
// Wait 60 seconds
delay(60000);
}
Now we have published an event named "value". We can see the updates of this event in particle console.
Now we can create new integration .For that select new integration in console and select webhook
You can see the above screen.Now we have to create a channel in thingspeak and fill the data to above form.Now open thingspeak and create a new account if you are new to thingspeak .Then create a new channel and note the channel API
Now we can fill the webhook form in particle console.Fill the boxes like below
- Event Name=value
- URL=https://api.thingspeak.com/update
- Request type = POST
- Device = Your device name
- api_key: YOUR_API_KEY
- field1: {{PARTICLE_EVENT_VALUE}}
now the webhook to thingspeak is created.Now you can see graphical representation of your sensor values in thingspeak
You can also embed the graph in your site also.
You can also embed the graph in your site also.
No comments:
Post a Comment