Smart Car Seat

Embedded Car Seat Module

Yotam Mosinzon Bradley Daitch

This page comes to present how a device can be assembled to solve the issue of children suffering from harm due to being left in a hot vehicle. That problem is large scale, as about 45 children lose their lives from heatstroke annually in the US. The hardware layout, joint with the software presented here, are a first model giving some solution to the issue.

In order to prevent a risk to the child, the device will notify the parent by text message and the car alarm if the child is in the seat, the car is turned off and the temperature is in a dangerous range. The circuit presented here simulates this using a TMP102 temperature sensor, an Enfora GSM to send texts, a force sensor to indicate if there is an object on the seat, and an 8-ohm speaker to simulate the car alarm. The Enfora GSM is interfaced using a Pololu Serial Adapter and powered using an external power supply (110 V) and the speaker is driven using a BJT transistor.

/media/uploads/yotammos/block_diagram.png
Figure 1. System Block Diagram

/media/uploads/yotammos/circuit_-_copy.jpg
Figure 2. Photo of Assembled Circuit


Circuit Components:

Enfora GSM

Enfora GSMExternal
1- Powerpower supply*
2 - Serial cablePololu 23201a
  • Wall converter (simulating car 12 Volts outlet)

The GSM/GPRS SA-GL is a compact, stand-alone wireless IP (GSM/GPRS)modem [2]. It is used to send text messages, when a SIM card is inserted to the GSM. A Null modem was used to properly connect the GSM to the Pololu and thus to the mbed.

Configuring the Enfora GSM to default parameters: /media/uploads/yotammos/p2.png
Figure 3. Factory Reset Instruction Documentation [5]

Properly setting the baud rate: /media/uploads/yotammos/p1.png
Figure 4. Data Rate Configuration [5]

Commands can be sent to the gsm through a terminal, like HyperTerminal. The gsm is automatically set up to echo what a user types, so you will see what you type in the terminal before it is sent to the gsm. Like the instruction set pages figures 3 and 4, documentation exists for all instructions. [5]

Important Commands for gsm SMS operations:

1. AT

This command will respond with "OK" and is only intended to verify the AT is ready to receive commands. It can also be used to verify that communication is set up properly.

Only four aadditional commands are needed to succesfully send a text message (after setting the gsm to factory defaults and then fixing a serial baud rate).

2. AT+CSMP=17,167,0,0

This sets the text mode parameters. This is needed after every startup regardless of setting the gsm to factory defaults. These parameters above (17,167,0,0) are default and recommended. See the user guide for more information on alternatives.

3. AT+CMGF=1

This sets the text mode to send texts, as opposed to receiving them. To receive, use 0 as the parameter.

4. AT+CMGS="16782450426"

This sets the phone number to send the text to.

After this, simply type / send what you would like the message to be.

To do all of this is C++ as part of an mbed project, simply use the serial interface for the gsm, let's name it gsm, and use gsm.printf() with C++ syntax for special characters (i.e. \" for "). This can be seen in the imported program from this notebook page. It is unnecessay but possible to use gsm.scanf() to see the gsm respond.

Pololu 23201a

Pololumbed
1- VccVu (5.0 V)
2 - GndGnd
3 - RXp13
4 - TXp14
5 - DSRGnd
6 - CTSGnd

The Pololu 23201a is serial adapter, interfacing between the mbed and GSM.

TMP102

TMP102mbed
1- VccVout (3.3 V)
2 - GndGnd
3 - SDAp9
4 - SCLp10

The temperature sensor is interfaced with the mbed using I2C serial bus.

Library:

Import libraryTMP102

TMP102 published as a library that can be imported independent

8-Ohm Speaker

/media/uploads/yotammos/p3.jpg
Figure 5. Speaker Driver Circuit

A header file for interfacing the speaker, using a PWMOut, was written to properly operate the speaker.

Speaker.h

