Commercial, Gunnebo Retail Solution, Innovation, Reflections, Retail, Software Development Insights

Norwegian Trade Conference; BOPIS + BORIS = True

I had the opportunity to attend the Norwegian Trade Conference in Oslo 24th September featuring some of the most interesting retailers in Norway, and even a couple of international speakers. The focus for this years conference was BOPIS + BORIS = True, but some of the keynotes also focused on traditional retail and omnichannel.

Trade is never a dying concept but rather a constantly changing industry. This rapid change and advancement bought in two e-commerce acronyms to the market. This is none other than BOPIS which is abbreviated for buy online and pick up in-store facility and BORIS which is bought online and return in-store.  So what does this give your business? How does it support customers to have a better shopping experience? These are the questions we intend to answer by the end of this article.

0

These new purchasing behaviors have widened the scope of shopping gives more flexibility and convenience to your business. Let’s dig in deeper and see what advantages these new Omni channels provide you with.

From apocalypse to renaissance?

Trade would never reach an apocalypse. Rather, it gives new beginnings just like the renaissance. So, it can be related to it as well.  There is one question that many have in mind when it comes to engaging consumers and maintaining relationships with them further with regards to trade and business. Is trade all about customer experience or it solely based on price? 

Chernobyl - Cash register in abandoned store
Old rusty cash register on the floor of an abandoned store in Pripyat – Chernobyl nuclear power plant zone of alienation.

Recent statistics that mainly focused on Norwegians show that Norwegian shoppers who shopped in physical brick and mortar stores in Norway increased by 16% from 2012-2018 and those who shopped abroad in physical stores increase by 76% in the same time frame. 

On the other hand, Norwegian shoppers who purchased from Norwegian online stores increased by 101% and purchasing from international stores increased by 146% from 2012-2018.

It also revealed that 50% of consumers preferred physical stores whereas 20% preferred online stores. However, 30% did not really have a particular preference. 

Therefore, these facts show that customer service is not just a department or a small fraction in the trade industry. It plays a bigger role as the main purpose is to build a loyal member and focus every aspect of keeping the customer in the center. Simply said, the customer is the boss! Not to forget while the store is 50%, delivery is equally important and takes about another 50% nowadays.

From apocalypse to relevance

Peterson was the speaker of the year during “The Big Show” in New York in January and has about 30 years of experience as a retailer, strategist, and speaker. His innovative approaches to modern retail and strong expertise in cultural trends are his specialty. 

img_4192
Lee Peterson – EVP: Thought Leadership & Marketing – WP Partners

It was pointed out that retail closures were more than openings in the USA and the sole reason was shoppers were looking for more facilities than just shopping. Whilst shopping, they looked for eating spots and food halls are a great technique. They also look into children’s play areas, fitness centers, green spaces to relax, farmers’ markets, places to buy household items and other facilities. For example, farmers’ markets have 3985 in 2014 to 9027 in 2019 as buying fresh fruits and vegetables has increased over the years and a consumer on average spends about $16 per visit.

Therefore, many shoppers looked for an all-in-one place to get all that they need. Therefore, incorporating this concept shows that shopping is not dead yet, but rather the way shopping is done must be changed. This is where BOPIS and BORIS become two famous traditions that are followed these days for customer convenience. 

BOPIS and BORIS

BOPIS

Unlike earlier days, people are less patient and expect instant gratification. Thus, BOPIS is very useful for people who are stuck in workplaces or traffic and do not really have the time to choose items in shops. Through this, they get the option of choosing the goods they need online and picking it up on the store. This saves time for people with busy schedules to smoothen their shopping. On the other hand, when customers pick their goods, 75% of them also purchase additional items while in-store.

Looking at the near future, the use of technology will be more heavily incorporated into shopping. For example, having 3-D views of products and being able to visually shop their stores and getting it delivered. 

BORIS

This is another option where you could buy online and get it delivered. However, if you want to exchange or return to a physical store, you can do so. So the hassle of return shopping is eliminated and is a convenient service. The benefit of it is that when customers visit the store to return goods, there is a high chance that they might exchange or even buy additional goods.

But these innovations won’t mean it is the end of shopping centers because having physical stores gives delight to people which virtual stores cannot give. People like to touch, feel or smell which online stores cannot give because those sensations can induce spontaneous purchases.

The line between physical stores and online stores will get thinner and thinner day by day and a new concept will come known as a physical store which will create a fluid web-to-store system with a smooth customer experience. Therefore, many different methods will be used with different approaches to reach different audiences.

How to create total seamlessness between the web and the store?

