Cooking Hacks Trip: Measuring acceleration with Waspmote in Port AventuraSeptember 25, 2012

[Artículo Prensa (En Español)]
[En Español]

Last June, we prepared a trip to pass a nice day with Cooking Hacks Team!! Destination: Port Aventura, one of the biggest theme parks in Europe, where one of the most impressive roller coasters of the world was inaugurated: Shambhala.

As we are a bit "geeks", someone suggested to use Waspmote to measure the acceleration of the roller coasters in Port Aventura so we said: "Why NOT?" We put Waspmote into an enclosure and programmed it with a simple code to measure the data from the 3-axis accelerometer which is included in the board, and save them in the microSD card. We connected the Wifi module and the code sent the data to our Smartphone each 2 minutes. The tests during the week were successful but... we had to test it in a real environment!!


// global variables
char data[100];
char* filename="log.txt";
int value=0;
long time=0;

void setup()
  // accelerometer setup

  // USB port setup

  // EEPROM register setup

  // Writing in the EEPROM

  // RTC on

  // SD ON

  // create file
  if(SD.create(filename)) USB.println("file created");
  else USB.println("file NOT created");

  // new rollercoaster log:
  if(SD.appendln(filename,"\n\n\n--------------------------")) USB.println("append ok");
  else USB.println("append failed");
  sprintf(data, "%d - This is a new rollercoaster. Time:%s",value,RTC.getTime());
  // append data to files
  if(SD.appendln(filename,data)) USB.println("append ok");
  else USB.println("append failed");
  if(SD.appendln(filename,"--------------------------\n")) USB.println("append ok");
  else USB.println("append failed");

  // set green led on when measurement starts

  // get actual time


void loop()
  // create new frame to be written
  sprintf(data, "millis:%lu#x:%d#y:%d#z:%d#",millis(),ACC.getX(),ACC.getY(),ACC.getZ());

  // append data to file

  // After 2 minutes of measurement, send WIFI data
  if(millis()-time > 120000)


void sendWIFI()
  // First, initialize the WIFI API and the connections with the waspmote
  // Then switch on the WIFI module on the desired socket.
  // If we don't know what configuration had the module, reset it.

  // 1. Configure the transport protocol (UDP, TCP, FTP, HTTP...)
  // 2. Configure the way the modules will resolve the IP address.
  // 3. Configure how to connect the AP.
  // 3.1 Sets the name of the ADhoc network.
  // 3.2 Sets the channel of the ADhoc network

  // 3. call function to create/join the Adhoc network.
    if (WIFI.setUDPclient("",2000,2000))
      // read and send all file lines
      for(int i=0; i < SD.numln(filename); i++)
        // Send messages to another device in same adhoc.
        WIFI.send(SD.catln( filename, i, 1));
        // Receive messages from the other in same adhoc.;



Friday came and the bus arrived to the Headquarters. During the trip we had time for games, jokes... even a karaoke!! When we were arriving to the park, we saw that Dragon Khan, with its loopings and electrifying falls, was not already the current icon of Port Aventura. Shambhala, the new roller coaster, was almost twice than the highest loop of Dragon Khan.

First we took a photo with Woody Woodpecker, Port Aventura's mascot. As you can see, we had a lot of energy to pass a nice day with all team. ;)

Along the day, we get on in all rides, getting funnier. The tests were made in several of them, but the most amazing were Dragon Khan and Shambhala. You can watch the result below.

After this great day in June, we are waiting the Costumes Day that we do in Cooking Hacks each year. You can visit our Facebook page and see the photos of last year. What kind of costumes will be this year? Who will be the winner?

I hope you have enjoyed this article as us.

You can find all information about Waspmote Starter Kit here.
You can take a look on the technical article in

David Bordonada from Cooking Hack's Team

Leave a Reply