Upgrading Apache Cassandra Cluster

At thethings.io we use Cassandra as our master time series database. Some weeks ago we needed to upgrade our Cassandra version to a major release version in order to improve the QoS of our architecture.

Cassandra with thethings.iO

This post aims to group all steps that we use for upgrade our Cassandra cluster to a newer version. There are a lot of documentation and sometimes it is a little bit annoying to look at different pages. In case that you use Cassandra for Internet of Things (or any other use case) we hope that this post will be useful.

This section describes how to upgrade Apache Cassandra with zero downtime if your cluster has a replication factor of at least 3.


  • Be careful when you run these steps on production environments.
  • For command simplicity I don’t include the user and password. Ex: nodetool drain -u username -pw password


  • Make sure you have an up-to-date daily backup. We use nodetool snapshot tool for that but there are other options as well like OpsCenter.
  • Familiarize yourself with the changes and features in this new release.
  • Remove all dead nodes.
  • Do not run nodetool repair or other tasks.

Please check this link for more information.

Steps for upgrade cassandra version

1. Run nodetool drain before shutting down the existing Cassandra service. This flushes all memtables from the node to SSTables on disk. Cassandra stops listening for connections from the client and other nodes. Also prevents overcounts of counter data, and speeds up restart post-upgrade.

nodetool drain -h hostname

2. Stop cassandra services.

service cassandra stop
service datastax-agent stop

3. Back up your cassandra configuration files from the old installation to safe place.

4. Update java version.

apt-get update
apt-get install oracle-java8-set-default
java -version

5. Install the new version of Apache Cassandra.

apt-get update
apt-get install cassandra=3.0.9

If you are running Cassandra from a source you should download the latest tar.gz instead of using the package manager.

6. Configure the new product. Review, compare, merge and/or update any modifications you have previously made into the new configuration files for the new version (cassandra.yml, cassandra-env.sh, etc.). Take care with the configuration options and check version restrictions.

7. Start the cassandra services.

service cassandra start
service datastax-agent start

Check the logs for warnings, errors, and exceptions.

tail -f /ttio/var/logs/cassandra/system.log # or path where you set your logs.

8. Run nodetool upgradesstables

nodetool upgradesstables

9. Check the logs for warnings, errors, and exceptions.

tail -f /ttio/var/logs/cassandra/system.log # or path where you set your logs.

10. Check the status of the cluster

nodetool -h hostname status

11. Repeat theses upgrade steps on each node in the cluster.



[Note: this article was first published on Adria Galin’s blog]

The most simple enterprise IoT platform

A year ago, I wrote Keep IoT simple, stupid where I was trying to explain that with thethings.iO we are trying to bring simplicity into the complex ecosystem of the Internet of Things. Store, analyze and visualize data should not be hard or need any specific team with knowledge on scaling machines, among others. This is the reason why one year ago, at thethings.iO we wanted to become the most simple enterprise IoT platform. And here we are!

The most simple enterprise IoT platform

The most simple enterprise IoT platform

During this year we have participated in several events, research documents and interviews and it’s great to see that we are working towards the right direction, to make thethings.iO becoming the most simple enterprise IoT platform instead of a complex mix of several features. Let me give you few examples.

IoT platform Scorecard made by Machnation

One of the most interesting IoT platform reports, mentioned us as one of the best AEP IoT platform. AEP IoT platform means Application Enablement Platforms that bring a collection of services and features to the hardware and IoT devices. We recently received the results from this research made by Machnation. It’s a really interesting document with a scorecard comparing thethings.iO with other 34 IoT platforms in the market (feel free to purchase it and share it).

IoT platform Scorecard 2016 by Machnation

IoT platform Scorecard 2016 by Machnation

Here some of the comments regarding with thethings.iO:

thethings.iO is positioned in the upper right-hand quadrant of the IoT AEP ScoreCard 2×2 matrix.

thethings.iO is ranked higher than established platforms like PTC ThingWorx in the report. And thethings.iO is towards the top of the ranks compared to the other 34 vendors evaluated.

That’s great that someone who is independent says nice things about thethings.iO.

And more

On the other hand we got insightful feedback from customers, friends, competitors and others letting us learn about what are the most interesting next steps. Few days ago, I read one of these lists that appear by the end of the year. In this case it was a list of the best 20 IoT startups in UK (or more potential or something like that I don’t remember now), and it was great to see one of our customers mentioned there. It makes us proud to see that our customers rock and they rock because we do.

thethings.iO the most simple enterprise IoT platform

We are building the most simple enterprise IoT platform in the market. Call it the most simple Sigfox IoT platform, the most simple industrial IoT platform or change *enterprise* by whatever you think it makes sense.

During 2017 you are going to see more and more features that go towards that direction. Feel free to let us know your feelings and feedback and let’s stay connected during 2017.

Connect KEPServerEx to an IoT platform

Industry is getting into the Internet of Things, some call it Industry 4.0 some other use other names. The hard thing of the industry is that sometimes the companies still use old protocols, legacy machines and systems. The protocol OPC UA (Unified Architecture) is one of the most extended IoT industrial standard for automation. At thethings.iO we want to lead industrial companies to get into the Internet of Things (IoT) and Industry 4.0. This is the reason why we are enabling our industrial customers with IoT gateways and compatibility with existing industrial products such as KEPServerEX, to seamlessly stream real-time industrial data to thethings.iO and apply all the operational tools and Big Data with cloud code and build dashboards and apps for final customers, among other features.

kepserverex and thethingsiO IoT platform
Today we will show you how to connect KEPServerEx to thethings.iO with MQTT. KEPServerEX is an OPC server and connectivity platform for industrial automation. As you will see, it is very fast and easy to forward data from your industry to IoT platform of thethings.iO ! So let’s get started!

Step 1: Install KEPServerEX

First, during the installation of KEPServerEx, we choose the IoT Gateway under Plug-Ins to be installed as well. We select ‘Entire feature will be installed on local hard drive’.


Step 2: Add an agent with REST client

After the installation is finished, we open KEPServerEX and then right-click on ‘IoT Gateway’ and select ‘New Agent’.


Then we choose a name for your agent and as type “REST Client”. Click ‘Next’.


Now, at the endpoint configuration, at the URL field we insert http://api.devices.thethings.io/v2/things/THING_TOKEN where THING_TOKEN is the token of the thing you want to send the data to. As method, we choose POST, put the publish rate to 1000 and select ‘Wide Format’.


After that, we  leave the header configuration empty and click ‘Finish’.


Step 3: Add IoT Items

The next step is to add an IoT Item to send data from. In order to do that, we click on our freshly created Agent and then on ‘Add IoT items…’.


For this tutorial we will use a simulator which generates random numbers and send them to thethings.iO

In the Tag Browser, we click on Simulation Examples, then on ‘Functions’ and choose Random4. Then we click ‘Apply’.


At the window for the item configuration that opens next, in the publish field we select ‘Every Scan’, leave everything else as it is and click ’OK’.


Step 4: Configure the agent

The last step is to do some final configuration on the agent we created before. For that, we right click on the agent  and choose ‘Properties’.


Then, in the body tab, we choose ‘Advanced Template’ and put the following:

    |#each VALUES|
        {“key”: “test”, “value”: “|VALUE|”}#unless @last|,|/unless|


After that,  we click on ‘OK’. If everything went well you will see the following message:


We can now go to our panel at thethings.iO and see how the random numbers are arriving!


thethings.iO is the most simple enterprise IoT platform. Do not hesitate to sign up and test it with your KEPServerEX with OPC UA. We are the IoT platform that you are looking for.

Particle Photon with thethings.iO IoT platform

At thethings.iO we love to play with hardware and today we are going to show you how to program and send data with a Particle Photon board to thethings.iO. For this, we are going to use the Particle Buid system as the IDE because it’s more integrated on the Particle system.

Particle loves thethings.iO IoT platform
The Particle Photon is a development kit made with a micro-controller ARM Cortex M3. It brings Digital I/O and Analog input and output, SPI, I2C, CAN, PWM among other.

Particle Photon

Particle Photon

Let’s start showing you how to connect the Particle Photon which is a WiFi board with thethings.iO IoT platform in order to have a Photon on steroids thanks to thethings.iO features.