As Hauk Landsverk, Digital Director of  Elkjøp expressed, to create a seamless integration between web and physical store is through these omnichannel approaches like BOPIS and BORIS to create a link between physical stores and mobile, telephone or computer devices.  Through these, customers will enjoy the benefits of technology which will simultaneously cater to their needs as well. It will be customer-centric rather than product-centric where it is based on the customer’s journey and experience which is a fundamental factor.

img_4212.jpg

It speeds off the web

Siv Heleen Grødem, entrepreneur and owner of the Suser i Sivet highlights certain strategies to enhance the shopping experience such as instead of selling individual clothes,  you sell a full costume. Apart from that other factors like social media promotions by stores, online presence and personal services like cash on delivery are a few aspects that also enhance the shopping experience. 

img_4213

Suser i Sivet also won the prestigeous award for retailer of the year: “The winner is the result of hard and planned work over many years, a willingness to invest and dare to try out new things and excellent marketing in social media. The result is a modern, forward-thinking business that masters the demanding art of combining online sales and physical store in an excellent way.”

Different industries, same customer – how to meet future customer needs

Ingjerd Blekeli Spiten, Executive Vice President of  PersonMarked highlights modern payment options like mobile banking and paying online as new developments that make purchasing more easier and convenient. Most banks and online payment gateways are trustworthy and reliable where almost 90% of people trust their banks and 20% of the people trust global payment systems like PayPal.  There are few others as well that rely on social media payments, IT companies or mobile companies.

img_4143.jpg

Keeping up with the consumers – how Zalando aims to become the starting point for fashion

David Hejgaard, Regional Lead Nordics of Zalando reflects on Moore’s law stating evolution is much faster than ever where customers tend to shop anywhere at any time of the day. Most physical stores have partnered with virtual stores where people can choose the color and size of what they need. If this is available in the virtual warehouse, they can purchase it. 

img_4233.jpg

How to prepare for a different future?

Truls Fjeldstad, Director of marketing and business intelligence at NorgesGruppen is a charismatic guy who mainly focuses on sustainability. He believes that classical stores where you pick and pay will continue to exist and never halt. Thus, to prepare for this, new features and services must be introduced to support the traditional brick and mortar stores. These include personal assistants, IoT, automation, and delivery as well. 

img_4245.jpg

How to leverage customer data and not just collect it?

Anton Nytorp, Head of CoopX at Coop Norway is a firm believer in heat mapping. This is a great technique to understand customer’s purchasing behaviors in the store. These analytics show actions and what your customers usually like. It is a good way to record data in a way that can be interpreted rather than just merely collecting it. 

20190924_112638111_iOS.jpg

Furthermore, placing similar products of different vendors is another great technique so consumers have many options to choose from if they don’t like a particular product type or brand. This also shows and helps identify which products are more likely to be bought.  Having an unmanned- store in Norway is also on the bucket list as it will show what customers actually want and not forced or induced to buy sales representatives. 

Symbolic consumption and self-concept

Siv Skard, Associate Professor at Kristiania University College researches consumer behavior. She highlights that people are always concerned about how others look at them and judge them. This is a great point that can be taken advantage of from a business perspective.  People are self-centered and if they notice that they are being watched, you can promote concepts like ‘go green’ or ‘go healthy’ which people tend to buy. 

img_4271

How to create results online from the first click?

Rune Kjeldsen, General Manager at “Hekta på Tur” began his first business at the age of 22 which was sold to a Dutch company. He then began an online store called Hekta Pa Tur which has steady and stable growth. Today it is a leading profitable store.

20190924_115254648_iOS.jpg

Thus the moral of the story is when the wind of change blows, you must build a windmill if you’re a winner because losers will build wind-shields instead.

The customer experience is what will differentiate you from the competitors in the future. 

Always keep in mind that customer experience is far more important than having a good customer service system. Thus, to ensure smooth and efficient customer experience, it is necessary to indulge in profitable and sustainable business models inclusive of Omni channels like BOPIS and BORIS. These strategies are what gives customers a better overall experience.

Sveinung Jørgensen, Associate Professor at INN and Lars Jacob Tynes Pedersen, Associate Professor at NHH research on sustainable and profitable business models working closely with Norwegian and international companies. They have published a book together called ‘RESTART 7 Roads for Sustainable Business Models’. You can read more about them at www.JorgensenPedersen.no

There are a few ways to enhance the customer experience. You can Redesign the business model and approach focusing on a customer-centric fashion model as it is important to see through the customer’s eyes.

Controlled experiments is another process of understanding customers and to see their issues beforehand. You can see the usability of the products, how well people can use and their overall experience and impression of the particular product or service.

20190924_121630287_iOS.jpg

Another method is Circular processes which are usually adapted by product-oriented companies who have sought ways to give in a service and benefit from it. For example, you purchase a washing machine and pay in a cycle whereas the manufacturer will ensure that it works properly and service it when needed. Service logic is quite similar to a circular process and is relatively new which focuses on exchanging services than just goods.

Alliances are equally important to engage with your customers and communicate with them throughout their shopping journey. You can get information such as feedback, their experiences. Knowing these you can adapt means to ensure customer’s expectations are met. Another important aspect is Results that are obtained by different analysis will help you identify loopholes and fix any issues to enhance the overall customer experience.
The three dimensions of customer experience are segregated into three elements. The first is a success where the customer is able to get what he/she requires and also see if the interaction was successful or not. An effort is analyzed to see how much effort the customer had to personally put to get a successful interaction. Lastly, emotion is whether the overall interaction left the customer delighted or disappointed.

The changeover process in the green shift

Anita Sørlundsengen, Retail Director and  Øyvind Andreassen, Senior Region Manager at ST1 Norway highlights the importance of the green shift in the modern century.  Gas stations have now transformed into energy stations with new concepts constantly developing. See how ST1 / Shell at retail director Anita Sørlundsengen and retailer Thommas Landsem have created the energy station of the future with special emphasis on good customer experiences. 

20190924_123812081_iOS.jpg

From market leader to challenger

Lars Kristian Lindberg, CEO / Managing Director at Gresvig emphasized that Gresvig was in need of a change or an advancement from a strong national brand to a more profitable international brand. Ole Sauar, Founder and CEO of Jollyroom stated that social media and influencers are a great method to grow your business in an international platform. Also having playing zones is another key idea. 

Also keep in mind that nordic countries who balance between socialism and capitalism have better economic efficiency and growth and thus, investors must carefully consider this aspect as well.

The key is to hit the emotional muscle

Sondre Gravir, CEO of the SATS group which is a leading fitness center chain in the Nordic region highlights that rather than focussing on getting in participants to the gym, the focus must be on getting the customer to the gym.

20190924_134623480_iOS.jpg

New business models

Emilie Stordalen, daughter of Peter Stordalen and part owner at Strawberry Group is a charismatic and down-to-earth personality. She currently works to develop and operate digital platforms. The specialty about her is that she focuses on individual people such as Amanda, who is young and modern to Anders, who is a bit aged and classical which gives a more personalized experience to customers. 

20190924_135607272_iOS

Another strategy used is that they tend to use low-quality locations such as basement rooms and give high-quality experiences like LED walls where you feel like you have woken up in a rainforest. These minute details are very important to create a positive image about your services or goods to the customers.

If you are interested in hearing more about the future of retail and IoT, feel free to contact me at bjorn.nostdahl@gunnebo.com 🙂

Software Development Insights

The demise of Major Retail Chains in the US

The number of retail chain stores closing over the past few years has dramatically increased. Yet, as of 2019, large stores announced the closing of almost 7000 stores. This is comparatively more than 2018 where 5000 stores shut down. If this continues, it could be the retail apocalypse. 

Store closing sign on business store front.

The sole reason behind this rapid closing of traditional stores is the rise of e-commerce outlets where traditional stores are no longer an attention- grabber. As mentioned in the previous article, online sellers like Amazon have made it really difficult for stores to withstand in this digital era.

Most of these stores have begun changing their sales strategies particularly focussing on digital marketing. Thus, they have now moved from brick and mortar stores to e-commerce sites. The trend these days is to do purchases online. This saves time and money for needing to visit stores. Buying products online is a more convenient method.

Apart from that, bankruptcy is another major concern because of private-equity firms like what happened to Toys R Us. Most of these private-equity companies are more likely to go bankrupt than public companies. Although these companies express that they can help to grow capital, they are silent about debt and leverage buyouts.

What happened to American Apparel?

American apparel was a major selling store since its launch in 1997. It faced a lot of sexual harassment and defamation issues costing the company $3 million as fines. In 2017, facing bankruptcy for the second time, they had to close most of their stores.

It was purchased by Gildan Activewear by the end of 2017 for $88 million. The major change is that sexual images are no longer there. The new American Apparel emphasizes more on materials and pricing to attract customers.

Toys R Us: the kids’ dream store

Toys R Us has been around for 70 years and was every child’s dream store. This company faced its doom when taken by a private equity firm in 2005. It faced an unsustainable debt and filed bankruptcy in 2017.  

April 20, 2018 San Mateo / CA / USA - Toys R Us logo and "Going out of business" announcement above the entrance to one of the locations in San Francisco bay area; customers going into the store

This decision was taken as suppliers pressurized and they liquidated remaining stores. They had to close almost 700 stores of theirs and sold the rest to Canada. Many say there might be a comeback but Toys R Us will be a fond memory for many.

Victoria’s Secret – A girl’s best friend

Parent company L Brands announced closing almost 53 Victoria’s Secret stores in 2019. They even did close 30 stores in 2018 due to bad sales. One reason was the controversial comments that the chief marketing officer spoke of transgender and plus size. 

Panoramic view of a Victoria's Secret store front

This incident outraged many and led to a reduction in sales. Apart from that, many people claim that the quality of products has dropped as well.

Abercrombie and Fitch – new  toned-down version

Abercrombie and Fitch have planned to close almost 40 stores in the USA this year 2019. They have made plans to change their marketing strategies and be more sales-oriented. Getting rid of sexual ads was another point of focus. 

They have also mentioned opening 3 flagship stores redesigning others as a part of the restructuring. Moreover, The change of infrastructure in which they have moved from dark tones to a more bright and light atmosphere is a key highlight.

GAP – shutting down rapidly

One of the most famous brands, GAP is closing doors of almost 700 stores worldwide. Its sister stores like the Banana Republic are struggling to survive as they are not performing well. 

August 20, 2019 Palo Alto / CA / USA - Gap store in Stanford Shopping Center in San Francisco bay area

They are planning to split into two and have decided to change business models to increase profit. The Old Navy will go on a separate way. This is another marketing strategy as well to increase sales.

Payless- bankruptcy victim

A few years back, Payless went into bankruptcy for the second time. Now it is finally closing doors in 2019. They are planning to close almost 2300 stores within the USA. One reason was that the shoe store only has physical stores and with the increase in online sales, store sales have gone down. 

AdobeStock_284256038_Editorial_Use_Only.jpeg

On the other hand, Just like Toys R us, private equity buyouts are very hard to bear due to an extensive amount of debt. They also began liquidation sales which went until June 2019.

Michael Kors: Restructuring

Michael Kors closed almost 100 stores in 2017. This year they will be shutting 50 stores and have stated that there could be more. This is because of the low sales that the company encountered. It has also faced great difficulty to focus on average buyers being a luxury brand. However, they have partnered with Amazon and have moved to online sales which is a positive movement.

View at Michael Kors shop. Michael Kors  is a New York City-based fashion designer widely known for designing classic American sportswear for women.

Claire’s –  The Accessory Chest overcomes Bankruptcy 

Claire’s is a very popular store for teens with an extensive amount of accessories.  However, Claire’s also sought Chapter 11 protection due to bankruptcy. It, however, eliminated its debt of $1.9 million. They also underwent restructuring and eliminated about 2000 locations. 

Gymboree – Children’s clothing 

Gymboree was another victim of bankruptcy and sought for protection under chapter 11. It was another store that was dependant on brick and mortar. It faced a lot of loss in sales that made the company face debt. It has planned to close all Gymboree and Crazy 8 stores within the US and Canada which is about 900 stores in total.

J.C. Penny – 116-year-old outlet

J.C. Penny closed about 130 stores back in 2017 due to a dip in sales and has also decided to close 18 more stores. This Giant retailer was forced to close their shops because they have been losing a huge amount of money, due to a reduction in sales. At the moment, it is a broke company and stores are out of date. There are assumptions that they have been planning to open some toy shops at their brick and mortar stores.

August 14, 2019 San Jose / CA / USA - JCPenney department store located in a mall in South San Francisco bay area

Conclusion

The list of retail stores calling it quits can go on and on. It is almost like a global epidemic that infests to every retail chain and shuts it down. The list mentioned here is just a few of them. More and more companies are facing issues either due to bankruptcy or lack of sales because of online purchases. Yet, some stores like Gucci, Luis Vuitton and Claire’s have risen from this problem and have adapted new marketing strategies.

We are living in a new world, with new channels and if you want to know how to make your retail business ready for the future, please reach out to me: bjorn.nostdahl@gunnebo.com

Debounce, Internet of Things (IoT), Microsoft Azure, Node RED, Software Development Insights

Debounce Algorithms in IoT

Working in IoT we sometimes need to handle large data streams of information, that might or might not be totally accurate. Streams might contain noise, inaccurate/unreal readings and other unwanted data.

Digital oscilloscope-1

Switch debouncing

Debouncing can be done on the hardware itself, or in software. Hardware debouncing can be done either using an S-R circuit or an R-C circuit. Two famous algorithms to do software debouncing is vertical counter and shift registers. Despite being well-known, in literature, these methods are typically presented as a code dump with little or no explanation. In this article, I will touch upon these circuits, methods and other algorithms and their use in IoT debouncing.

Understanding Switch Bounce

When the contacts of mechanical switches toggle from one position to another, these contacts bounce (or “chatter”) for a brief moment. During the first millisecond, the bounces are closely spaced and irregular, and although all of it happens in the course of milliseconds, high-speed logic will detect these bounces as genuine presses and releases.

Electrical panel. Low voltage device. Electrical equipment. Power supply. Electro substation. Power net.jpg

A button release produces bounces too, but it is common for a switch release to produce less bounce than for a switch press.

Switches usually become stable after 5-20ms depending on the quality, size and electronics of the hardware.

Hardware Debouncing

Debouncing using S-R circuits

Switch debouncing using S-R circuit is one of the earliest hardware debouncing methods. In this circuit, S-R latch avoids bounces in the circuit along with the pull-up resistor. It is still the most effective debouncing approach.

The figure below depicts a simple digital debouncing circuit which is used quite often.

1

The circuit utilizes two cross-coupled NAND gates which aim to create an S-R latch, A SPDT (Single Pole Double Throw) switch and two pull up resistors. Then the resistor produces and generates a logic ‘one’ for the gates and the Switch pulls one of the inputs to ground.

If the switch is kept in a position as  seen in the figure, the output of the upper gate is ‘1’ regardless of the input of the other gate and the one created by the bottom pull up resistor which stimulates the lower NAND gate to zero, rapidly in turn hustles back to the other gate. If the switch moves back and forth like a pendulum between the contacts and is suspended or halted for a while in neither one of the regions amidst the terminals, the latch preserves its’ state because ‘0’ from the bottom NAND gate is fed back. The switch may move between the contacts but the latch’s output assures that not in any way it would bang back and therefore, the switch is bounce free.

R-C Debouncing

Although S-R is still common, it’s bulkiness cause problems when you try to use it frequently. You can see that it uses many hardware pieces. Another drawback to using S-R circuits is SPDT switches are more expensive than SPST switches. Thus, a new approach of debouncing emerged using an R-C circuit. The basic principle behind it is to use a capacitor to filter out swift adjustments or changes in the switch signal.

The following image demonstrates a basic R-C circuit which is used for debouncing.

2

It is a simple circuit which uses two Resistors, a Capacitor, a Schmidt trigger hex inverter and an SPST switch.

  • In the event where the switch opens, the voltage across the capacitor which is initially zero begins to charge to Vcc through R1 & R2. The voltage at Vin is higher and hence, the output of the inverting Schmitt trigger is low (logic 0)
  • When the switch is closed, the capacitor discharges to zero and subsequently, the voltage at Vin is ‘0’ and output of the inverting Schmidt trigger is high (logic 1)

At the time of the bouncing condition, the capacitor will halt the voltage at Vin when it comes to either Vcc or Gnd.

You may wonder why a standard inverter is not used. There is a problem for using the standard inverter gate here. TTL defines a zero input when the applied voltage is between 0 and 0.8 and the output in certain circumstances or situations is very unpredictable or unforeseeable. Thus, we must use a Scmitt trigger hex inverter. Thereby, the output remains constant even if the inputs vary or dither and it also ensures to prevent the output from switching due to its’ hysteresis trait.

Software Debouncing

We can debounce switches using the software as well. The basic principle is still to switch signals and filter out glitches if any. The most used algorithms used for that are counters and shift registers.

Counter Method

The first approach uses a counter to time how long the switch signal has been low. If the signal has been low continuously for a set amount of time, then it is considered pressed and stable. 

Let’s see the steps in the Counter method. 

First, we set up the count value to Zero. Then set up a sampling event with a certain period, say 1 ms. You can use a timer for that. On the sample event, Do the following things.

If the switch signal is high, reset the counter variable to 0 and set the internal switch state to ‘released’. If the switch signal is low, increment the counter variable by 1 until it reaches 10. once the counter reached 10, set the internal switch state to ‘pressed’. 

Shift Register Method

Similar to that of the counter method. The only difference is that it uses a shift register. The algorithm assumes unsigned 8-bit reg value usually found in microcontrollers

First, set up the shift register variable to xFF. Set up a sampling event of period 1 ms with the help of a timer. On the sample event, Do the following things.

First, shift the variable towards MSB, the most significant bit. Set LSB, the least significant bit to the current switch value. if the shift register value is equal to 0, set internal switch state to ‘pressed’. otherwise, set internal switch state to ‘released’. 

IoT Sensor Bounce

Recently my team has been working on telemetry involving OCR decoding of License Plates. I consider data from an OCR routine, a temperature sensor or a push button the same thing and debouncing the telemetry can be done very much in the same way.

