How we created an iOT Device

Lefteris Haritou
6 min readSep 8, 2018

--

The idea

My brother in law (Aggelos Fekas) came to me 3 years ago with an idea he had. He wanted to create an automation device that would monitor the performance of Irrigation hose reels.

The idea was simple. He would monitor the hose reel turn rate and report the speed and time left to the farmer using an Arduino and a SIM800 GSM module (to send SMS messages). He would also report any speed changes and if the reel stopped irrigating (saving the crop in case a hose rupture).

The reel monitoring would be done by 2 hall sensors and the system would be powered from a 12V SLA battery, a solar battery charger and a 10Watt Solar panel, so the system can be fully autonomus.

So he started creating the project and I was helping him with the Arduino code. The project was completed and he started testing it on his fathers irrigation hose reel during the summer of 2016.

The project became also his bachelor’s thesis in Winter 2016 for his bachelor in the Technological Educational Institute of Thessaloniki

Early prototype of the system
Prototype on an irrigation reel
A better version of the prototype

Converting from idea to a product

When he started considering selling the project as a product, I suggested that he should convert the project to a custom PCB (adding a solar charger circuit) and I joined the project to help with the PCB and Arduino Development.

During that initial development we realised that the ATMega328 wasn’t enough. The 32Kb of Flash Ram, and 2Kb of SRam, were simply not enough for the project we wanted and so we moved to the Arduino Mega (ATMega 2560 MPU).

Arduino Mega Prototype

All that time we thought that if a Arduino Mega costs $6 on Ebay and a Sim800 module $4, we should be able to build our self designed PCB for less than that (Little did we know at that time that this was not even remotely close).

The process was amazingly challenging and we made a lot of mistakes that cost us a lot of money (we had to create 3 versions of the PCB before it was error free).

Version 1 of the PCB ( 10 pieces) which was very expensive and was useless
Version 2 of the PCB without silk screen and on a cheap finish
Final version of the PCB with Silk Screen

At the end and after 3 PCB designs we finally had a working prototype! The only problem was, we realised that the cost of the PCB production and assembly would costs us 3 times the cost of the Arduino Mega, the Sim Module and the solar charger, but at least we had a product now!

Our self designed PCB board

IOT idea

While testing the prototype I started thinking that now that we have a more powerful MPU, we could do more! So I thought that we should move from SMS to an own designed iOS and Android Application.

My idea initially was to create a Python backend that would expose REST API endpoints were the device would post data and the iOS & Android Applications would fetch them from the backend.

Thankfully my friend Vangelis Stykas at that time told me to look at the MQTT protocol as he told me that this would save tons of data and it was optimised for IOT Devices.

After a quick search I’ve discovered the real power of MQTT protocol and realised that this was what we needed.A lot of search went to find an MQTT platform that would work for us. We needed something low cost, but powerful enough. After a few weeks of testing the various platforms we found something that was going to work for us and with the help of Vangelis I was able to get our own MQTT server up & running.

Custom Bootloader challenge

During the PCB development and while I was speaking to a friend of Vangelis that had been creating electronic devices for a lot of years, he strongly advised me to create a bootloader for the MPU that would allow us to remotely update the firmware.

This was the best suggestion we ever had in this project. It saved our lives as our first couple of firmware versions had issues that we failed to discover, which were quickly fixed by doing OTA updates.

I’ve started looking around to find how I’d create a custom bootloader, but things were pretty complicated. It took days of reading and trying out to figure this out, but at the end, I’ve written a bootloader I’m very proud of!

It’s a very failsafe bootloader that never bricks the device (even if you turn it off during flashing).
It also does CRC checking and decrypting of the firmware (yes the firmware we upload to the device is encrypted), plus it has an option to restore the factory firmware in any case, by just holding the up & down buttons while powering on the device.

iOS & Android Applications

Final thing I needed to do, was to create the applications, but this was the least challenging thing in the whole project as I am a Mobile Developer for years.

Check out our iOS & Android Applications (description is in Greek, but both apps are multilingual, supporting English as well).

Here are some screenshots of the English version of the App:

iOS Screenshots of the Application for the device

The Product

Product installed on an irrigation reel
The box with the mount and solar panel

This is the final product inside a waterproof enclosure, with a custom front PCB Membrane and a custom designed metal support where the enclosure and solar panel are attached to.

The 12V SLA battery is contained inside the enclosure and plug terminal connectors are found on the bottom of the enclosure where the pressure and hall sensors are connected

You can also checkout this YouTube video with the product installed on some reels

Final Thoughts

This was one of the most challenging but fun things I did in my life so far.
Seeing the final assembled PCB made me really proud of what we achieved.

Making 10 PCB’s at once on the first PCB design (and with an ENIG finish which is very very expensive) was probably our biggest mistake. First PCB batches should always be made as cheap as possible and in very small quantities until you are 100% sure your PCB is working as it should.

Prices you see on Ebay are miles away from prices you’ll get from part suppliers. (An ATMega2560 MPU costs 10+ Euro from a supplier, and only 3.5 Euro on Ebay, but then again you are playing the Russian roulette if you are buying parts from China as there are tons of fakes and bad quality replicas)

Assembling the PCB in small quantities is also very expensive as the assembly cost drop drastically once the quantities increase, but then again it get’s very expensive to create large quantities of final assembled PCB’s

Sourcing the parts, is also challenging, as price changes happen often and components are a lot of times hard to find!

Credits

I wish to thank Vangelis Stykas for his help and for introducing me to Panagiotis Christodoulou

I wish to thank Panagiotis Christodoulou for helping me find the person to design our PCB, providing me with information’s on where to produce the PCB’s and where to assemble them and all his help during the development of the PCB.

--

--