Shares
Monitor Data From Anywhere With Arduino & the Adafruit FONA

Monitor Data From Anywhere With Arduino & the Adafruit FONA

Last Update: / by Marco Schwartz

In some situations, you could want to monitor a project remotely, and we all know that’s quite easy to do using an Arduino board & an Internet connection. However, a WiFi or Ethernet connection is not always available, for example in a secondary home in the countryside, or a mountain cabin.

This is where this project comes into play: in this article, you are going to learn how to send measurement data via GPRS (cellular data), using the Adafruit FONA shield & Arduino. This way, you’ll be able to monitor projects remotely even if no Internet connection is available. Let’s start!

Hardware & Software Requirements

We are first going to see what components are required for this project.

Of course, you’ll need an Arduino board. I used an Arduino Uno board here. The most important component of this project is of course the GSM/GPS shield. I used an Adafruit FONA 808 breakout board for this project:

Monitor Data From Anywhere With Arduino & the Adafruit FONA

This is a very convenient piece of hardware as it integrates everything you need for your projects: a GSM/GPRS chip, as well as a GPS receiver.

Note that in some countries, the plan is to stop the GPRS/GSM network in the future. In that case, you could perfectly use the 3G version of this board, which would work just as well for this project.

Then, you’ll need a SIM card, in the ‘classic’ SIM card format. If you only have a micro or nano SIM card, you’ll need to use an adapter. Also, make sure that the SIM card is activated with at least some data available. For this project, I used a very cheap prepaid SIM card with about 10 MB of credit available on the card.

You will also need a GSM/GPRS antenna, and a GPS antenna, that you can also get from Adafruit. I also used a simple DHT11 sensor for this project.

As the shield is taking a lot of power, it needs an external battery to function properly. For that, I used a standard 3.7V LiPo battery with a JST connector.

Finally, you will a breadboard and some jumper wires to make the required connections.

This is the list of all the components that I used for this project:

On the software side, you will need to have the latest version of the Arduino IDE, which you can find at:

https://www.arduino.cc/en/Main/Software

You will also need the latest version of the Adafruit FONA library, which you can get using the library manager inside the Arduino IDE.

Hardware Configuration

We are now going to assemble the hardware of this project. We’ll set up the breakout board, and then assemble it to the Arduino board.

The first step is to open up the FONA board so you can insert the SIM card. Then, simply insert the SIM inside the board and close the tray again. After that, put the GPRS antenna and the GPS antenna on the board.

We are now going to connect the FONA board to the Arduino board. First, place the FONA board on the breadboard. Then, connect the different pins of the FONA board as follows:

  • Vio connects to 5V of the Arduino board
  • GND connects to GND
  • Key connects to GND as well
  • RX connects to digital 2 of the Arduino board
  • TX connects to digital 3 of the Arduino board
  • RST connects to digital pin 4 of the Arduino board

For the DHT11 sensor, connect the first pin of the sensor to VCC of the Arduino board, the second pin to pin 7 of the Arduino board, and finally the last pin of the sensor to GND. Once that’s done, this is how it should look like:

Monitor Data From Anywhere With Arduino & the Adafruit FONA

Finally, before moving on to the next section, make sure to connect the battery to the FONA board.

Logging Data Online

We are now going to use the GPRS connection to log data online, using a service called Dweet.io. Then, we’ll even use a website to display this data graphically.

Of course, this assumes that you have a mobile Internet access where the project will be located. But that’s perfect to monitor data in a location where there is mobile Internet, but where you don’t want to install a regular Internet access.

As the code is quite complex, I’ll only highlight the most important parts, but you can of course find the complete code on the GitHub repository of the project.

First, we need to define a ‘thing’ name on Dweet.io, which is a virtual object that will hold all the measurement data:

String yourThing = "8g62og";

Then, we activate the GPRS module on the board:

if (!fona.enableGPRS(false))
Serial.println(F("Failed to turn off"));

delay(1000);

if (!fona.enableGPRS(true))
Serial.println(F("Failed to turn on"));

