Interactive Voice Response system using Particle Core, GSM Breakout Board, Emic2 and DTMF Decoder

Source Code

My previous project using was a Voice Messaging system based on Particle Core, GSM Breakout Board and Emic2 TTS Module. Actually this was the project I first started but because of the unavailability of the DTMF Breakout Board, I released the Voice Messaging project.

Overview

This project is an IVR System. Following hardware components are using for this project.

  1. Particle Core as main processor and for Internet connectivity
  2. A GSM Breakout Board for Cellular connectivity
  3. SparkFun I2C/SPI-to-UART Breakout Board for SPI to UART
  4. Emic2 Text to Speech module for TTS
  5. DTMF Breakout Board

Here is the overview of the different hardware components and how they interact.

enter image description here

This project is almost similar to my previous Voice Messaging project except it has an additional DTMF Breakout Board. This is used to decode the DTMF signals. This board is used to detect which number user has pressed on other end. The Audio Out of the GSM Breakout Board is connected to the Audio Input of the DTMF Decoder and the pins DR, D0, D1, D2 and D3 are connected to Particle Core pins D2, D3, D4, D5 and D6 respectively. The Data Ready (DR) pin of the DTMF Board will be high when the boards detects the DTMF tone and it is decoded correctly. When this pin is high, we read the data pins D0…D3, this will be give us the number pressed on the other end of the telephone line.

In this sample the GSM Board is configured to answer the incoming call after 2 rings, so when a call is received it will be automatically answer after 2 rings. When the call is answered, application will speak out a welcome message and prompts the user to enter a 4 digit PIN. The default PIN is 9999, but you can change it whatever you like. When the correct PIN is entered, the application will ask you to enter 7, 8 or 9. Pressing 7 will speak out the current temperature, pressing 8 will speak out current humidity and pressing 9 will hang up the call. The sample use DHT Sensor to read temperature and humidity. This sensor is connected to the pin D0 of Particle Core.

Wiring

Particle Core and I2C/SPI-to-UART

  • Core MOSI to I2C/SPI-to-UART MOSI
  • Core MISO to I2C/SPI-to-UART MISO
  • Core SCK to I2C/SPI-to-UART SCK
  • Core SS to I2C/SPI-to-UART SS

I2C/SPI-to-UART and GSM Shield

  • I2C/SPI-to-UART Vcc to 3.3v
  • I2C/SPI-to-UART GND to GND
  • I2C/SPI-to-UART Tx to GSM Board Rx
  • I2C/SPI-to-UART Rx to GSM Board Tx
  • GSM Board 5v to 5v
  • GSM Board GND to GND

Particle Core and Emic2 TTS Module

  • Core Tx to Emic2 Rx
  • Core Rx to Emic2 Tx
  • Emic2 5v to 5v
  • Emic2 GND to GND

DTMF Board and GSM Breakout Board

  • DTMF Board Audio In to GSM Board Audio Out

DTMF Board to Particle Core

  • DTMF Board 5v to 5v
  • DTMF GND to GND
  • DTMF DR to Particle Core D2
  • DTMF D0 to Particle Core D3
  • DTMF D1 to Particle Core D4
  • DTMF D2 to Particle Core D5
  • DTMF D3 to Particle Core D6

Screenshots

enter image description here

Demo Video

https://www.youtube.com/watch?v=sPZ4FBCrNjo

Send Voice Message using Particle and GSM Breakout Board

Source Code

I bought a GSM Breakout Board and it was resting on my table for a long time. Last week I decided to work on a project using GSM and Particle Core. Actually I decided to work on 2 project, one is to deliver a voice message to a specified number and other one is an IVR system. Here is the first project I worked, send voice message to a specified telephone number. I am working on second one and will post here once completed.

Overview

This project basically call a number, when the call is picked up on the other end, deliver a voice message and then hangup. This project mainly uses 4 Hardware Components.

  1. Particle Core as main processor and for Internet connectivity.
  2. A GSM Breakout Board for Cellular connectivity.
  3. SparkFun I2C/SPI-to-UART Breakout Board for SPI to UART.
  4. Emic2 Text to Speech module for TTS.

enter image description here

Since both GSM Board and Emic2 are Serial based, you need 2 Serial to communicate to these two. So first I tried Serial1 and Serial2 on Spark Core. But only one was working at a time, either Serial1 or Serial2. I was not able to get both working at the same time. So I used SPI to Serial Breakout Board. This breakout board convert SPI or I2C to Serial. The Emic2 is connected through Serial2 and GSM Board is connected through the SPI to Serial board.

Adafruit FONA library is used to communicate to the GSM Board. Even though this is written for Adafruit FONA Breakout Board, it will work with other SIM800/SIM900 boards. FONA is based on SIM800L module. I have slightly modified the Adafruit FONA Library to include the functions to read current call status and set the auto answer.

For voice output I am using Emic2 Text to Speech module. The audio output of this module is connected to the Audio Input of the GSM Breakout Board using 3.5mm Audio connector.

The Particle Core application exposes three functions, one to set the number to which voice message has to be delivered, second one to set the message and third to set the number of rings before automatically answer the call. When we send voice message, the application place a call to the number and waits for the other end to pick up the phone. Once the phone is picked up, voice message is delivered and the application hang up. The status of the current call is obtained using the GSM900 AT Command AT+CLCC. This command returns the status of the current call. This command is explained in this document. The response string contains the status of the current call if any, if there is no active call the command returns just the string “OK”. Third field of the response string contains the status of the current call. Following are the possible values of this field.

  1. 0 Active
  2. 1 Held
  3. 2 Dialing
  4. 3 Alerting
  5. 4 Incoming
  6. 5 Waiting

Once the call is placed, the application waits for the active call status to become active and the message is delivered using the Emic2 TTS Module and hangs up the call once the TTS is completed. For incoming call if the auto answer is set, the SIM module automatically answer the call after the specified number of rings. In this case also when the call is active, the application delivers the message and hangs up.

Wiring

Particle Core and I2C/SPI-to-UART

  • Core MOSI to I2C/SPI-to-UART MOSI
  • Core MISO to I2C/SPI-to-UART MISO
  • Core SCK to I2C/SPI-to-UART SCK
  • Core SS to I2C/SPI-to-UART SS

I2C/SPI-to-UART and GSM Shield

  • I2C/SPI-to-UART Vcc to 3.3v
  • I2C/SPI-to-UART GND to GND
  • I2C/SPI-to-UART Tx to GSM Board Rx
  • I2C/SPI-to-UART Rx to GSM Board Tx
  • GSM Board 5v to 5v
  • GSM Board GND to GND

Particle Core and Emic2 TTS Module

  • Core Tx to Emic2 Rx
  • Core Rx to Emic2 Tx
  • Emic2 5v to 5v
  • Emic2 GND to GND

Screenshots

Circuit

Web Interface

Demo Video

https://www.youtube.com/watch?v=dfa3WrB7OzY&feature=youtu.be

Windows 10 IoT Core and SHT15 Sensor

Source Code

Here is another project using Window 10 IoT. In this project I am using SHT15 Temperature an Humidity sensor. This sensor give accurate temperature and humidity readings.

I used this library and converted to C#. The port was easy and simple. Only at one point I was stuck, where we wait for the result after sending a command to the sensor. In the original code, after sending temperature or humidity commands to the sensor, it waits for the data to be ready for reading. The code loops 100 times and see whether the data pin is high or not. It turns out for Windows 10 IoT looping 100 times is not enough, after I increased it to 3000 it was working. I don’t know why this is so, someone expert in this area has to find out and explain.

The project reads Temperature, Humidity and calculate the Dew Point. The Dew Point calculation is taken from Arduino DHT Library.

Wiring

  1. SHT15 Vcc to 3.3v
  2. SHT15 Gnd to GND
  3. SHT15 Data to GPIO24 (Pin #18)
  4. SHT15 Sck to GPIO23 (Pin #16)

Using the sample

Open the project in Visual Studio 2015. Start the application using the ‘Remote Device’ option under the Debug Tab. Configure the IP Address of the RPi2.

To see the sensor values, access the internal HTTP Server using the URL http://<<RPi2 IP Address>>:8080. The web page automatically refresh every 5 seconds.

RPi2 and SHT15

RPI2 and SHT15

Browser Output

Fritzing

Luminosity Sensor Sample using Windows IoT Core

Source Code

As you all know Microsoft released Insider Preview of Windows 10 IoT Core recently. I too download and installed it on my RPi2. While playing with Windows 10 IoT Core, I decided to work on TSL2561 Luminosity Sensor using I2C. Here is the sample I created this weekend.

In this project I am using TSL2561 Luminosity Sensor connected to RPi2 using I2C. This project is based on Sparkfun TSL2561 Library. This library is ported to Windows 10 IoT Core. This is simple and a straight forward porting. The sample read the luminosity and display it. You can either connect RPi2 to a monitor or access the internal HTTP server running on port 8080. The HTTP Server code is shamelessly copied from the super awesome project Hands-on-lab IoT Weather Station using Windows 10.

Wiring

  • TSL2561 3V3 to RPi2 3.3v (Pin #01)
  • TSL2561 GND to RPi2 Ground (Pin #09)
  • TSL2561 SDA to RPi2 SDA (GPIO02)
  • TSL2561 SCL to RPi2 SCL (GPIO03)

Using the sample
Open the TSL256 solution in VS2015. Start the application using the ‘Remote Device’ option under the Debug Tab. Configure the IP Address of the RPi2.

To see the sensor values, either connect the RPi2 to a monitor or access the internal HTTP Server using the URL http://<<RPi2 IP Address>>:8080. The web page automatically refresh every 3 seconds.

Screenshots

Wiring

Schematic

RPi2

Output

Basic weather station using Intel Edison, Cylon.js, Pubnub and Freeboard.io

Source Code

This is project I worked this weekend. The project use Intel Edison and BMP180 sensor for the weather data. Using Cylon.js I collect the sensor data display it on Freeboard.io using Pubnub real-time communication.

Cylon.js is a powerful JavaScript robotic framework based on Node.js and supports multiple development platform and different sensors. You can install Cylon.js on Intel Edison and use it to create powerful programs. In this project I use Pubnub for real-time communication and Freeboard.io is used to create beautiful dashboard. You can also send sensor data to IoT Cloud solutions and use it for processing. I am using Intel XDK IoT Edition for development.

Prepare and install on Intel Edison

To run this project, first you have to setup the Intel Edison, this link has the detailed instructions to setup the board. Then download install the Intel XDK Iot Edition from here. Download the project from GitHub, open and upload to the board. Please note that you have to use the XDK’s Compile/Build options, this will fetch cylon.js and all the necessary modules and install it on Edison.

Wiring

  1. BMP180 Vcc to Edison Breakout Board’s 3.3v
  2. BMP180 GND to Edison Breakout Board’s GND
  3. BMP180 SDA to Edison Breakout Board’s A4
  4. BMP180 SCL to Edison Breakout Board’s A5

Screenshots

Intel Edison

Intel Edison

Setting up Freeboard.io

Setting up Freeboard.io

Freeboard Dashboard

Freeboard Dashboard

Fritzing

Fritzing Diagram

Spark Core and Temboo Light Monitor

https://github.com/krvarma/SparkCore_Temboo

Here is a project I worked on last weekend using Spark Core and Temboo. Temboo provides easy and fast access to different APIs. It provides different libraries to connect to Temboo services and access it. There is a great Spark Core port of Temboo Arduino library which I decided to use for this project.

This project uses a low cost Light Sensor to constantly monitor the light level. If it is below a particular level then call a Temboo Choreo. For this project I am using Nexmo library (Library\Nexmo\Voice\CaptureTextToSpeechPrompt) to call a particular phone number, speaks out a message and get input (digits). Temboo library provides a easy way to call any Choreo and get the return value. The return value may vary based on the Choreo we are using. It can XML or JSON. In this project I am using JSON return string.

As everybody knows parsing JSON/XML from a memory limited MCU is not that easy. For this reason Temboo library provides Output Filters to make it very easy to process the return values. The above link provides a detailed documentation on how to use Output Filters. The Nexmo’s return value in JSON format contains an element ‘digits’ which contains the user entered digit. In this sample if the digit is ‘1’ then the LED attached to D2 is turn on. When the light level goes above the limit the LED is turned off. Instead of LED we can connect anything more meaningful like a Relay control to turn on the light, etc…

Using the project

To use this project, you should configure the Temboo Nexmo library and save it to a profile (https://www.temboo.com/library/Library/Nexmo/Voice/CaptureTextToSpeechPrompt/). You should also have one Nexmo account either trial/paid. Replace the following #defines of temboo-light.ino with actual Temboo credentials.

// Your Temboo account name 
#define TEMBOO_ACCOUNT "<<temboo account>>"  
// Your Temboo app key name
#define TEMBOO_APP_KEY_NAME "<<temboo app key name>>"  
// Your Temboo app key
#define TEMBOO_APP_KEY "<<temboo app key>>"  

Replace the Temboo profile name (which is saved previously) at line no. 111 of temboo-light.ino

Also you have Replace the Spark Core credentials in the temboo.html page.

Screenshots

enter image description here

enter image description here

enter image description here

Demo Video

https://www.youtube.com/watch?v=BORNp10bbY0

Electric Imp and BlinkM

https://github.com/krvarma/ElectricImp_BlinkM

A simple Electric Imp application that controls BlinkM Smart LED. This is only simple port of BlinKM functions. Not all the functions are included, only functions to set and fade RGB and HSB is included in this sample. The application does not include Script and other functionality. This will be added in future.

Wiring

  1. BlinkM SCL to Pin 1
  2. BlinkM SDA to Pin 2
  3. BlinkM Vcc to 3.3V
  4. BlinkM GND to GND

enter image description here

Sample Application

The sample application defines a class BlinkM which contains which defines the BlinkM functions. The application simply fade Red, Green and Blue.

XBee and Spark Core, Part 3 – Analog Input using Light Sensor

https://github.com/krvarma/XBee_SparkCore_LightSensor

Here is the part 3 of my XBee and Spark Core series. This part is about Analog Input using a Light Sensor. In this part AD1 of the Remote XBee is configured as Analog Input. AD1 is connected to Light Senor. As usual this XBee is configured as Router AT and Coordinator is connected to Spark Core via Serial. The Remote XBee is configured to send samples every 1 second and the Spark Core receives this IO Sample data and reads the Light Sensor value.

Same as the previous project, I am using the XBee library and reads the analog data using getAnalog method of the ZBRxIoSampleResponse class.

To monitor the values, in this part I created a Freeboard.io data source and configured a Display Panel.

Screenshots

enter image description here

enter image description here

enter image description here

XBee and Spark Core, Part #2 – Remote Door Monitor using XBee Digital Input

https://github.com/krvarma/Spark_XBee_Remote_Door_Monitor

This is the part 2 of my XBee and Spark Core series. In this part I worked on a simple remote door monitor using XBee, Spark Core and a Magnetic Contact Switch (Door Sensor).

In this project, the remote XBee is configured as Router AT. The DIO4 of the XBee is setup for Digital Input (3) and it is also configured to send IO Sample data every 1 second (setting IR to 3E8 hex). The Magnetic Contact Switch is connected to DIO4 of this XBee, so when the door is closed the DIO4 will be HIGH and when the door is open the DIO4 will be LOW.

A Coordinator XBee is connected to Spark Core using Serial. The Coordinator receives the IO Sample data that Remote XBee is sending and parse it to see whether DIO4 is HIGH/LOW. An event is generated based on the door state.

The companion web page listens for the above event and display some graphics based on the whether the door is open or closed.

I am using XBee Library ported by @peekay123. The Spark Core continuously reads XBee packets and look for packets with API ID ZB_IO_SAMPLE_RESPONSE. This is the API ID of the IO Sample Data. If it is IO Sample data, then read the data into ZBRxIoSampleResponse class. The ZBRxIoSampleResponse.isDigitalOn() method can be used to find whether a particular PIN is ON/OFF.

Screehshots

Spark Core and Coordinator XBee

Remote XBee and Door Sensor

Web Page

Demo Video

Demo Video

Using Spark Core and XBee for RF Communication, Part #1

https://github.com/krvarma/XBee_SparkCore

Here is one of the project I worked these days, this is a part one that uses Spark Core and XBee for RF Communication. My intention is to use XBee(s) and Spark Core to create very simple Home Automation project. In this part, I just turn on/off a remote LED which can be controlled using a Web Application.

The project is to control a remote light, i.e. turn on/off the light. In this part I am using Spark Core and two XBee’s (either Series 1 or Series 2). If you are using Series 1, then one should be configured to accept API Command, other can be wither API or AT mode. If you are using Series 2, then one should be configured as coordinator API and other can either be a Router AT/API or an End Device.

Introduction

Here in this project the Coordinator API XBee is connected to Spark Core and communicate using Serial. Spark Core is used as Internet Gateway to control XBee. The Core application uses XBee Library ported by @pkourany. For this project I am using XBee Remote AT command to control remote XBee(s). For more about API Mode and Remote AT Commands please refer to this link.

The Router XBee’s D0, D1, D2 and D3 pin are connected to four LEDs which can be remotely turn on/off. Any device can be connected to any pins and send the Remote AT commands to the remote XBee. It can a Rely connected to Electrical Light, or anything else.

To send Remote AT Command, you can either use a Broadcast address or a destination 64-bit (MAC/EUI64) address of the XBee module. Using the 64-bit destination address allows us to send commands to a particular XBee. There is also a 16-bit configurable address which can be used to group multiple XBees and send commands to that group. Since this is a different topic and is not in our scope, for more information refer to the Digi documentation.

The sample JavaScript Web application is used to control the remote light. To use this application you should replace the deviceid and accesstoken with actual values. When the application is opened you will be asked to enter the Name (any name, just for display purpose) and the 64-bit remote address of the XBee that is connected to the Relay Module. Once it is entered you can turn on/off the D0, D1, D2 and D3 pins.

Here you can find a very useful API Frame Generator from Digi International. This is extremely useful for the development and debugging, I used it a lot for this project.

Wiring

Coordinator XBee and Spark Core

  • XBee Vcc to Spark Core 3V3
  • XBee GND to Spark Core GND
  • XBee DOUT to Spark Core Rx
  • XBee DIN to Spark Core Tx

Router XBee and Relay Module

  • XBee Vcc to 3v3
  • XBee GND to GND
  • XBee DIO0 to LED1
  • XBee DIO1 to LED2
  • XBee DIO2 to LED3
  • XBee DIO3 to LED3

Screenshots

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Demo Video

https://www.youtube.com/watch?v=n_4AgTekWqs