Ecosystem for Smart Glass Technology (ESGT) Mbed Configuration


Overview

This wiki demonstrates how The Magicians Senior Design group configured and wired the mbed device from a hardware and software perspective. The team used the mbed as a slave device for a Raspberry Pi 3, which was connected via USB Serial. What this means is that the mbed slave simply collects data from the sensors and sends that data to the Raspberry Pi 3 master. The mbed performs no data manipulation; that processing is left to the Raspberry Pi 3.

Wiring

HTU21D-F

The HTU21D-F is an integrated humidity and temperature sensor from Adafruit, which can be found here.

/media/uploads/itatchi42/_scaled_wiring.jpg

mbedHTU21D-F Cable Connector
Vout (3.3v)Red
Data (p21)Yellow
NCWhite
GNDBlack


/media/uploads/itatchi42/dht11_pinout.jpg

mbedHTU21D-F
Vout (3.3v)Pin 1
Data (p21)Pin 2
NCPin 3
GNDPin 4

Warning!

You'll need a 4.7 kOhm resistor connected between VCC and Data lines, to act as a medium-strength pull up on the data line.


Phototransistor (Light Sensor)

A low-cost phototransistor or photocell is used to determine different lighting levels in a room. They are available at Adafruit for under $1.
/media/uploads/itatchi42/pcschem.png

mbedPhototransistor
Data (p21)Pin 2
GNDPin 4


Information

Orientation of phototransistor pins does not matter.

Warning!

You'll need a 10 kOhm resistor in PARALLEL b/t Lead 2 and Vout (3.3v).


Sharp IR Proximity Sensor

The Sharp IR Sensor is capable of measuring distances of objects ranging from 10cm - 80cm from the sensor. A datasheet for it can be found here.
/media/uploads/itatchi42/sharp-gp2y0a21yk0f-ir-distance-sensor-228x228.jpg

mbedSharp IR Sensor
Vout (3.3v)Red
GNDBlack
AnalogIn (p16)Yellow

Warning!

You'll need a 10 microfarad capacitor between the black and red wires.



Code

main.cpp

#include "mbed.h"
//#include "HTU21D.h"
#include "DHT11.h"

Serial pc(USBTX, USBRX);
float vcc = 3.3;

AnalogIn light(p15); // Light sensor
DHT11 humid(p21); // pwmout... From: https://developer.mbed.org/users/s_inoue_mbed/code/DHT11_Hello_World/file/da7b1c04a659/main.cpp
AnalogIn IR(p16); // Sharp IR 10 - 80 cm
AnalogIn sensor4(p18);
AnalogIn sensor5(p19);
AnalogIn sensor6(p20);


int main() {
    char reqData;
    int state;
    while(1) {
        if (pc.readable()) {
            reqData = pc.getc(); // blocking
            if (reqData == '0') {        
                pc.printf("Light,  Humidity,  Temperature (°F),  ,  DISCONNECTED,  DISCONNECTED");      
            }
            else if (reqData == '1') {                        
                state = humid.readData();
                if (state != DHT11::OK) {
                    pc.printf("ERROR\n");   
                } 
                else {   
                    pc.printf("%4.4f, %d, %4.4f, %4.4f, %4.4f, %4.4f\n", light.read(), humid.readHumidity(), 32.0f + ((float)humid.readTemperature() * (9.0f / 5.0f)), IR.read(), sensor5.read(), sensor6.read());
                    
                }
            } 
            wait(3);
        }
    }
} // end main


Import libraryDHT11

A library for the use of DHT11, a temperature and humidity sensor


Please log in to post comments.