WATERfalls

entire sctructure small

structure overview

action shot small

working close up

Flexor

Motion
Pressure
icon-car.pngKML-LogoFullscreen-LogoQR-code-logoGeoJSON-LogoGeoRSS-LogoWikitude-Logo
WATERfalls

loading map - please wait...

WATERfalls 18.946780, 72.792910
Arduino Components diagram

Arduino Components diagram

 

/*
3 sensor feed to Xively, Flexor, Pressure, Motion

##Xively WiFi Sensor Tutorial##
This sketch is designed to take sensors (from photocell) and upload the values to Xively
at consistant intervals. At the same time it gets a setable value from Xively to adjust the brigthness
of an LED. This sketch is reusable and can be adapted for use with many different sensors.
Derived from Xively Ardino Sensor Client by Sam Mulube.

By Calum Barnes 3-4-2013
BSD 3-Clause License – [http://opensource.org/licenses/BSD-3-Clause]
Copyright (c) 2013 Calum Barnes
*/
#include
#include
#include
#include

char ssid[] = “TP-LINK_MR3040_8F7B3B”; // your network SSID (name)
char pass[] = “67101870”; // your network password (use for WPA, or use as key for WEP)
//int keyIndex = 0; // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

// Your Xively key to let you upload data
char xivelyKey[] = “FOyV9NXPpL72zKUU9Jn7F6tDm7ktheeBIqQlPZ1SPMfHC9jg”;
//your xively feed ID
#define xivelyFeed 283454569
//datastreams
// JEFF char sensorID[] = “sensePin”;
//char ledID[] = “LED_CHANNEL”;
char sensorIDf[] = “Flexor”;
char sensorIDp[] = “Pressure”;
char sensorIDm[] = “Motion”;

// Analog pin which we’re monitoring (0 and 1 are used by the Ethernet shield)
// JEFF #define sensePin 0
//led connected pin
//#define ledPin 9

#define Flexor A0
//analog pin pressure
#define Pressure A1
//digital connected pin motion
#define Motion 2

// Define the strings for our datastream IDs
XivelyDatastream datastreams[] = {
// JEFF XivelyDatastream(sensorID, strlen(sensePin), DATASTREAM_FLOAT),

XivelyDatastream(sensorIDf, strlen(sensorIDf), DATASTREAM_FLOAT),
XivelyDatastream(sensorIDp, strlen(sensorIDp), DATASTREAM_FLOAT),
XivelyDatastream(sensorIDm, strlen(sensorIDm), DATASTREAM_FLOAT),
//XivelyDatastream(ledID, strlen(ledID), DATASTREAM_FLOAT),
};

// Finally, wrap the datastreams into a feed
XivelyFeed feed(xivelyFeed, datastreams, 3 /* number of datastreams */);

WiFiClient client;
XivelyClient xivelyclient(client);

void printWifiStatus() {
// print the SSID of the network you’re attached to:
Serial.print(“SSID: “);
Serial.println(WiFi.SSID());

// print your WiFi shield’s IP address:
IPAddress ip = WiFi.localIP();
Serial.print(“IP Address: “);
Serial.println(ip);

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print(“signal strength (RSSI):”);
Serial.print(rssi);
Serial.println(” dBm \n”);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//pin setup
// JEFF pinMode(sensePin, INPUT);

pinMode(Flexor, INPUT);
pinMode(Pressure, INPUT);
pinMode(Motion, INPUT);
//pinMode(ledPin, OUTPUT);

Serial.println(“Starting multiple datastream upload to Xively…”);
Serial.println();

// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print(“Attempting to connect to SSID: “);
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println(“Connected to wifi”);
printWifiStatus();
}

void loop() {
//adjust LED level. set from Xively
/*int getReturn = xivelyclient.get(feed, xivelyKey); //get data from xively
if(getReturn > 0){
Serial.println(“LED Datastream”);
Serial.println(feed[1]);
}else Serial.println(“HTTP Error”);

//write value to LED – change brightness
int level = feed[1].getFloat();
if(level < 0){
level = 0;
}else if(level > 255){
level = 255;
}
//actually write the value
digitalWrite(ledPin, level);
*/
///////////////////////////////////////////////////////
//read sensor values
// JEFF int sensorValue = analogRead(sensePin);
// JEFF datastreams[0].setFloat(sensorValue);

int sensorValue_f = analogRead(Flexor);
datastreams[0].setFloat(sensorValue_f);

int sensorValue_p = analogRead(Pressure);
datastreams[1].setFloat(sensorValue_p);

int sensorValue_m = analogRead(Motion);
datastreams[2].setFloat(sensorValue_m);

//print the sensor valye
// JEFF Serial.print(“Force Cell”);
// JEFF Serial.println(datastreams[0].getFloat());

Serial.print(“Flexor”);
Serial.println(datastreams[0].getFloat());

Serial.print(“Pressure”);
Serial.println(datastreams[1].getFloat());

Serial.print(“Motion”);
Serial.println(datastreams[2].getFloat());

//send value to xively
Serial.println(“Uploading it to Xively”);
int ret = xivelyclient.put(feed, xivelyKey);
//return message
Serial.print(“xivelyclient.put returned “);
Serial.println(ret);
Serial.println(“”);

//delay between calls
delay(10000);
}

——————————————————————————————-

/*
LEDs responding to Flexor, Pressure and Motion sensors
*/
// Flexiforce quick start example
// Reads A0 every 100ms and sends voltage value over serial

int pirPin = 2; //motion sensor

const int ledPinR = 10;
const int ledPinG = 9;

void setup()
{
// initialize serial communications
Serial.begin(9600);
pinMode(pirPin, INPUT);
pinMode(ledPinR, OUTPUT);
pinMode(ledPinG, OUTPUT);
}

void loop()
{
// Read the input on analog pin 1:
int sensorValue = analogRead(A1); //pressure

int sensor, degrees; //flexor

int pirVal = digitalRead(pirPin);

// read the voltage from the voltage divider (sensor plus resistor)
sensor = analogRead(0); //flexor

// Convert the analog reading (which goes from 0 – 1023) to a voltage (0 – 5V):
float voltage = sensorValue; //* (5.0 / 1023.0);

// convert the voltage reading to inches
// the first two numbers are the sensor values for straight (768) and bent (853)
// the second two numbers are the degree readings we’ll map that to (0 to 90 degrees)
degrees = map(sensor, 387, 225, 0, 90);
// note that the above numbers are ideal, your sensor’s values will vary
// to improve the accuracy, run the program, note your sensor’s analog values
// when it’s straight and bent, and insert those values into the above function.

// Print out the value you read:
Serial.println(voltage);

// print out the result
Serial.print(“analog input: “);
Serial.print(sensor,DEC);
Serial.print(” degrees: “);
Serial.println(degrees,DEC);

delay(1000);

if (voltage > 500 && degrees < 10){
digitalWrite(ledPinG, HIGH);
}
else {
digitalWrite(ledPinG, LOW);
}

if (pirVal == LOW){ //was motion detected
Serial.println(“Motion Detected”);
digitalWrite(ledPinR, HIGH);
}
else {
digitalWrite(ledPinR, LOW);
}

// Wait 100 milliseconds
delay(200);
}