delay(1000);

After that, in the loop() function of the sketch, we send the measured data to Dweet.io, by making a GET request to the server:

uint16_t statuscode;
int16_t length;
String url = "http://dweet.io/dweet/for/";
url += yourThing;
url += "?temperature=";
url += String(temperature);
url += "&humidity=";
url += String(humidity);
char buf[80];
url.toCharArray(buf, url.length());

Serial.print("Request: ");
Serial.println(buf);

We also read back the answer and display it inside the Serial monitor. We also wait for one minute before sending data again:

if (!fona.HTTP_GET_start(buf, &statuscode, (uint16_t *)&length)) {
Serial.println("Failed!");
}
while (length > 0) {
while (fona.available()) {
char c = fona.read();
Serial.write(c);
length--;
}
}
fona.HTTP_GET_end();

// Wait
delay(60 * 1000);

It’s now time to test the project! Grab the code the GitHub repository of the project at:

https://github.com/openhomeautomation/monitor-data-arduino-fona

Make sure to change the name of the ‘thing’ inside the code. Then, upload the code to the board, and open the Serial monitor.

You should see the following inside the Serial monitor:

Monitor Data From Anywhere With Arduino & the Adafruit FONA

If you can see this ‘succeeded’ message, it means the data was correctly uploaded to the server.

You can now check it by going to the following URL:

https://dweet.io/get/latest/dweet/for/my-thing-name

You will get the last measurement inside your web browser:

Monitor Data From Anywhere With Arduino & the Adafruit FONA

This means that you are now able to log data from your project, without a WiFi or Ethernet connection!

Monitor Data From Anywhere

But you can do more than that: we are now going to see how to display this data graphically. To do so, we’ll use a platform called Freeboard.io. This platform allows you to create free online dashboards for your projects, and interfaces nicely with Dweet.io.

First, create a free account at:

http://freeboard.io/

Now, create a new dashboard, and create a new source inside this dashboard with the following parameters:

Monitor Data From Anywhere With Arduino & the Adafruit FONA

Of course, you need to insert your own thing name here. After that, you should see the source inside your dashboard, and when it was last updated:

Monitor Data From Anywhere With Arduino & the Adafruit FONA

Now, we’ll create a widget to display the temperature. Create a new Pane, and inside this a new Gauge widget with the following data:

Monitor Data From Anywhere With Arduino & the Adafruit FONA

Now, create the same for the humidity data. This should be the final result:

Monitor Data From Anywhere With Arduino & the Adafruit FONA

Congratulations, you can now log data using your FONA board, and also monitor this data graphically from anywhere in the world!

You can of course now adapt this project and build your own monitoring projects with it. You can for example log the data coming from several different boards to Dweet.io, and monitor all the data within a single dashboard. With that, you can monitor data in several location that don’t have a WiFi or Ethernet access.

If you want to learn more about building similar projects with Arduino & the FONA board, I recommend checking the book that I wrote on the topic: GSM & GPS Projects With Arduino.

Want to learn more? Get my free eBook about Arduino!

Arduino is an amazing platform that you can use to build all sorts of projects. Download today my free eBook "Building a Simple Alarm System with Arduino". Simply click on the button below!

Leave a Comment

Please enter your name.
Please enter your email.
Please enter your comment.
Luke a year ago
I just got this to work using teh fona808. I had to play around with 1 or two lines of code but it works great! Ive already sent up 90 sets of datapoints so far!
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Mario a year ago
Hi. When you mention FONA, DOES THIS INCLUDE FONA 808..? At this moment I am interested in collecting data from GPS and sending it to the server for later plot or analysis. I have already made the FONA 808 send me the Lattitude and Longitude to a mobile as SMS
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Ron 2 years ago
This board seems to be broken. The only thing I get is a 'Leave A Comment' screen.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.
Ron 2 years ago
This board seems to be broken. The only thing I get is a 'Leave A Comment' screen.
Reply
Please enter your name.
Please enter your email.
Please enter your comment.