Skip to content

Instantly share code, notes, and snippets.

@shiogen
Last active August 29, 2015 14:24
Show Gist options
  • Save shiogen/c0860327f80da3375e73 to your computer and use it in GitHub Desktop.
Save shiogen/c0860327f80da3375e73 to your computer and use it in GitHub Desktop.
Datalogger Sample
//definitions for jumpwire.io
#define jumpwire_io_token "Set_your_token"
#define jumpwire_io_project "A"
#define your_WiFi_SSID "Set_your_ssid"
#define your_WiFi_password "Set_your_password"
#define your_ESP8266_baud_rate 115200
//put your definitions here
//put your global variables here
unsigned long timer;
int sensorPin = A2; //temperture sensor analog pin 2
int sensorValue = 0;
int sensorPin2 = A1; //humidity sensor analog pin 1
int sensorValue2 = 0;
void setup() {
jumpwireIoSetup(); //always put this code in setup()
//put your code here
timer = millis()-50000;
}
void loop() {
jumpwireIoLoop(); //always put this code in loop()
//put your code here
if(millis() - timer > 60000){ //do every minutes
sensorValue = analogRead(sensorPin); //get temperture
float value = modTemp(sensorValue); //convert temperture
sensorValue2 = analogRead(sensorPin2); //get humidity
float value2 = toHumidity(sensorValue2); //convert humidity
Throw('T',value);
Throw('H',value2);
timer = millis();
}
}
void Catch(char key, float value) {
//this function is called when byte values on jumpwire.io server are changed
//put your code here
}
//Convert Voltage into Celcius
float modTemp(int analog_val){
float v = 5; // VCC Voltage
float tempC = ((v * analog_val) / 1024) * 100; // Celcius
return tempC;
}
//Convert Voltage into Relative Humidity
float toHumidity(int analog_val){
float v = 5; // VCC Voltage
float tempC = (analog_val / (1024/v)) * 100; // Percentile
if(tempC > 100){
tempC = 100;
}
return tempC;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment