Mizah Bit

Mizah-Bit

finished

View of finished prototype.

open

View of prototypes inner workings.

icon-car.pngKML-LogoFullscreen-LogoQR-code-logoGeoJSON-LogoGeoRSS-LogoWikitude-Logo
Mizah Bit

loading map - please wait...

Mizah Bit 41.021871, 28.976478

/* MIZAH BIT SCRIPT v1
This is a working version of the mizah bit script in which a flex sensor
and thew x and y component of an accelerometer are feeding to the xively
datastream online. In the next version, LED triggering capabilities will
be built in and the accelerometer outputs will be calibrated to fit within
set ranges

*/
#include
#include
#include
#include

char ssid[] = “ITU-NET Misafir”; // your network SSID (name)
//char pass[] = “14507366”; // 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[] = “njYuheTkoW9yHU2ohB2tOm2aV27EuNDi0yDAC7yCrofkl2pa”;
//your xively feed ID
#define xivelyFeed 1905489015
//datastreams
char sensorIDx[] = “AccelX”;
char sensorIDy[] = “AccelY”;
char sensorIDf[] = “Flex”;

// Analog pin which we’re monitoring (0 and 1 are used by the Ethernet shield)
#define sensorPin_x A0
#define sensorPin_y A1
#define sensorPin_f A2

// Define the strings for our datastream IDs
XivelyDatastream datastreams[] = {
XivelyDatastream(sensorIDx, strlen(sensorIDx), DATASTREAM_FLOAT),
XivelyDatastream(sensorIDy, strlen(sensorIDy), DATASTREAM_FLOAT),
XivelyDatastream(sensorIDf, strlen(sensorIDf), 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”);
}

//to hold the caculated values
double x;
double y;
//double z;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//pin setup
pinMode(sensorPin_x, INPUT);
pinMode(sensorPin_y, INPUT);
pinMode(sensorPin_f, INPUT);

Serial.println(“Starting single 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);
// 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”); */

void loop() {
///////////////////////////////////////////////////////
//read sensor values
int sensorValue_x = analogRead(sensorPin_x);
datastreams[0].setFloat(sensorValue_x);

int sensorValue_y = analogRead(sensorPin_y);
datastreams[1].setFloat(sensorValue_y);

int sensorValue_f = analogRead(sensorPin_f);
datastreams[2].setFloat(sensorValue_f);

//print the sensor valye
Serial.print(“AccelX”);
Serial.println(datastreams[0].getFloat());
Serial.print(“AccelY”);
Serial.println(datastreams[1].getFloat());
Serial.print(“Flex”);
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(15000);
}