Collection of European license plates from different countries

First of all, we needed to clean up the data stream by filtering out incorrect values. Since there are not control digits on license plates, we chose to trust the result if the camera would return three similar plates within five iterations.

If you want to know more about how to debounce data streams or if you have any questions, please reach out to me: bjorn.nostdahl@gunnebo.com

 

Holiday, Reflections

Finally Vacation :-)

Finally it is vacation time again – and I can spend some precious time with my family 🙂

17th May Celebration

The summer starts (as always) with the celebration of the Norwegian Constitution Day – the national day of Norway – and is an official public holiday observed on May 17th each year. Among Norwegians, the day is referred to simply as syttende mai (lit. “seventeenth May”), Nasjonaldagen (The National Day) or Grunnlovsdagen (The Constitution Day).

20190517_102423557_iOS

The Constitution of Norway was signed at Eidsvoll on May 17th in the year 1814. The constitution declared Norway to be an independent kingdom in an attempt to avoid being ceded to Sweden after Denmark–Norway’s devastating defeat in the Napoleonic Wars.

546398_10150796919012691_287569939_n.jpg

The unique tradition of the celebration of the 17th of May brings some complexities. That is the reason why it is often confusing and hard to understand for a new-comer to Norway with all the fuzz during the day. The children carry flags and march together with bands. Ice cream, hot dogs and other goods to eat are abundant. The buildings are decorated with Norwegian flags and women and men of all ages dress in their Bunad, or national costume. Graduating high school students wear their russedress and celebrate the approaching school year’s end. The sound of loud music is heard from every corner. Understanding of all these 17th of May traditions requires some historical and social background knowledge.

Sweden Rock

Working in Sweden, I had the opportunity to attend the Sweden Rock festival. Classic rock, hard rock, metal and even some blues – something for all tastes. Clean and neat, safe and secure. Ocean-near location, cozy grass hillsides and real lavatories. But most of all, a really friendly and good-natured atmosphere. Like one big family, with members from over 50 countries. The best audience in the world, quite frankly.

20190606_184818343_iOS

The festival ran from Wed, 5 Jun 2019 – Sat, 8 Jun 2019, and I had a really great time in one one of the most exhilarating festival in the world. It promises to be a good time.

Tons of Rock

Lagends like Kiss, Def Leppard and Satyricon played at Tons of Rock, and I was overwhelmed to attend this great event!

file-1.jpeg

Dream Theater had a great show, celebrating the 25th anniversary of the masterpiece “Images & Words” with us at Ekebergsletta.

Maintenance and Spring Cleaning

Spring is the time to roll up the sleeves and fix whatever the long winter has torn down or wore out. Painting the house, cleaning the back yard and of course applying antifouling paint on the boat to keep the sea-weed away.

20190718_113241512_iOS

I also took the time to fit out the shed with a hardware lab, so the family and myself can work on mechanic repairs outside. The first task at hand was to fix the injection fuel pump for the boat as this had corroded during the winter.

Sun and Sand in Spain

This year (as always) we will go to Orihuela Costa in Spain. Orihuela Costa is a coastal region situated on the Costa Blanca in the province of Alicante. It sits close to the border with Murcia, near La Manga and the beautiful Mar Menor. Despite its name it is actually around 20 kilometres away from the main resort of Orihuela.

WP_20160617_23_52_34_Rich.jpg

The region covers several resorts including Punta Prima, Playa Flamenca, La Zenia, Cabo Roig, Villamartin, Campoamor and Mil Palmeras.

Orihuela Costa is an ideal destination for those looking for a beach family holiday, with 16 kilometres of diverse coastline. It is also an excellent choice for golf holidays; in fact Orihuela Costa is well equipped for all needs, with lots of amenities, facilities and leisure attractions

Cartagena Roman Theater

The theater was built between 5 and 1 BCE, and for centuries was covered by a cathedral built over the upper part of the the theater’s “cavea,” or seating area. The first remains were discovered in 1988, and the theater underwent restoration, completed in 2003. Today the ancient arena still holds performances, and there is a museum at the site displaying the finds from a series of archaeological excavations.

Cartagena looking over the Roman Amphitheater, Spain-1_low

Alicante Castle

Alicante boasts many treasures. And among its most prominent is indisputably the Castle of Santa Bárbara, which stands on Mount Benacantil overlooking the city. Hewn from millenary stone, this fortress has witnessed centuries of history in this ancient city and even played a leading role in several chapters.

Alicante Santa Barbara castle in Costa Blanca, Spain-1_low.png

Leisure and Activities for the Kids

Not living the kids out, there would also be fancy events and activities they can do to make them enjoy this holiday. I understand that visiting some of these places can be a bore to them, and some places may even be over exiting..

