This is the first version of the mbed program for the Smart Car Seat developed by the Smart Car Seat Team of GaTech Design Expo Spring 2017.

Dependencies:   Adafruit_FONA FSR SDFileSystem mbed

Fork of Smart_Car_Seat_v1 by Jea Du Kim

Team Members

Bryan Bates – OBD/Bluetooth System
Robert Dunkin – Physical Wiring/Power
Jgenisius Harris – Cooling System
Jea Du Kim – Sensor System
Emily Pitts – Smartphone Application
Tyler Woei-A-Sack – GSM Communications

Advisor

Dr. Mick West

Overview

Car Seat Pic Car Seat Diagram

The purpose of this project was to design a child’s safety car seat with Internet of Things capabilities and a cooling system that activates in the case of an emergency. It is comprised of a network of sensors, a wireless notification system, and a cooling system.

How Does It Work

The Smart Car Seat is initially set up using a smartphone application where the user inputs their phone number. The number is saved to an SD card and is read by the GSM module when it sends the text messages. If the infrared thermometers read a critical temperature and the force sensitive resistors detect someone, the cooling system will turn on and a text message will be sent to the phone number on file.

Smart Car Seat Program

Import programSmart_Car_Seat_v1

This is the first version of the mbed program for the Smart Car Seat developed by the Smart Car Seat Team of GaTech Design Expo Spring 2017.

Components

/media/uploads/jd0205/overall_carseat_schematic.jpg

This project involves the usage of the mbed LPC1768.

400

Force Sensitive Resistors

250

This project uses 4 Square FSR Interlink 406, two placed on the seat and two placed on the back rest to detect if someone is sitting on the seat.

mbedFSRVoltage Divider
p20FSR Bottom Left10K
p19FSR Upper Left10K
p18FSR Upper Right10K
p17FSR Bottom Right10K

/media/uploads/jd0205/fsrschematic3.jpg

As they are still resistors, the orientation of the pins do not matter, as long as one end goes into VCC and the other leads to a voltage divider and an AnalogIn like shown in the diagram. With a 10K Ohm voltage divider, a raw analog value of 0.5 for each FSR should be enough to distiguish an object of the size of a small child on the sensor.

Any additional information can be found at the Force Sensitive Resistors page.

Import library

Public Member Functions

FSR (PinName Pin, float resistance)
Create an FSR object.
float readRaw ()
Read the raw data.
float readFSRResistance ()
Read the resistance of the FSR .
float readWeight ()
Read the weight in N.

MLX90614 IR Thermometers

250

This project uses two MLX90614 IR Thermometer placed on the back of the headrest to measure the temperature of the child sitting on the seat and the ambient temperature.

mbedFSRPullupsPulldowns
gndVSS - gnd
VoutVDD - 3.3V0.1uF (to VSS)
p27SCL - I2C Clock10K
p28SDA - I2C Data10K

250

At around room temperature, the Thermometers should read approximately 22 C. When reading the temperature from the palm, the sensors should read approximately between 30 and 35 C.

With the MLX90614 and I2C, you can run up to 127 thermometers through the same SCL and SDA connection as long as they have different 7-bit addresses. The default I2C address for the MLX90614 is 0x5A, but it can be changed with this program.

Import programMLX90614 IR_Temp_Sensor (change address)

I have spent so much time looking into how to change the address of a MLX90614 sensor for use of multiple sensors, so I think it might be helpful to somebody.

Any additional information can be found at the MLX90614 I2C IR Thermometer page.

SD Card File System

250

This project uses the basic SD Card reader that works with the mbed to store all the contact information for the system.

mbedMicroSD Breakout
p8 (DigitalOut)CS
p5 (SPI MOSI)DI
VoutVCC
p7 (SPI SCLK)SCK
GNDGND
p6 (SPI MISO)DO
ncCD

Careful

VCC is the 3.3V from Vout. Using the 5V will damage the SD card.

Information

The project uses a simple .txt file to store a 10-digit phone number. Before operations, check if the file is named correctly and in the correct directory based on your code.

Any additional information can be found at the SD Card File System page.

Import librarySDFileSystem

SDFileSystem

GSM Module

250

This project used the FONA 808 MiniGSM provided from Adafruit to send messages to the contact information stored in the SD Card.

mbedAdafruit FONA
ncBat
GNDGND
ncSPKR+
ncSPKR-
p12Rst
ncPS
GNDKey
p11RI
p14 (Serial RX)TX
p13 (Serial TX)RX
ncNS
Vout (3.3V)Vio

Warning!

Adafruit Fona 800/808 will only work when there's an external battery connected with at least 3.4V. When the battery is at a low level, the MicroUSB charger should be plugged in with the battery. Be careful with low rated batteries as the USB will charge at 4.2V.

Both the 800 and the 808 uses the same protocols, so any additional documentations, information, and project libraries can be found at the Adafruit FONA 800 Project page.

Import library

Data Structures

class EventListener
Listener for FONA events. More...

Public Member Functions