class Speaker
{
public:
    Speaker(PinName pin) : _pin(pin) {
// _pin(pin) means pass pin to the Speaker Constructor
    }
// class method to play a note based on PwmOut class
    void PlayNote(float frequency, float duration, float volume) {
        _pin.period(1.0/frequency);
        _pin = volume/2.0;
        wait(duration);
        _pin = 0.0;
    }
 
private:
// sets up specified pin for PWM using PwmOut class 
    PwmOut _pin;
};

Phidgets 1106 Force Sensor

TMP102mbed
1- VccVu (5.0 V)
2 - GndGnd
3 - Ainp15

An analog force sensor.


Program Demo

Figure 6. Program Demo Video

In the video, the device was tested, working correctly by texting to the number which was programmed in advance. In the demo, the temperature threshold was lowered to simulate the action in a hot vehicle. The program worked correctly, the speaker made the relevant noise and the text was sent properly.

Main program:

#include "mbed.h"
#include "Speaker.h"
#include "TMP102.h"

#define BUFFER_SIZE 40

AnalogIn fSensor(p15);
TMP102 temp(p9, p10, 0x90);
RawSerial gsm(p13,p14);
RawSerial pc(USBTX,USBRX); // for debugging
DigitalIn carPower(p8); // switch
Speaker speaker(p21);

void make_noise();

void gsm_recv() //receive from gsm, send to pc
{
    while(gsm.readable()) {
        char c = gsm.getc();
        pc.putc(c); //this may take too long
    }
    make_noise();
}

void pc_recv() //receive from pc, send to gsm
{
    while(pc.readable())
        gsm.putc(pc.getc());
}

// Making noise, notifying the area of a child in the car
void make_noise() {
    speaker.PlayNote(969.0, 0.5, 0.5);
    speaker.PlayNote(800.0, 0.5, 0.5);
}

int main() {
    float tempC;
    bool isChild, isHot;
    gsm.baud(115200);
    pc.baud(115200);
    
    pc.attach(&pc_recv, Serial::RxIrq);
    gsm.attach(&gsm_recv, Serial::RxIrq);
    
    while(1) {
        // Getting temp in C
        tempC = temp.read();
        
        // Checking if temp is hot
        isHot = tempC >= 10.0;
        
        // Checking if there is a child in the seat
        isChild = fSensor > 0.9;
        
        carPower ? pc.printf("car on \r\n") : pc.printf("car off \r\n");
        pc.printf("temp = %f\r\n", tempC);
        pc.printf("fSensor = %f\r\n\n", (float) fSensor);
        
        if (isHot && isChild && !carPower) {
            // Sending a text to the user
            wait(10);
            if (!carPower) {
                gsm.printf("AT\r\n");
                wait(2);
                gsm.printf("AT+CSMP=17,167,0,0\r\n");
                wait(2);
                gsm.printf("AT+CMGF=1\r\n");
                wait(2);
                gsm.printf("AT+CMGS=\"+17068298025\"\r\n");
                wait(2);
                gsm.printf("Child is in danger!!! %c\r\n", 0x1A);
            }
        }
        wait(2);
    }
}

Sources:

[1] Enfora GSM Datasheet. [Web]. Available at: http://www.testech-elect.com/enfora/pdf/GSM1218HR.pdf Accessed: December 11, 2016.

[2] Enfora GSM Manual. [Web]. Available at: https://www.manualslib.com/manual/671203/Enfora-Gsm1218.html?page=8#manual Accessed: December 11, 2016.

[3] Enfora Guide, Tutorial, Programmer Refernence Manual. [Web]. Available at: http://www.testech-elect.com/enfora/enfora_doc.htm Accessed: December 11, 2016.

[4] Speaker layout. [Web] Available at: https://developer.mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/ Accessed: December 11, 2016.

[5] GSM Command Set, Enfora. [Web]. Available at: http://www.testech-elect.com/enfora/doc/GSM1308_Quad-Band_SA-G+_AT_Command_Set_REv1.01.pdf Accessed: December 11, 2016.


Please log in to post comments.