Things used in this project

Hardware components:
Wunderbar relayr 02 1024x1024
WunderBar
×1
Platinchen (Arduino compatible board plus integrated BLE)
×1
Relayr - WunderBar Bridge
×1
Gesture Sensor APDS-9960 - for hands free operation of blender
×1
Proximity Sensor VCNL4000 - for level / volume detection in blender
×1
Eclipse SmartHome supported switch (e.g. Belkin WeMo Switch)
×1

Code

blender.inoC/C++
Platinchen the tiny Arduino compatible board is using following code, receiving sensor data and streaming the data via the Wunderbar Bridge to the Open Cloud
/* 

This code was created during the #HackTheHouse in Berlin
by the blended team - http://www.hackster.io/smarthome/blended
Includes code libraries provided by Sparkfun.com
Code is as it is  - might be changed and comes with no warranty
Download and install latest UART firmware and Arduino Libs from 
relayr gibthub

 */

#include <SoftwareSerial.h>
#include <WunderbarBridge.h>

#include <Wire.h>
#define VCNL4000_ADDRESS 0x13  //I2C Address of the board

#define BRIDGE_DEBUG true

// SoftwareSerial mySerial(8, 10); // RX, TX
const int DEBUG_TX = 10;
const int DEBUG_RX = 8;

/*  Config the bridge module, the 3rd parameter is the baudrate,
    which has to be the same used in the PC serial monitor application*/
Bridge bridge = Bridge(DEBUG_RX, DEBUG_TX, 115200); 

const int led = 2;
const int button = 5;

void setup() {
	pinMode(led, OUTPUT);
	pinMode(button, INPUT);
      
        Wire.begin();  // initialize I2C stuff
        initVCNL4000(); //initilize and setup the board
  	  
	bridge.begin();
}


static char dataOut[18];
/* Main Loop */
void loop() {
	 
	static bridge_payload_t rxPayload;

	if (bridge.newData == true){
		
	rxPayload = bridge.getData();
    
        // no action here
	}

  unsigned int ambientValue = readAmbient(); //can a tiny bit slow
  unsigned int proximityValue = readProximity();

  int length = snprintf(dataOut, 18, "%d", proximityValue );
  bridge.sendData((uint8_t*) dataOut, length);
}

/* the serialEvent() handler is called on every received data 
from the serial port. */
void serialEvent(){
	bridge.processSerial();
}



void initVCNL4000(){
  byte temp = readVCNLByte(0x81);

  if (temp != 0x11){  // Product ID Should be 0x11
    //Serial.print("initVCNL4000 failed to initialize");
    //Serial.println(temp, HEX);
  }else{
    //Serial.println("VNCL4000 Online...");
  } 

  /*VNCL400 init params
   Feel free to play with any of these values, but check the datasheet first!*/
  writeVCNLByte(0x84, 0x0F);  // Configures ambient light measures - Single conversion mode, 128 averages
  writeVCNLByte(0x83, 15);  // sets IR current in steps of 10mA 0-200mA --> 200mA
  writeVCNLByte(0x89, 2);  // Proximity IR test signal freq, 0-3 - 781.25 kHz
  writeVCNLByte(0x8A, 0x81);  // proximity modulator timing - 129, recommended by Vishay 
}


unsigned int readProximity(){
  // readProximity() returns a 16-bit value from the VCNL4000's proximity data registers
  byte temp = readVCNLByte(0x80);
  writeVCNLByte(0x80, temp | 0x08);  // command the sensor to perform a proximity measure

  while(!(readVCNLByte(0x80)&0x20));  // Wait for the proximity data ready bit to be set
  unsigned int data = readVCNLByte(0x87) << 8;
  data |= readVCNLByte(0x88);

  return data;
}


unsigned int readAmbient(){
  // readAmbient() returns a 16-bit value from the VCNL4000's ambient light data registers
  byte temp = readVCNLByte(0x80);
  writeVCNLByte(0x80, temp | 0x10);  // command the sensor to perform ambient measure

  while(!(readVCNLByte(0x80)&0x40));  // wait for the proximity data ready bit to be set
  unsigned int data = readVCNLByte(0x85) << 8;
  data |= readVCNLByte(0x86);

  return data;
}


void writeVCNLByte(byte address, byte data){
  // writeVCNLByte(address, data) writes a single byte of data to address
  Wire.beginTransmission(VCNL4000_ADDRESS);
  Wire.write(address);
  Wire.write(data);
  Wire.endTransmission();
}


byte readVCNLByte(byte address){
  // readByte(address) reads a single byte of data from address
  Wire.beginTransmission(VCNL4000_ADDRESS);
  Wire.write(address);
  Wire.endTransmission();
  Wire.requestFrom(VCNL4000_ADDRESS, 1);
  while(!Wire.available());
  byte data = Wire.read();

  return data;
}

Project logs

Visualize sensor data
Project log #1
On Mar 2, 2015 at 4:13 PM - 0 comments

to further improve the solution we used the relayr Python APIs to stream the sensor data to plot.ly for better analytics of the sensor data - works great!

https://plot.ly/~fab_lab/148

Noice on the level sensor need filtering


Credits

Guido web
fab-lab.eu

Maker!

Contact
Sascha wolter 20131113
Sascha Wolter

Sascha is a Developer, Innovation Manager, and Keynote Speaker with Passion for IoT, Rich Applications and Mobile Apps in all flavors.

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

eyephone
  • 559
  • 8

Full instructions

eyePhone. For creating an innovative solution for helping the blind identify color.

BabyBiCO 1.0
  • 860
  • 11

Work in progress

Smart monitor that tracks babies sleep and sleeping environment in order to give them a better sleep quality.

cantTouchThis
  • 501
  • 7

Full instructions

Cant Touch This is a quick and fun application which uses the Wunderbar Light/Color/Proximity sensor and the relayr Cloud Platform to ale...

WunderSound
  • 524
  • 7

Jam with your washing machine: Accelerometer and Kinect input for sequence generation and sound synthesis.

WunderSound

by Julian Vogels, Khaled Osman, Jose Cunyat on julianvogels.de

Casa Emergencia
  • 537
  • 7

Full instructions

Casa Emergencie - Wunderbar Droidcon 2014 Hackathon Entry

Casa Emergencia

Team WunderGuys

Seat Sentry
  • 841
  • 10

Work in progress

Saving kids lives by improving child seat safety

Seat Sentry

5 members

Add projectSign up / Login