Adafruit_FONA (PinName tx, PinName rx, PinName rst, PinName ringIndicator)
Create instance of the Adafruit_FONA .
bool begin (int baudrate)
Built-in Test to see if FONA is connected.
void setEventListener ( EventListener *eventListener)
Set the event listener for incoming calls.
int readable (void)
Check if FONA has anything in its output buffer.
bool getADCVoltage (uint16_t *v)
Get ADC voltage from external pin.
bool getBattPercent (uint16_t *p)
Get battery percentage level.
bool getBattVoltage (uint16_t *v)
Get battery voltage level.
bool unlockSIM (char *pin)
Unlock SIM if needed.
uint8_t getSIMCCID (char *ccid)
Get the SIM chip card interface device (CCID)
uint8_t getNetworkStatus (void)
Get the Network Status of FONA.
uint8_t getRSSI (void)
Get the RSSI of the network signal.
uint8_t getIMEI (char *imei)
Get the International Mobile Station Equipment Identity (IMEI)
bool setAudio (uint8_t a)
Set the Audio Output interface.
bool setVolume (uint8_t i)
Set the Audio Volume.
uint8_t getVolume (void)
Get the Audio Volume.
bool tuneFMradio (uint16_t station)
Tune the FM radio.
bool FMradio (bool onoff, uint8_t a=FONA_HEADSETAUDIO)
FM radio set output.
bool setFMVolume (uint8_t i)
Set the FM Radio Volume.
int8_t getFMVolume ()
Get the FM Volume.
int8_t getFMSignalLevel (uint16_t station)
Get the FM signal strength.
bool setSMSInterrupt (uint8_t i)
Set the SMS Interrupt.
uint8_t getSMSInterrupt (void)
Get SMS Interrupt Setting.
int8_t getNumSMS (void)
Set the SMS Interrupt.
bool readSMS (uint8_t i, char *smsbuff, uint16_t max, uint16_t *readsize)
Read SMS.
bool sendSMS (char *smsaddr, char *smsmsg)
Send SMS.
bool deleteSMS (uint8_t i)
Delete SMS.
bool getSMSSender (uint8_t i, char *sender, int senderlen)
Send SMS.
bool enableNetworkTimeSync (bool onoff)
Enable FONA to sync time with the cellular network.
bool enableNTPTimeSync (bool onoff, const char *ntpserver=0)
Enable FONA to sync time with the time server.
bool getTime (char *buff, uint16_t maxlen)
Retrieve the current time from the enabled server.
bool setPWM (uint16_t period, uint8_t duty=50)
Control the buzzer capability of the PWM out on the FONA.
bool callPhone (char *phonenum)
Call a phone.
bool hangUp (void)
Hang up a phone call.
bool pickUp (void)
Answer a phone call.
bool callerIdNotification (bool enable)
Enable/disable caller ID.
bool incomingCallNumber (char *phonenum)
Retrieve the incoming call number.

Bluetooth Module

250

This project uses the HC-05 Bluetooth Module to connect with an Android app to update or change contact information stored in the SD Card.

mbedBluetooth
p9 (TX)RX
p10 (RX)TX
GNDGND
VoutVCC

The Bluetooth module simple acts as a wireless Serial connection, so there is no need for additional Libraries other than the Serial.

Any additional information about Serial connections can be found at the Serial page.

Import librarymbed

No documentation found.

Cooling System

250 250

The Cooling System involves the use of a MOSFET Relay and a combination of 5V Fans, Peltier Plates, and Heatsinks to provide cold air when commanded to.

mbedMOSFET RelayCooling System
gndJP2-2 - gnd
5VJP2-1 - RAW
p16JP2-3 - Control
JP1-1Device (Neg)
JP1-2Device (Pos)

Any additional information about Relays can be found here.