If you already have an account and your device is already claimed, please jump to step 3.

    1. Claim your photon: Install particle-cli and type “particle setup” from a terminal console. This command will guide through account creation and device claiming (make sure you connect your device via usb first).
    2. Create a thethings.iO account: If you still don’t have an account, please register at thethings.iO IoT platform. In order to create a new thing:
      1. Enter to your account and click on Things.
      2. Press on Create new IoT product.
      3. Give a name and choose Other for the board.
      4. Finish the steps and remember the thing Token.
Particle IDE

Particle IDE

  1. Navigate to the particle build IDE.
      1. Click on the fourth row (Devices) and press the star in order to select the devices as preferred to flash.
      2. Clone our github repository about the Photon Particle. Feel free to reproduce our example or change the code at your own.
    #include "MQTT/MQTT.h"
    void callback(char* topic, byte* payload, unsigned int length) {
        String text = "";
        for (int i = 0; i < length; i++)
    MQTT client("mqtt.thethings.io", 1883, callback);
    int a;
    String TOKEN = "YOUR TOKEN";
    String TOPIC = "v2/things/"+TOKEN;
    String WIFI_SSID = "your wifi";
    String WIFI_PASSWORD = "your password";
    void setup() {
        digitalWrite(D1, LOW);
        WiFi.setCredentials(WIFI_SSID, WIFI_PASSWORD); 
        while(!WiFi.ready()) {
        Serial.print("Connected ssid");
        while (!client.connect("photonclient")) {
            Serial.println("Could not subscribe, retrying...");
    void loop() {
        a = random(0,10);
        if (digitalRead(D1) == HIGH) {
            message = "{\"values\":[{\"key\":\"fun\",\"value\":"+String(a, DEC)+"}]}";
            client.publish(TOPIC, message);
            delay(5000);         // ADDED A LITTLE BIT DELAY TO REDUCE BOUNCES
        if (client.isConnected()) {
    1. Flash the code into the Photon using the thunder icon (top left section).
  2. Create a thethings.iO dashboard: Now it’s time to create a dashboard in your thethings.iO account to show all the values sent by the Photon. Lets create some charts:
    1. Click on the Add Widget blue button.
    2. Give a name to the Widget.
    3. Select Thing Resource inside Data Source.
    4. Select thing you just created before.
    5. Select the name of the resource you want to display and the format (pie, chart, graph…).
    6. Click on Costumize it and select the number values you want to show.
    7. Accept and Save!


Repeat this last step to build awesome dashboards with thethings.iO!

We are at IoT Solutions World Congress next week

IoT Solution World Congress 2016 starts next week, starting on Tuesday 25th of October until 27th of October. The night before, on Monday at 7pm, there’s also the awesome IoT Stars that thethings.iO is proudly sponsoring.

iotwsc 2016

At thethings.iO we are very excited about participating at the 2nd edition of the IoT Solutions World Congress event at the Barcelona (Gran Via) expo. The industrial IoT is one of thethings.iO main markets and it’s a great opportunity to meet up companies and partners to exchange impressions of the market and show off our new developments to potential customers, resellers and partners.

During the #IoTSWC16, we are going to introduce the last innovations at thethings.iO such as the product analytics, the node code and the marketplace. At thethings.iO we are pushing hard to become the most simple industrial IoT platform in the market.

As exhibitors, we will have a booth at the IoT Solutions World Congress. Looking forward have you visiting our booth at C371 (Barcelona Activa) and chat with us about your needs, experiences, projects and ideas with thethings.iO. Last year it was great, so we hope it will be at least the same!

Our CEO, Marc Pous, is going to give two talks during the IoT Solutions World Congress. The first one on Wednesday 26th of October at 10:00 AM inside the IoT Catalan Alliance, speaking about IoT and innovation. The second talk, it is as well on Wednesday at 3.30 PM at the ISACA Alliance and Marc will speak about industrial IoT and security.

IoT Stars

IoT Stars MWC 2015

IoT Stars MWC 2015

thethings.iO is a proud sponsor of the IoT Stars. Our CEO, Marc Pous and Rudy de Waele are making a big party for IoT again, this time during the IoT Solutions World Congress. Join us to enjoy awesome speakers such as Rob Tiffany, Tom Raftery or Ignasi Vilajosana and fresh beers sponsored by Moritz. Can’t miss it!

Zolertia + thethings.iO Workshop

Finally we will be teaching a workshop with our friends from Zolertia at their event. Meet our team (Miquel and Carles) showing how to connect the Zolertia’s Remote to thethings.iO in just few clicks at this interesting (and free) workshop on Monday 24th.

Looking forward meeting you. If you can’t come to Barcelona this year, you can follow us on Twitter and the blog or just contact us by e-mail. Let’s stay connected!

Connect industrial gateway Option CloudGate to thethings.iO

Some of our customers use industrial routers from 3rd party manufacturers for several reasons. Some of these reasons are important requirement because of the environment, certifications, connectivity or needs on the field. Industrial routers or gateways are getting important on use cases such as the industry. Option have created the CloudGate router which is a really interesting gateway to use if you need to have an IoT swiss army knife.

CloudGate & thethings.iO

CloudGate & thethings.iO

Today we’re going toconnect the CloudGate router, from Option, to thethings.iO IoT platform in 3 simple steps. As an example we are going to connect the DL100-M485 temperature and humidity datalogger to a CloudGate that will send the data to thethings.iO. The DL100-M485 sensor uses the Modbus RTU protocol over the RS485 interface to transmit the temperature (both ºC and ºF) and the relative humidity (%).

The necessary components for this example are:

  • A CloudGate
  • Industrial serial expansion card (from Option)
  • DL-100M485 sensor
  • 12V DC power adapter (to provide power to the sensor)
  • Cables (to connect the sensor to the CloudGate).
  • A 120 Ohm resistor
  • Internet through Ethernet port

Set up the CloudGate hardware for thethings.iO

Option CloudGate connected to thethings.iO

Option CloudGate connected to thethings.iO

This is the step by step to connect the Option CloudGate to thethings.iO IoT platform:

  • Install the industrial serial card on the CloudGate.
  • Connect the green cable (D+) from the sensor to Tx+ pin on the industrial serial card.
  • Connect the white cable (D-) from the sensor to Tx-pin on the industrial serial card.
  • Connect the 120 Ohm resistor form D+ to D-.
  • Connect the 12V+ with de red cable from the sensor.
  • Connect the GND with the black cable from the sensor.

In order to connect the Option CloudGate to the IoT platform thethings.iO we will use Luvit-Red. Remember that the luvit-red package must be installed in our CloudGate. Luvit-red is available in the cloudgate universe. After registering and registering the Cloudgate, choose the latest Luvit-red version available to be installed on the CloudGate. Once the router restarts, the package will be installed. Luvit-Red is a visual tool to program workflows with the sensor data and other data from the CloudCode or from thethings.iO.

Set up a thethings.iO account and dashboard

If you still don’t have an account, please register at thethings.iO IoT platform.

In order to create a new thing:

  1. Enter to your account and click on Things.
  2. Press on Create new IoT product.
  3. Give a name and choose Other for the board.
  4. Finish the steps and remember the thing Token.

Program Luvit-red workflow to send data to thethings.iO

Luvit-red is a visual programming platform based on modules connections. In order to send the sensor values to thethings.iO, we are going to need the Modbus pull, Modbus extract, Function, JSON, and HTTP request modules.

    1. Modbus pull:
      1. Change the serial port to /dev/ttySP4 with 9800 and the parity of 8 bits and 1 stop bit.
      2. In this case we want to read 2 registers, located at the address 30001 and 30002. The operation Read Input Registers starts in the position 30001, so we only need to start at the same address (0 offset) and read 2 registers.


  1. Modbus extract:
    • With this module we are going to format the values as 16 bit integers. We should read 2 values and divide them to 100 to have the exact value (with commas). The result will be an array of 2 elements called Industrial and addressable in the payload of the message.


  2. Function:
    • Now we need to create the payload of the message: data and data1 will store the value of both humidity and temperature.


  3. JSON:
    • This module will transform the previous message into a well-parsed JSON.
  4. HTTP request:
    • All the messages will be sent using and HTTP POST. The URL should be https://api.thethings.io/v2/things/ followed by the thing token you created at thethings.iO


  5. Final connection:thethings-all-modules
    1. After connecting all the modules with its neighbours we should achieve the same flow as the next one:

Build thethings.iO Dashboard

Now it’s time to create a dashboard in your thethings.iO account to show all the values taken by the sensors. First we are going to create a Product table to show all the sensor values at the same time.

  1. Click on the Add Widget blue button.
  2. Give a name to the Widget.
  3. Select Product inside Data Source.
  4. Select the product you just created before.
  5. Select Table and check Realtime.
  6. Click on Costumize it and select the values you want to show (the name of the key in the function module).
  7. Accept and Save!

Now lets create some charts:

  1. Click on the Add Widget blue button.
  2. Give a name to the Widget.
  3. Select Thing Resource inside Data Source.
  4. Select thing you just created before.
  5. Select the name of the resource you want to display and the format (pie, chart, graph…).
  6. Click on Costumize it and select the number values you want to show.
  7. Accept and Save!

This is an approximate result of the dashboard that we have built in 2 minutes.


Create more widgets and make awesome Dashboards with thethings.iO and let us know why you use Option CloudGate with the IoT platform thethings.iO!

Sigfox IoT Dashboard with thethings.iO IoT platform

In today’s post we are going to show you how to create (step by step) a Sigfox IoT Dashboard with thethings.iO IoT platform.

Sigfox thethings.iO

In this example we’ll use the same board an peripherals as the previous post (Connecting the SmartEverything to thethings.iO). Please follow the first two steps in order to flash the code in the SmartEverything. The Smart Everything board is a 32-bit ARM Cortex-M0+ that supports Arduino and brings a Sigfox module (Telit LE51-868 S), a GPS module with embedded antenna (Telit Jupiter SE868-A), a Proximity sensor (ST VL6180X), Humidity and temperature sensor (ST HTS221), accelerator sensor with Axis sensors (ST LSM9DS1), and a Pressure Sensor (ST LPS25H). In addition to this, the SmartEverything also has NFC and Bluetooth Low Energy modules.

Let’s start the tutorial

Now, make sure you have an account at thethings.iO. If not, register quickly by clicking here.

Once you have done this, you can start with this Step by Step.

In order to receive the data from Sigfox, you’ll need to redirect all the messages using a callback from our Sigfox profile. You’ll need to configure our thethings.io profile for this:

  1. Navigate to Things (2nd row at the left).
  2. Create a new product: Insert your product name. Then choose a name for each resource you’re going to use. Finally choose Sigfox inside Format.thethings-io-newproduct
  3. Press on the product you have created. Copy the url in the Subscription URL.


Now lets move to the Sigfox backend:

  1. Go to Device:
  2. Navigate to Callbacks.
  3. Click new
  4. sigfox-callbacks-list-thethingsChoose the following configuration:
      1. Type: DATA UP-LINK.
      2. Channel: URL.
      3. Url pattern: Paste your previous subscription URL from thethings.iO.
      4. Use HTTP method: POST and click Ok.sigfox-callback-thethings

Parsing data from Sigfox

Now go to thethings.iO IoT platform and you will need to specify how to parse the data that Sigfox forwards to thethings.iO, in order to display the correct values:

  1. Go to Cloud Code
  2. Navigate to Functions and Edit the parser with the name that you gave to the product before.
  3. Parse your resources by splitting the string that Sigfox sends (An hexadecimal number containing all the sensor values, one after the other). In the preview params, copy the sigfox payload you send from Sigfox and change “quote” to “data” to prove your function.
function parseF(s) { // Use this function in order to patch the GPS data stored as floats in the code
 var a = ((s & 0x7FFFFF | 0x800000) * 1.0 / Math.pow(2,23) * Math.pow(2, ((s>>23 & 0xFF) - 127)));
 if (s >= 2147483647) { //If >= (it's a negative latitude or longitude)
 a =-a;
 return a;

function main(params, callback){
 var result = [
 //Replace with your own payload parse 
 "key": "temperature",
 "value": parseF(parseInt(params.data.substring(8,16),16))
 "key": "humidity",
 "value": parseF(parseInt(params.data.substring(0,8),16))
 callback(null, result) 

Creating the dashboard Widgets

It’s time to create an IoT Dashboard with thethings.iO to show all the values of your sensors!

    1. Click on the botom right cross (+)thethings-io-widget-create
    2. Introduce a name for the widget.
    3. Select Thing Resource.
    4. Select Sigfox.
    5. Select your thing Token.
    6. Select the resource that you want to show.
    7. Select how you want to show your resource (Lines, bars, log…) and choose realtime (if you want to see the values updating in realtime). Play with the value inside Custom Parameters.

Repeat this process until you finish your awesome IoT Dashboard!


3 reasons to use thethings.iO IoT platform

Every company that wants to be successful in the Internet of Things realm have a lot to do. One of the most crucial part is the IoT platform. Some of the key questions when building an IoT product are: Should I build my own IOT platform? should I use an IaaS as an IoT platform? or should I work with an existing IoT platform ready to go?

thethings.iO IoT platform

thethings.iO IoT platform

The answer is, don’t reinvent the wheel and keep IoT simple! We strongly recommend to use an existing IoT platform. At thethings.iO, we will be very happy to listen about your IoT use case or project and showcase you how does it look a tailored IoT platform for your product and customers with thethings.iO technology. And the most important part, making your life much easier for less!

Here find the main 3 reasons to use thethings.iO as the IoT platform our your connected product, if you are building an Internet of Things product.

IoT platform

IoT platform

1) The IoT platform working from the very first minute

thethings.iO IoT platform is the simplest IoT platform in the market. We know that launching a connected product is hard but it should not be complex to store data, monitor the data with flexible IoT dashboards and analyze the data from your devices and customers.

thethings.iO is a complete IoT platform solution that works literally in minutes. By working with thethings.iO, we save your time building your own IoT platform and maintaining it, with a fix cost. At thethings.iO we offer scalability, flexibility and security since you connect your first pilot until your production product is scaling to millions.

IoT Dashboards

IoT Dashboards

2) Customizable IoT dashboards

At thethings.iO, our customers and users can access to the data from any sensor, anytime anywhere. Historical data or real-time streams are pushed to thethings.iO panel. With unlimited API requests and data storage included, thethings.iO provides beautiful historical charts and real-time charts that you need to monitor and control your products.

thething.iO provides customizable and flexible dashboards to our customers. The IoT dashboards enable customers to visualize insights from the Big Data, we provide aggregations and KPIs, revealing trends or even detecting anomalies. Some of the features most used are the predictive maintenance, assets management or understanding the final customers usage of the connected products (churn, ROI, etc).

All of these data showed with a flexible dashboard and amazing widgets under the brand of our customers (logos, colors and URLs) makes thethings.iO one of the mot flexible and beautiful IoT platform in the market.

IoT Analytics

IoT Analytics

3)Cloud Code ready with deep analytics

As we are working with massive amount of data from the devices connected to thethings.iO, we have built a tool with enough flexibility to apply Big Data and Analytics algorithms on the top of the data in real-time or every some time (hours, days, etc), this is Cloud Code.

At thethings.iO Cloud Code feature you can work oriented to events with Triggers and get real-time alerts every time that any of your things send data. Configurable in just few clicks on or enjoying the power to code all what you need, thethings.iO offers this flexibility to non-technical managers or developers. The main goal of triggers is to get an instant alert when special conditions appears (e.g. temperature is too low, device is our of a virtual fence, button is pushed, among other).

The cloud code also offers Jobs which are algorithms executed every hour or every day. The aim of Jobs are providing a such powerful tool that enable technical people to aggregate data, summarizing the data, revealing trends, and detecting anomalies through Big Data algorithms such as predictive maintenance or artificial intelligence algorithms.

thethings.iO is ready to rock

Today thethings.iO is an IoT platform company operating on several verticals of the Internet of Things with a lot of experience on the industry, logistics and connected home use cases. We have close relationship with engineering companies, telcos and app developers to understand how to build end-to-end solutions.

All in one, thethings.iO IoT platform is the right place for every company seeking the best IoT platform and IoT dashboards to use with their networked products. Our main goal is to build the most simple IoT platform, so thethings.iO IoT platform is very easy and intuitive to use, and technical support is always available. You get your things connected quickly and easy with most of the IoT protocols such as HTTP, MQTT, CoAP, ModBus and Websockets.

So, why wait? There are a lot of advantages of a state of the art IoT platform waiting for you at thethings.iO.