Skip to content

Instantly share code, notes, and snippets.

@MechanicalCoder
Created April 21, 2016 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MechanicalCoder/3bf207834348f7079e000afbf9c0f826 to your computer and use it in GitHub Desktop.
Save MechanicalCoder/3bf207834348f7079e000afbf9c0f826 to your computer and use it in GitHub Desktop.
#include "application.h"
unsigned int nextTime = 0; // Next time to contact the server
const int gasOutput = A0;
// int DangerLight = D7;
float MidConcThreshold = 650;
// float HighConcThreshold =1000;
float CurrentValue=0;
int i=0;
void setup() {
Serial.begin(9600);
// pinMode(DangerLight, OUTPUT);
}
void loop() {
CurrentValue = analogRead(gasOutput);
Serial.println("Keep Calm. no danger !");
Spark.publish("Gas_Concentration",String(CurrentValue));
delay(1000);
}
@MechanicalCoder
Copy link
Author

A sample code on using spark.publish() method to send data to the cloud server. The cloud API URL and other credentials are mentioned in application.h file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment