This tutorial explains how to enable EasyIoT server SMS interface. EasyIoT SMS interface can be used to send alarm SMS messages to mobile phone or to read sensor properties or send commands to sensors with SMS. You will need USB modem stick with SIM card.
Those days you can get USB modem stick for couple of EUR. It doesn't need to be modern high speed modem, because it will be used only to receive and send SMS messages.
First step is installation. SIM card must be unlocked - no PIN protection.
Windows platform
Most modems come with Windows SW which is installed first time when you insert USB modem in computer. If everything is installed correctly you should see modem under Control panel in device manager under ports (Com and LPT). To test modem send AT commands. Use PuTTY or similar program to send commands to test modem. Try to send ATi comand to see modem information. If everything is OK you should see modem info like manufacturer, model, etc in response.
Raspberry Pi platform
To install modem in Raspberry Pi first update Raspbian to latest release:
sudo apt-get update
sudo apt-get upgrade
After that check if modem is installed (modem must be inserted in USB port). Run lsusb command. You should see similar output:
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 008: ID 050d:0234 Belkin Components F5U234 USB 2.0 4-Port Hub
Bus 001 Device 005: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
Bus 001 Device 010: ID 12d1:1506 Huawei Technologies Co., Ltd. E398LTE/UMTS/GSM Modem/Networkcard
If you see output with detail modem info that's ok. If you see output similar as this:
Bus 001 Device 010: ID 12d1:14d1 Huawei Technologies Co., Ltd.
Just modem manufacturer with no additional info, you need to install usb_modeswitch. To install usb_modeswitch execute:
sudo apt-get install usb-modeswitch
After that you should see detail modem info in lsusb. Exact installation procedure can be different for your modem model - use Google to find proper solution.
If you see detail modem info test if modem is working. In console send AT commands to modem port.
echo "ATi^M" > /dev/<DEVICE> #(note: ^M is ctrl+v+m)
device is most probably /dev/ttyUSB0 or /dev/ttyUSB1. To see response type
cat /dev/ttyUSB0
or
cat /dev/ttyUSB1
In response you should see modem information.
Some of my findings:
- you need good power supply for Raspberry Pi. In my case it was not good enough to use 1A power supply. It works only with 2A power supply. This may depend on USB modem model.
- I have problems with one USB stick. It works at begging, but it stops working after one hour. Then it was not recognized by Raspian any more. It start working only after reboot. I assume it's Raspbian-USB modem problem, because sticks works OK on Windows machine. This problem is sloved with AT^CURC=0 command in V0.7.
- Modem may consume bigger current than Raspberry can supply. It may be different for your modem model and Raspberry model. I'm using Raspberry Pi model B rev.2. I have to shortcut polyfuse F3 (see picture) to supply enough current to USB modem. For other Raspberry model solution may be different. Do this only if you know what are you doing (you will lose warranty or fry Raspberry). The other solution to supply enough current would be to use Powdered USB hub for USB modem.
Enable SMS interface in EasyIoT server
In EasyIoT web interface go to Config->SMS interface.
First enter USB stick port - the one you tested before. Under Rasbian it's usually /dev/ttyUSB0 and under Win is some COMxx port. Then check if your modem speed is correct. Open Systemconfig.xml in config folder. If you see <BaudRate>115000</BaudRate> change to <BaudRate>19200</BaudRate>. This settings is under <SmsGateway> tag. Before you change settings you should shutdown server.
After you enter correct port and baudrate enable SMS interface.
Next try to test if your SMS interface is working. Send SMS message with text "test" (without ") to your USB modem SIM card telephone number. In response you should get SMS with "EasyIoT server SMS interface OK." text.
EasyIoT server SMS commands
With SMS commands you can control or monitor your sensor network.
To read sensor property use:
GetParameter [driver] [address] [property]
For example if you want to read temperature sensor of MySensor driver with adders N4S0 use
GetParameter MySensors N4S0 Sensor.Temperature
You can find driver name and sensor address in web interface:
As response you will get SMS with value of parameter.
To control module you have more commands:
-to switch digital output on
ConrolModule [driver] [address] ControlOn
-to switch digital output off
ConrolModule [driver] [address] ControlOff
-to set analog output value
ConrolModule [driver] [address] ControlLevel [value]
Examples are:
ControlModule MySensors N1S3 ControlOn
- to switch on
ControlModule MySensors N1S3 ControlOff
- to switch off
ControlModule MySensors N1S4 ControlLevel 20
- to set (dimmer) level 20
Those commands are sometimes hard to remember. To make things easier create shortcuts. In Web interface click button Add shortcuts and enter shortcut and complete command. After that you can call commands with shortcut text.
In Allowed sender you can limit the list of telephone numbers which are allowed to send commands to your EasyIoT server for security reason.
See more tutorials at http://iot-playground.com/build
Buying guide
To support this site and EasyIoT framework development please buy in our store.
Comments
2016-05-04T15:50:22.0319980+02:00 ERROR EasyIoTSMSInterface AT^CURC=0 command error.
I tried the "test" sms and get no response. I tried to manually send a sms with minicom and this works. I tried some AT commands and it seems to me thet this stick doesn't support all of them.
Did anybody get this USB stick work with EasyIot?
Thanks for your replies.
Jerry
searching on Digg for something else, Anyhow I am here now
and would just like to say many thanks for a remarkable post and a all round entertaining blog (I
also love the theme/design), I don't have time to read through it all at the moment
but I have book-marked it and also added your RSS feeds,
so when I have time I will be back to read a lot more, Please
do keep up the awesome work.
Thank you for this info. I've investigated and found solution. The problem are modem periodic status messages. It can be switched off by AT^CURC=0. After I add this command in EasyIoT server modem works all the time. Fix will be included in V0.7 release,
PCh.
yes, search EventHelper in forum
You gave me good idea. SMS interface always reads all characters and ignore garbage. I will try flush com port before sending AT commands.
[EDIT]
I've tried all combination ATZ command and cleaning serial port - result is the same, Huawei E169 hangs.
Sorry for my English
PCh.
No. I've got mine on local web site for second hand things for 10 EUR. It was cheaper than on ebay.
Chris
RSS feed for comments to this post