file-2

Music and Entertainment for the Dad

Every Tuesday and Friday I will go to the lunch jam at El Rincon Del Tio Cali where the local musicians will entertain and involve us in fantastic musical experiences. I most likely would be visiting here on my own probably after the kids have gone to other fancy places to catch fun time.

20180807_144102478_iOS

Leyendas del Rock

Leyendas del Rock is a rock and metal festival that takes place in the city of Villena, Spain. Now celebrating their fourteenth edition – and the seventh consecutive year in it current location – the festival has become a respected date in the calendar of heavy metal fans thanks to the lineups of the scene’s favourites.

With more than 60 performers spread across four days and five stages, the high-octane display of hard-hitting rock sounds will this year be headlined by Australian four-piece Airbourne and legendary Irish rockers Thin Lizzy, among others.

20180810_224013993_iOS

So, have a nice vacation everyone – I will see you again in 26th August 🙂

MQTT, Protocols, Software Development Insights

MQTT for Dummies

In this article, I will be discussing one of the most trending topics in IoT. I will take you through a beginner level tutorial on MQTT which is currently the most used protocol in IOT projects. 

MQTT Message Queuing Telemetry Transport-1_low

MQTT stands for Message Queueing Telemetry Transport Protocol. To put MQTT in a nutshell, it is  “A lightweight event and message-oriented protocol allowing devices to asynchronously communicate efficiently across constrained networks to remote systems”. I know that this doesn’t really help much. So let’s try to decode that definition and understand what MQTT is and how to use it.

What is MQTT?

Again, for people who have no idea about MQTT, it is a protocol for machine-to-machine communication. It uses a publisher-subscriber model for communication. If you are from a programming background, you probably would have some knowledge about the publisher-subscriber model. Anyway, we will discuss the publisher-subscriber model and how MQTT works later in the tutorial.

MQTT over HTTP for IoT

Before going onto discuss how MQTT works, let’s first try to understand how it came to existence. MQTT came to exist as a replacement for HTTP because HTTP could not properly answer the challenges in IOT and M2M projects. Unlike web applications, IOT projects have some peculiar challenges. One of the main concerns is that IOT requires the event-driven paradigm. Some of the features of this event-driven paradigm are:

  • Emitting information one-to-many 
  • Listening to events whenever they happen 
  • Distributing minimal packets of data in huge volumes 
  • Pushing information over unreliable networks  

Some other challenges you face in an M2M application 

  • Volume (cost) of data being transmitted 
  • Power consumption 
  • Responsiveness 
  • Reliable delivery over fragile connections 
  • Security and privacy 
  • Scalability

MQTT was successfully able to cope with these challenges due to their features. 

Why MQTT is good for M2M and IoT applications

MQTT has unique features you can hardly find in other protocols, like:

  • It’s easy to implement in software as it is a lightweight protocol.
  • MQTT is based on a messaging technique. This makes it faster in data transmission compared to its alternatives.
  • It uses minimized data packets which results in low network usage.
  • Low power usage. As a result, it saves the connected device’s battery.
  • Most importantly it works on real-time which makes it ideal for IoT applications.

We learnt earlier that MQTT works through a publisher-subscriber model. In a P2S system, the publisher sends its messages to a topic. Then, every subscriber of that topic will receive the message. In MQTT, Broker handles the topic and messaging process while MQTT clients behave as publishers and subscribers.

Components of MQTT

To learn about how MQTT works, we have to understand some concepts in MQTT. The fundamental components of MQQT protocol are explained below.

Broker

The broker is a server that handles the communication and data transmission between the clients. It is responsible for the distribution, management and storage of data sent and retrieved by the clients. The broker acts like a centralized hub that regulates the message exchange. 

In the case where a broker breaks down, the whole communication process breaks down as there is no way for the clients to communicate with each other directly. Therefore, the Broker Bridging mechanism was introduced to prevent such cases and build a fail-safe broker network. 

There is a number of broker applications available on the internet including the popular ones; Mosquitto and HiveMQ or you can also use cloud-based brokers from cloud providers such as IBM or Azure.

Clients (Publisher, Subscriber)

These are basically the end-users who retrieve the data distributed by the broker. Each client is assigned a unique ID to identify themselves and the session when connected to the broker. A client could either be a publisher who publishes messages under a specific topic or a subscriber who receives messages relevant to a topic, at one time.

Message

These are the chunks of data sent and received by the clients. Each message consists of a command and a payload section. The command part determines the type of message and there are 14 message types available in MQQT.

Topic

