Nocturnal solar-powered lamp from any glass jar

SIM900A 2G module + Hologram SIM card. Publishing sensor measurements to Thingspeak.


This is the second part of the series called "SIM900A 2G module + Hologram SIM card = winning combination in category dirt cheap?". In the previous post I demonstrated how to perform some essential operations with SIM900A GPRS module: send AT commands to determine firmware version and baud rate, and most importantly reflash it, unlocking it to operate outside of Asian countries.

Today I'll show you how to make use of Hologram SIM card and its free 1Mb per month quota. We'll take some sensor measurements  (fake them, to be exact) and send them to Internet via Thingspeak.

Hologram SIM card

If you haven't ordered and registered Hologram SIM at the time of reading the first part, I'll show where and how to order it, register it and find out information essential to connect to 2G GPRS network.
  •  Navigate to their website. You'll have to register an account to order a free SIM card. Don't worry - it's not just some useless account on another website, you'll use it to get access to your dashboard with detailed information and stats about your SIM cards and data usage.
  •  Order a SIM card - the one that has one free megabyte of data per month. The shipping was free as well at the time when I ordered it, not sure about now. As is evident from its name, it's supposed to have coverage around the globe, although I don't see how it's possible in 3/4G only countries. Those who successfully used this SIM in a country where 2G has been  phased out, please let me know in the comments section.
  •  After some time of waiting, the envelope with your SIM will finally turn up in the mailbox. Now you'll have to register it. Go to the dashboard.hologram.io and activation button will be in plain sight:
  •  Select the Maker plan, if you will (it will allow up to 25 active SIM cards), although you are free to pick any other one if it fits you better.
  • The next step will give you insight on the financial aspects of your plan. I've highlighted two most important things on my plan's page: 1) It includes 1Mb a month for free. 2) The limit on data usage can be set by you - that means if you don't want to pay, you won't (set the limit to 1Mb), or you can go unlimited and pay 40 cents for each megabyte after the first one.
  •  We've finally gotten to activation. 1) Enter the number of your SIM(s). 2) Enter a name - it's actually a kind of prefix for this batch of SIM cards.
  • The final page with all details of registration contains yet another reassuring thing for people who went for the free 1Mb SIM: you won't be charged unless you add a payment method. Make sure that everything you've entered is correct and click "Activate N SIM" button:
  •  Activation takes about 10 seconds, wait for it...
Patience is a virtue! This screenshot means that your request to activate your sim is being processed.

Finished!
  •  If you've ever connected any 2G modem to GPRS network, you're probably wondering where to look up APN, user name and password for connection. They are right there, just click on your device record in "Manage" table.
APN is "hologram", user name and password empty.

That was Hologram SIM card preparation - now it's ready to connect to 2G network, and you know all you need to gently push it toward this course of action..

Thingspeak

Making a channel in Thingspeak to publish your data from anywhere with access to Internet is quite easy. Obviously, you have to open Thingspeak website and register:

  • Create a new channel - one for each device sending data.
  • Fill in the details of your channel. You can publish up to 8 distinct measurements for one channel (device) e.g. temperature, humidity, etc. We'll settle on just one value for our experiments.
  • After successfully creating your channel, you want to know how to post some data into it. Go to "API Keys" section - there are examples of HTTP requests for every possible scenario. Also, take note of your "Write API Key" - we're going to need that for our next step.

Publishing fake measurements to Thingspeak via GPRS

Let's see if we can at long last send something to the server. After completing the first part of this tutorial we have our SIM900A modem ready to connect to any 2G network provider, and we've just got ourselves the SIM card with 1Mb of free data per month and a Thingspeak channel to publish numbers to. Yeah, we're definitely all set.

In part 1 we changed the baud rate to 115200 to speed up the firmware upload process, but our top priority now is absence of errors during transmission. Lower baud rates are better suited for that purpose, therefore I suggest as soon as you're connected to your module, the first command you issue is AT+IPR=9600.

I bet that by now, your hands are itching to upload something to Arduino! What I did before actually connecting hardware and writing the code, though, was manually enter all the required commands to get acquainted with the flow. You can skip straight to schematics of mock sensor data publisher, but I recommend going through the same steps to get a better feeling of what's happening under the hood.

A word of advice before we go on: GPRS operations are especially current-consuming, that's why I soldered and hot-glued yet another huge capacitor on top of my module:


In the case when your module starts resetting during GPRS connection, it's a transparent indication that you need to do it too. How to tell if your module is resetting itself? You'll see the startup sequence in your console window:

Now, on to the whole GPRS command sequence. You can take the the same auto-detection sketch we used in part 1:
And this is how you set up 2G connection and send HTTP requests



78 in AT+CIPSEND=78 stands for the length of the data you're about to send, including trailing \r\n - for real API key it's going to be 73 + the length of field1.

As soon as you're done typing the last command, you should be able to see a new data point in Thingspeak device page:


At this point we are sure that this approach of sending sensor measurements works (even if you decided to skip straight to microcontroller implementation - believe me, it works).

Let's proceed with assembling everything according to the schematic and coding. We'll use the same hardware as what's in part 1, plus one pushbutton and one potentiometer:


There's never enough power pins on Arduino. I splashed a huge blob of solder on female 2.54mm pin header to make an impromptu distributing hub.

The schematic diagram is as simple as they go: potentiometer provides mock sensor data, and pushbutton serves as a trigger to send one measurement to Thingspeak.


Next comes the code:



Upload the code, open the Serial monitor and spin the potentiometer head to any value you desire. Push the button and watch it end up on Thingspeak servers:




The only question that remains is: How much measurements like this one can I upload in one month, under the limit of 1MB? Let's find out with the help of Hologram dashboard:


1 kilobyte of data is all it used! That means that 1 free megabyte is around 1000 sensor updates a month, or 32 a day. Not bad for a freebie, huh?

What can YOU do with this information? It's up to you to decide. The most viable idea of the device that I came up with is a remote solar- or hydro-powered sensor that just notifies you about some events and/or sends you updates on temperature/humidity/you name it.

Anyway, thanks for reading all the way to the end, and stay tuned for more exciting ideas about transforming mundane electronic parts into something useful!

Comments