Task
As often happens tasks do not fit into the standard features of the available tools. It happened this time. Next, outline the problem.
There are several remote sites in the vast country (Ukraine) electrified, but not having simple technical capabilities to connect to the Internet. Objects are usually located so that about 3G or WiMax do not stutter. Only GPRS is available. You need to be able to monitor the temperature in several rooms of these objects. Moreover, it is desirable if not in real time with a minimum delay. Complicated is still the fact that the objects, although real estate, but there may be a situation that there will be a move. Therefore, capital equipment installation methods disappear.
That is, it would be good to have such a complex that can be easily transferred to a new place, plugged into an outlet and hanging up the sensors to forget about it. I am well aware that this hour the market is full of suitable solutions, but as always there is a fly in the ointment - this is the price in this case. Plus, often such solutions come with their software. And if God forbid you need to change something in it, then I will not tell you further, many probably talked themselves on similar topics with support services.
')

Equipment
It so happened that in connection with another project I had a GPS tracker on my desk, something like this -
habrahabr.ru/post/100747 Their peculiarity is that they are implemented using the modules of the Italian company Telit. This company produces both GPS-GSM modules and simply GSM. The peculiarity of these modules is that they have inside Python. That is, they can execute scripts. And it is natural that all devices and module resources are available from Python. Do you understand what all goes?)
Many trackers have the ability to directly connect sensors, but in the first place you will not install sensors at a significantly distance, and secondly their number is limited to two - four. By this I went the other way. Fortunately, the tracker also has a COM port. But with its help it is already possible to interrogate almost any equipment for stationary SCADA systems.
It is worth noting here that since Telit modules almost all have Python on board and scripts written for one module with minimal changes will work on another. It’s just that if a module doesn’t have a GPS, for example, you need to be very smart and don’t try to use it in a script.
I wrote and tested the script on the tracker, and then the modem
gprs-modem.ru/product/gsm-modem-teleofis-rx108-r-rs485-s-opciej-kreplenie-na-din-rejku was purchased on the Telit GL868-Dual module and it all worked right away!
Also nearby was the
OVEN MVA-8 analog input module
www.owen.ru/catalog/95286354 .

This is a simple analog input module for 8 sensors. Supports Modbus protocols (ASCII, RTU), DCON, OWEN. That's just the tracker and Python does not know about such protocols. We'll have to train.
Communication between devices is RS485 and therefore they can be mutually located at a considerable distance from each other. In addition, the sensors themselves can be located quite far from the MBA-8.
Implementation
Working with Telit modules is quite simple. The written script is loaded into the module and marked for execution. Docks for AT commands and Python functions can be found here
www.telit.com/en/products/gsm-gprs.php?p_id=12&p_ac=show&p=47 GL865-DUAL - a module in SMT format and a platform of a module similar to GE865-QUAD. Just drank it a bit for our countries.

It can be seen that it can be soldered without problems at home. The harness is minimal.
I want to note that when you download the documentation, be sure to check that it is suitable for the specific version of the firmware of your module. This is a serious rake. It can be a long and tedious search for a bug, but it turns out that just a function is not supported. Supported firmware versions can be found right from the start.
I will not retell all that is written in the docks. Everything is available there. In short, we have at our disposal several devices on board: MDM, MDM2, SER, SER2, MOD, GPS (if any). I think the name you guessed is what is what. And in the end, it all comes down to the fact that we, through the SER, interrogate the MBA8 and try to send it via MDM (modem) to our server, and if that didn’t work out, we add the data to the history file until better times.
MDM and MDM2 are not two modems and just two interfaces of the same modem. For what? This you will learn if you want to implement something like this.
Now in order. How to organize work with a modem can be found above the link where I gave an example of the tracker. It remains a survey MBA8. We are going to do it.
I was not lucky, I turned out to be an old MBA8 and it supported only its own protocol OWEN. This protocol made me very surprised. Why is it so wise to me it is not clear, but I managed to implement a poll on it. You do not have to go head to log. I will give here already ready functions of interrogation and calculation of a checksum. Please do not kick, this is the first thing I wrote in Python. By the way, Python is 1.5.2 there, but badly curtailed. For example, it is absent as a floating point number phenomenon. Therefore, be sure to read the docks.
Function to calculate the checksum:
def Crc16Owen(buffer): CRC = 0x0000 for j in range(0,len(buffer)): byte = ord(buffer[j]) for i in range(0,8): if ((byte^(CRC>>8))&0x80): CRC = (CRC & 0x7FFF) << 1 CRC = CRC ^ 0x8F57 else : CRC= (CRC & 0x7FFF) << 1 byte = (byte&0x7F) << 1 return CRC
The function to translate the lines ARIES into a normal form:
def OwenToHex(S): Sr='' for i in range(1,len(S)-1,2): a = ((ord(S[i])+0x09) << 4) & 0xF0 b = (ord(S[i+1])+0x09)&0x0F Sr = Sr + chr(a+b) return Sr
MVA8 polling function having the address number 8:
ToMva8Request = ['#GOHGONOKHTVU\r', '#GPHGONOKINGG\r', '#GQHGONOKMOGI\r', '#GRHGONOKLIVS\r', '#GSHGONOKVMGM\r', '#GTHGONOKSSVO\r', '#GUHGONOKOJVQ\r', '#GVHGONOKRPGK\r'] def GetMva8Data(): Mva8Data = '' SER.receive(5)
I want to remind once again that before yelling at me with a foul language it is worth understanding the intricacies of the built-in python, there are a lot of problems.
There are a few limitations. For example, space for scripts and other files is only 2 Mb. But for the file history is enough. Also, work with files is very slow and the cold start of such a logger lasts about 1.5 minutes. It is certainly possible to organize a survey more often than once every 30 seconds, but you will have to do it. Since I am satisfied with the survey every 5 minutes, this problem has not touched me. And do not forget about the fact that we use a memory that has a limited number of overwrites. If your logger will peel the data permanently into one and the same cell, then you will have enough memory for two months, after which there will be failures. But it is possible to realize the history file in such a way that the recording was kept all the time in different cells, which was realized. Estimated time of memory use in this mode turned out about 500 years., If you rely on data from memory manufacturers.
The modem has one drawback - it resets the clock when the power is turned off, it was necessary to organize the receipt of time from the server.
And by the way, I know that there are the same smart Siemens modems, but I like Telit more. And there are other reasons but they will not be there.
Well, now the main thing - the price.
Modem - 2 950 rubles.
MVA8 - 4,189.00 rubles
Sensors + wires add on.
In my pretty cheap work. And do not forget that all this can be easily transferred and installed elsewhere.
PS The basic idea is that the modem performs not only the functions of a modem, but also the functions of a master that polls equipment and storage functions. And you do not need to use a separate, even minimal buffer server.