The GSM Shield
After some Web browsing we found a GSM Dualband Shield from Libellium (now outperformed by quadband device) that worked fine for this project even if It had some quirks that I had to solve via software. Libellium links the Shield Schematic and a tutorial that gives the basic information to start, but to get the thing done is another story.
To power the shield You have two options: Draw the Power from the Arduino Board or from an external power supply. You can choose between the two with the V. in ext jumper.
The power supply should be able to provide 2A. If You want to use a smaller power supply (and I’am sure that You will) You have to solder a 220μF capacitor between the ground and the 3.3V output of the LDO on the shield. With this mod the shield can draw the power from the Arduino board connected to a standard USB port. If the Modem has not enough power freezes while tries to transmit.
Another little issue with this shield is that there is not enough space between the modem and the PCB to fit the UFL antenna connector (looking at the photos of the quad band Shield seems that this issue has been resolved). After some (useless) abrasive file work on the UFL connector I decided to cut the connector and solder the antenna cable straight on the upper side of the modem where there is an antenna pad. I know this is not a very good HF connection, but seems to work fine even in low signal strength conditions (would be nice to measure SWR).
The shield has a couple of jumpers (Serial comm. jumpers) that exchange RX and TX signals from the Modem. One setup allows You to play with AT Commands with a terminal emulation program (Hyperterminal (XP) CoolTerm (MacOS) Tera Term (Windows 7) or you favorite one) through the USB/Serial connection. Another setup allows the Arduino to take control of the modem. When uploading the Arduino firmware to the board you must remove the TX jumper (the lower one) or the Modem will trash the communication trying to answer to the noise sensed on the RX line, leading to an upload failure. Since this can be very frustrating, if you plan to develop something with this shield, consider building a tool like this (see above) that will take just a couple of minutes, but will save a lot of time and mental health later. It’s a NC switch connected with a two pole connector that must be used to replace the TX jumper. Keep the button pressed during the Arduino firmware upload, and your life will be immensely better, trust me.
Before delivering your application, remember to solder the GSM Modem shielding to the PCB. There are three soldering point on the shield; this will guarantee mechanical stability and better noise immunity.
The GSM Modem
The GSM Modem is a Daviscomm DS3500, a rebranded iSirius iSR3500; I could find very little documentation about this modem: Libellium provides the AT Commands Manual, the Extended AT Commands Manual. There is a tech doc on the Web that explains the hardware design requirements that applications should comply with.
For who (like me) has never used a GSM modem before I can summarize saying that It’s a device that talks through a serial line with the application (in this case the Arduino board), answering to AT Commands and issuing asynchronously URC (unsolicited result codes). For example if the modem receives a call You’ll receive on the serial line a “ring” URC. Furthermore there are a lot URCs that You can enable reporting a lot of useful information. The drawback of URCs is that they can be received at any time even when you’re waiting a command response and this complicates the communication process. For example if you issue an “AT” (do nothing) command you’d expect a “OK” response but you could receive a “Ring” before the “OK”.
The best way to fully understand how a GSM Modem works is trying sending commands by hand and decoding responses; I suggest You to try a lot before deciding the software architecture. Remember to disable the PIN protection of the SIM (with a phone is easier), this will make your life better.
The big issue with this Modem (or shield I don’t know) is that it randomly resets loosing the configuration setup. This is very annoying. At the time of writing I’m still waiting for a response from Libellium about this odd behavior. After long and painful experimentation I’ve found that the reset seems due to serial inactivity (not to bad powering as erroneously reported in some forum posts) so issuing an “AT” command every 30 seconds keeps the modem busy enough to stay alive. With this fix the device works reliably, so I decided not to throw the whole thing into the dustbin.
This project uses just few of the modem capabilities, because we just need to send and receive SMS, and to use the phonebook to store a phone number, but with this device You can send e-mail and browse the web (at GPRS lightning speed).
The two main functions of the thermostat are temperature sensing, and heater driving.
For temperature sensing I choose an Analog Devices AD22100 that is the perfect device for keeping the design simple. As it’s a ratiometric device there is no need for a precision reference, it’s enough to give as reference for the ADC the 5V power supply; with this trick the ADC coupled with the output circuit of the AD22100 becomes insensitive to voltage changes because they share the same voltage source.
The overall precision is of 2%, linearity 1% and resolution of 0.2 °C are good enough for a house in the mountains thermostat which must raise room temperature from 5 °C to 20 °C.
For heater driving I’ve choosed a dual coil latched relais. This is a nice device that has two coils one to close and one to open the relais contact. One interesting thing is that to change the relais state You need to give just a pulse on the right coil, so the relais does not draw any power between state changes.
To add flexilbility in driving the heater, we need to emulate the NC/NO behavior for the “Heater On” state using a single contact. This may be useful because some heaters can be turned on with a Closed Circuit and some with an Open Circuit.
Different setup of JP1 and JP2 allow to exchage the coils setting “Circuit Open” or “Circuit Closed” for the “Heater On” state.
All the power is drawn from the Arduino board. The coil pulse draws 56mA for few milliseconds, and the AD22100 500μA.
The are four Leds for visual feedback: blue for GSM signal strength (that periodically blinks a number of times equals to the signal strength bars in a cell phone), yellow for thermostat activation, green for heater status and red for power on.
The I/O 8 of the Arduino Board is configured a serial TX line used for software debug. To debug I often use a USB-DLP232M a cheap and reliable solution for USB to TTL serial communication.
Stay tuned, We’ll analyze the GSM Thermostat software in the next post.