Revision:
0:5a4b2c91de63
Child:
1:a33e55fecf16
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 03 21:14:11 2017 +0000
@@ -0,0 +1,178 @@
+#include "mbed.h"
+#include "FSR.h"
+
+#include <ctype.h>
+#include <string>
+
+#include "SDFileSystem.h"
+#include "Adafruit_FONA.h"
+
+#define FONA_RST p12
+#define FONA_TX p13
+#define FONA_RX p14
+#define FONA_RI p11
+
+Serial pcSerial(USBTX, USBRX);
+
+DigitalOut led1(LED1);      //Fona status - on(connecting), off(disconnecting)
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);      //Pressure status - on(child on seat), off(off seat)
+DigitalOut led4(LED4);      //Temperature status - on(Too hot), off(not hot)
+
+Adafruit_FONA fona(FONA_TX, FONA_RX, FONA_RST, FONA_RI);    //GSM
+
+SDFileSystem sd(p5, p6, p7, p8, "sd");      //SD card reader
+
+DigitalOut CtrlRelay(p16);      //Relay Controller
+
+FSR bottomFSR1(p20, 10); // Pin 17-20 is used as the AnalogIn pin and a 10k resistor is used as a voltage divider for the FSR
+FSR topFSR1(p19, 10);
+FSR topFSR2(p18, 10);
+FSR bottomFSR2(p17, 10);
+
+I2C i2c(p28, p27);      //I2C commands
+
+Serial bt(p9, p10);     //Bluetooth module
+
+float temp, avgTemp; //temperature in degrees C
+const int addr1 = 0xB4;     //Default MLX90614 address - 0x5A
+const int addr2 = 0x08;     //Changed another MLX90614 address to 0x04
+char data[3];
+bool danger;
+int onForce;
+
+float temp1,temp2,temp3,temp4,avgF;
+
+char pnum[22];
+char message[141]= "Emergency! Your child is still in the Smart Car Seat!";
+//Message to send to phone and contacts
+
+class FonaEventListener : public Adafruit_FONA::EventListener {
+    virtual void onRing() {
+        led1 = 1;
+    }
+    
+    virtual void onNoCarrier() {
+        led1 = 0; 
+    }
+};
+FonaEventListener fonaEventListener;
+//GSM Module initalization
+
+bool onSeat(float fLevel);      //Checks if there is a child on the seat
+float readTemp(int addr, char* cmd);    //Reads the temperature through the I2/C
+void callback(void);        //Changes the stored number on the SD card
+
+int main() {
+    pcSerial.baud(9600);        //Set the serial baudrate to 9600
+    wait(2);                    //Wait 2 secs to initialize and settle
+    i2c.frequency(50000);       //Set the I2C frequency to 50kHz for the MLX90614
+    wait(2);                    //Wait another 2 secs for initalization
+    
+    
+    char cmd1[1];
+    char cmd2[1];
+    cmd1[0] = 0x07;     //Command to read object temperature
+    cmd2[0] = 0x06;     //Command to read ambient temperature
+    
+    
+    pcSerial.printf("FONA basic test\r\n");
+    pcSerial.printf("Initializing....(May take 3 seconds)\r\n");
+    // See if the FONA is responding
+    if (! fona.begin(9600)) {
+        pcSerial.printf("Couldn't find FONA\r\n");
+        while (1);
+    }
+    fona.setEventListener(&fonaEventListener);
+    pcSerial.printf("FONA is OK\r\n");
+    
+    
+    bt.attach(&callback);       //Allows the app to change the phone number
+    
+    
+    //Reads the stored phone number
+    FILE *fpr = fopen("/sd/mydir/myphone.txt", "r");
+    if(fpr == NULL) {
+        error("Could not open file for read\n");
+    }
+    fscanf(fpr,"%s", pnum); 
+    pcSerial.printf("Phone Number: %s\n", pnum);
+    fclose(fpr);
+    
+    
+    danger = false;
+    
+    while (1) {
+        if (onSeat(0.2))        //Checks if child is on the seat
+                                // 0.2 is very low, 0.5 for moderate touch, 0.8 for heavy pressing
+        {   
+            led3 = 1;
+            
+            temp1 = readTemp(addr1, cmd1);      //Read object temperature (C)
+            temp2 = readTemp(addr2, cmd1);
+            //temp3 = readTemp(addr1, cmd2);    //Read ambient temperature (C)
+            //temp4 = readTemp(addr2, cmd2);
+            
+            avgTemp = (temp1+temp2)/2;          //Average value
+            //avgTemp = (temp3+temp4)/2;
+            printf("%5.2f\r\n",avgTemp);
+            
+            if ( avgTemp > 30)      //If value exceed a "bad" temperature
+            {
+                led4 = 1;
+                CtrlRelay = 1;      //Turn on cooling system
+                danger = true;
+            } else if ( avgTemp < 25)   //When it falls back down
+            {
+                led4 = 0;
+                CtrlRelay = 0;      //Turn off cooling system
+            }
+            if (danger) {       //When child is in "danger"
+                fona.sendSMS(pnum, message);    //FONA will send message to the contact
+            }
+        } else {
+            led3 = 0;
+            led4 = 0;
+            CtrlRelay = 0;      //When child is no longer on the seat
+            danger = false;     //The system resets
+        }
+        wait(1);
+    }
+}
+
+float readTemp(int addr, char* cmd) {   //read the value from the MLX90614
+    i2c.write(addr, cmd, 1, true);
+    i2c.read(addr, data, 3);        //Two bytes of data + 1 word of codes
+    
+    temp = (((float)((data[1]<<8)|data[0]))*0.02) - 273.15;
+    return temp;
+}
+
+bool onSeat(float fLevel) {     //Detects child by activating enough pressure sensors
+    onForce = 0;
+    if  (bottomFSR1.readRaw() > fLevel) {
+        onForce += 1;
+    }
+    if  (bottomFSR2.readRaw() > fLevel) {
+        onForce += 1;
+    }
+    if  (topFSR1.readRaw() > fLevel) {
+        onForce += 1;
+    }
+    if  (topFSR2.readRaw() > fLevel) {
+        onForce += 1;
+    }
+    return onForce >= 2;
+}
+
+void callback(void) {       //Rewrites the phone number saved in the SD card
+    bt.gets(pnum,11);
+    pcSerial.printf("New number: %s\n", pnum);
+            
+    FILE *fp = fopen("/sd/mydir/myphone.txt", "w");
+    if(fp == NULL) {
+        error("Could not open file for write\n");
+    }
+    fprintf(fp, "%s\n", pnum);
+    fclose(fp);
+}
\ No newline at end of file