This is the namespace or literally the topic that describes what the message is about. Each message gets assigned to a topic and clients can publish, subscribe or do both to a topic. The clients can also unsubscribe from a topic if they want to. MQTT topics are just strings with a hierarchical structure. 

Assume that there is a topic called “home/kitchen”. We call home and kitchen as levels of the topic while home being topper level topic than the kitchen. Also, topics can use wild cards such as ‘+’ and ‘#’.

Publish

This is the process of clients (Publisher) sending data to the broker under a topic be distributed among the clients (Subscriber) who have requested data from the same topic.

Subscribe

This is the process of Clients (Subscribers) receiving data specific to a topic they have previously subscribed to, from the Clients (Publishers) through the broker.

QOS: Quality of Service

Each message is given an integer value from 0 to 2 to specify the delivery mode. This is known as Quality of Service. There are three different types of QOS.

  • 0 (Fire and forget) – the message is delivered only once, acknowledgement not given, high-speed delivery method.
  • 1 (Acknowledgement) – the message is delivered once or several times until an acknowledgement is received. 
  • 2 (Synchronized) – the message is delivered only once, guaranteed delivery, comparatively slower.

Practical use of MQTT

Its time to do some practical things here and get used to dealing with the MQTT protocol. As you learnt previously, there are many MQTT clients developed for each programming language.  I will use Paho python MQTT client as I am a fan of Python and it is probably the best MQTT client out there. 

mosquitto-text-side-28

First, you need a broker to create an application with MQTT. One of the most popular MQTT brokers is Mosquitto. You can install it with the following command. 

sudo apt-get install mosquitto

We set up it to work on our localhost. By default, Mosquitto listens to port 1883. Next, install the MQTT client with pip command.

sudo apt-get install mosquitto

We setup it to work on our localhost. By default, Mosquitto listens to port 1883. Next, install the MQTT client with pip command.

pip install paho-mqtt

This command will install python MQTT client library on your machine. The core of the client library is the client class which provides all of the functions to publish messages and subscribe to topics. 

There are several important methods in Paho MQTT client class which you should know:

  • connect()
  • disconnect()
  • subscribe()
  • unsubscribe()
  • publish()

Each of these methods is associated with a callback

Publishing a message

One of the main tasks you do with MQTT is publishing messages. A simple code that publishes a message usually has 4 steps.

  • Import the paho.mqtt.client class
  • Creating a client instance with Client() constructor
  • Connecting to the server with connect() method
  • Publish messages with publish() message.
import paho.mqtt.client as mqtt

clientName = mqtt.Client("uniqueClientId)
clientName.connect("localhost",1883,60)
clientName.publish("TopicLevel1/test", "Your Message Here");
clientName.disconnect();

Most of the code is self-explaining. First, you create an instance of an MQTT client. Then you connect with the broker running on Localhost. Then the client publishes its message on “TopicLevel1/test” topic. After that, it disconnects from the broker.

Subscribing to a topic

You know that MQTT is not a one to one messaging protocol as it connects many devices. The trick here is that message from any device is assigned to a topic. Any devices that are subscribed to that topic will receive the message. Similarly, you can publish messages to Topics.

You can subscribe to a topic with subscribe() method in Client class. Subscribing to a topic has the same steps as to publishing messages. I am not going to repeat it as you can easily identify these steps from the code.

import paho.mqtt.client as mqtt

def on_connect(subscriber, userdata, flags, rc):
  subscriber.subscribe("topic/test")

def on_message(client, userdata, msg):
  if msg.payload.decode() == "Disconnect!":
    subscriber.disconnect()
    
subscriber = mqtt.Client("subscribeeId")
subscriber.connect("localhost",1883,60)

subscriber.on_connect = on_connect
subscriber.on_message = on_message

subscriber.loop_forever()

In this application, the client works as a subscriber. It subscribes to the topic to the broker which in this case, runs on localhost. Whenever it receives a message, it calls for the on_message() method. If the received message is disconnected, it immediately disconnects from the broker. This is a very simple use of subscriber method. You can write more complicated logic using the same callback functions. 

So in this article, you get a concise yet comprehensive idea about MQTT. Its’ time to move on to the conclusion to recall yourself as to what is the gist of the article.

Conclusion

MQTT is a lightweight, flexible and a simple but very efficient protocol that has a definite advantage over others when it comes to IoT and M2M solutions; considering its low bandwidth and low power consumption, response time and multiple usages. In conclusion, it could be said that MQTT is the best protocol so far when it comes to IOT development.

If you want to know more about MQTT, you can check the links below or have any questions, please reach out to me: bjorn.nostdahl@gunnebo.com

MQTT and ActiveMQ on RPI

MQTT for PIC Microcontrollers