imran khan
imran khan

Reputation: 21

Sending Sensor data to azure iot suite using gprs module with raspberry pi or arduino

I have a raspberry pi 2 and sim900 gsm/gprs module. I have to send some sensors data to azure iot suite's remote monitoring application for monitoring and control. We can not provide ethernet or wifi at the site. The only option is using gsm/gprs module. I have searched a lot but couldn't find any material about this. And would it be possible to achieve this using arduino instead of rpi.

Upvotes: 2

Views: 3456

Answers (2)

Borja Tarazona
Borja Tarazona

Reputation: 165

yes, this is possible with arduino and RPi.If you use a SIM900 module, make sure you have the latest firmware and you can use SSL.

Here you can find a program I made to send data to my Azure IoT Hub via HTTPS using SIMCOM Modules (SIM800, SIM900...): https://developer.mbed.org/users/BorjaTarazona/code/Azure_SIM800_HelloWorld/

To upload the data to your IoT Hub via HTTPS using a SIM900 module you need:

  1. APN for the SIM900 module. The APN is given by your network provider.
  2. A Connection URL that will look like this: "https://XXXXXXXX.azure-devices.net/devices/XXXXX/messages/events?api-version=2016-02-03"
  3. A Shared Access Signature that you can get from your Azure account. It should be something similar to this one: "Authorization: SharedAccessSignature sr=XXXXX.azure-devices.net&sig=rCD5ZWvjblAl20djcEdtuL40vpKmdjvQH7lTphIRtJo%3D&se=XXXXXXXXX"

The commands I use to send data to Azure using HTTPS with the SIM900 moudle are:

Initialization

  1. Set context type: AT+SAPBR=3,1,"CONTYPE","GPRS"\r\n
  2. Set APN: AT+SAPBR=3,1,"APN","YourAPN"\r\n
  3. Open bearer: AT+SAPBR=1,1\r\n
  4. Query bearer: AT+SAPBR=2,1\r\n
  5. Enable HTTP functions: AT+HTTPINIT\r\n
  6. Enable SSL: AT+HTTPSSL=1\r\n

Data transmission

  1. Set bearer profile identifier: AT+HTTPPARA="CID",1\r\n
  2. Set the URL: AT+HTTPPARA="URL","YourURL"\r\n
  3. Set the shared access signature: AT+HTTPPARA="USERDATA","Authorization: YourSharedAccessSignature"\r\n
  4. Set Content-Type field in the HTTP header: AT+HTTPPARA="CONTENT","application/json"\r\n
  5. Set the JSON string to be sent: AT+HTTPDATA=StringLength,20000\r\nYourJSONString
  6. HTTP POST: AT+HTTPACTION=1\r\n

Upvotes: 5

Jackie
Jackie

Reputation: 2030

I don't see SIM900 GPRS module listed in windows IoT compatible list https://developer.microsoft.com/en-us/windows/iot/win10/supportedinterfaces#Miscellaneous, so I'm supposing it's not officially supported.

Otherwise, you can port an Linux kernel/distribution to rapspberry pi, which has a ready-to-use pppd dial service. When you have your device connected to web, use the windows iot c client https://github.com/Azure/azure-iot-sdks.git to connect to Azure IoT Hub.

Upvotes: -1

Related Questions