Category Archives: opensensorcloud

arduinopi

Raspberry or Arduino: how to choose?

arduinopi
When you look at a platform to play with connected objects, these are the two stars. But which one to choose? Especially when you look at the spec, there is one much more powerful than the other, so why we should bother of the Arduino ?

So we will try to understand which one is suited for what kind of project, in order to help you to do the right choice.

The raw specs are the following:

Arduino Raspberry
RAM 2 kb 515 Mb
Program size 32 kb Up to 32 G, depending of SD card
IO output 14 Digitals, (6PWM), 6 analog 8 digital 17 GPIO
CPU 16 Mhz 700Mhz
Price 25 euros 30 euros
Connectivity None by default, Ethernet/Wifi using shield or more powerful Arduino cards Ethernet, Wifi using an USB key

So definitvely raw spec of Raspberry are better than Arduino’s. But CPU and memory in IOT are not the only criteria to choose.
In fact, it depends totally from your type of project. If you want something close to the hardware, simple, cheap (a single arduino chip is around 3 euros).
To help you, here is a more detailed tab of various area of interest of each:

So, if your project is ….

Arduino Raspberry
Close to the hardware +++ +
Require analog input/output +++ -
Require CPU power - +++
Require Internet connectivity + +++
Require Screen output + +++
Needs to use USB devices - +++
Needs to store a lot of data + +++
Need to work on battery +++ +
Need to work alone +++ ++
Need to boot quickly +++ +
Need cheap device +++ ++
Require high level language
(python, javascript, ruby,…)
- +++

Raspberry is not expensive, but much more than an Arduino when it comes to industrialization. You can have an Arduino up an running for less than 3 or 4 euros, and you can freely build your own layout.

So for exemple :

Good Arduino usages
- autonomous gps tracking device
- small connected devices
- house sensor (gaz, electricity, intrusion, etc…)

Good Raspberry projects :
- home central automation
- media center
- ip camera recorder

Project that could be both :
- autonomous robot
- “complex” connected object , .i.e. nest like

Some project could need both. A good example is home automation, you can do simple capture device using arduino, and collect data in a master system based on Raspberry

Both are great device to play with, so I strongly encourage you to test both and to do your choice, depending on your project.

Power monitoring using Arduino

Another small but interesting project is power monitoring usage using Arduino.

The idea was to be able to get instant feedback on my home power consumption.

So I bought some CT sensor from EBay (9 euros/each) . The only problem is that I have a three phased installation. So instead of two phases as usual, (three wires) there are three phases and four wires.

The installation was made in two steps: first a breadbord connected to the CT sensor and the arduino, sending the information every ten seconds on OpenSensorCloud using an Eternet Shield.

EMon
As this worked fine, I’ve bought an a shield instead of my breadboard. This cost little bit but the result is much better than a custom one.

The advantage of having a three phase installation is that you can display each phase individually, so it gives you much more indication on what is currently hapenning. For instance, I no that on Phase 3 there is the heat pump installation, on phase 2 the kitchen, etc…

The result is visible here, you have a dashboard showing the instant consumption on each phase, as well as the daily total :
Emon

The sketch is here:
ArduinoCode
As a bonusI wanted something to display these data in the living room, so I used the spark core that I bought as an #IoT geek: the core is connected to the server and receive the data every ten seconds. This is probably not the optimum configuration (Ethernet -> Server -> Wifi -> Spark core) and I plan to do an updated version if a different connectivity. In the meantime, the result is quite nice: the core display the total consumption and the phase consumtion ona small olde display, as well as the usage graph of the last ten minutes.

The RGB led of the core is also used to provides feedback on power usage: green -> low usage, red, high usage

Bo_RURHIUAEGdMI_002

First SigFox program with Arduino (Akeru)

Following my previous post, I’ve started to explore Sigfox capacities with a small first project. The idea was to make a low powered GPS tracker. So I’ve just added a 10€ GPS adapter from China and wrote my first sketch.
The idea is to make a simple GPS Traker, ideally not using SMS but being able to send his position from anywhere, with of course very low energy consumption. This first version is just a proof of concept so we are not yet focused on the consumption. The data are then send to the OpenSensorCloud platform (feel free to register! )

photo(2)

The programe is quite simple:
1. initialize everything
2. wait for the GPS to get fix position
3. send it to server through Sigfox network
4. wait 10 min
5. start at 2)

We need to wait 10 minutes before sending another 22 bytes messages, it’s a Sigfox limitation and the tradeoff between low consumption, high coverage, and size. I don’t see this as a big issue for many usage, but for sure, it will add some interesting challenges

In short:

// include the library code:
#include <Akeru.h>
#include <TinyGPS.h>
#include <SoftwareSerial.h>

// initialize the library with the numbers of the interface pins
TinyGPS gps;
SoftwareSerial ss(8, 9);  // GPS RX is set on pin 8

void setup() {

  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Akeru.begin();  // Not sure it's neded, as I need to call it again later
  delay(1000);
  ss.begin(9600);
  // Init modem
  delay(1000);
}

// int is 16 bits, float is 32 bits. All little endian
typedef struct {
  float lat;
  float lon;
  float alt;
} Payload;


void loop()
{
  Payload p;
  float flat, flon;

  gps.f_get_position(&flat, &flon, &age);
  p.lat=flat;
  p.lon=flon;
  p.alt=gps.f_altitude();
  
  if(flat==TinyGPS::GPS_INVALID_F_ANGLE){
    delay(1000);
  }else{
    // Note Seems that we need to call Akeru.begin() again or
    // further call to isReady or send will be blocked...
    delay(1000);
    Akeru.begin();
    delay(1000);
    Serial.println("is ready:"+String(Akeru.isReady()));
    Serial.println("Sending");
    bool status=Akeru.send(&p,sizeof(p));
    Serial.println("done result:"+String(status));
    // Wait for 10 minutes before sending another one
    for(int i=0;i<600;i++){
       delay(1000);
    }
    Serial.println("wake up");
  }
}

Of course, the program need some improvements, like waiting to have more satellite fixed before seding the first message, but let’s keep it simple.

The full source code is available

I had some minor issue, it seems that the Akeru API needs to be “reseted” before sending new data

The payload is quite simple, just a structure with three float: lat , lon, and alt (the last one might not be the most interesting but it was just a test).

The most interesting things is that now opensensorcloud support Sigfox devices. Sigfox allows you to send data in a limited way. You are allowed only 22 bytes per message, so no way to do ascii or json. So you usually send binary information, typically raw C or C++ structure. Then you have to decode them on the server.
Hopefully, OpenSensorCloud provides full support for such feature:
When creating a sensor for an Akeru enabled device, you just need to specify the format of the payload, this will be automatically converted to corresponding sensor values.
SigFoxConf

Make sure that your sigfox device id is well defined
Format are described in a generic json way, for instance, in may case, the payload contained 3 float field, so format is the following:

[
  {'name':"lat",'type':'float'},
  {'name':"lon",'type':'float'},
  {'name':"alt",'type':'float'}
]

As I wanted to map this to a “Position” object, and not to thre sensors, I ad to add a little bit of definition


[{'name':'pos',
  'type':'position',
  'struct':[
   {'name':"lat",'type':'float'},
   {'name':"lon",'type':'float'},
   {'name':"alt",'type':'float'}
  ]
 }
]

As a Sigfox callback, put the URL of the OpenSensorCloud callback, like this

http://api.opensensorcloud.com/device/sigfox?api_key=YOUR_API_KEY


Replace with the value of the platform.
OpenSensorCloud expect two extra parameters: device value, with the device_id you’ve just entered before, and data with the binary payload.

The API_KEY is visible on your profile,
And let’s go

The map location appears on the platform

You can see the result on the
Real Time Dashboard live
capture

In next part, we will add geofencing and twitter features thanks to the Trigger functions of the OpenSensorCloud platform…