Just recently I was invited by fellow MVP Serge Pilko, CEO of Embarcadero tech partner Softacom, to discuss Windows development using Delphi to work with IoT devices. IoT, or “the internet of things” is a hot topic right now. Devices like Arduino and Raspberry Pi have opened up a whole new market of very low-cost devices which can control, sense and record all sorts of things from air pressure to moisture content of soil and can perform a wide variety of incredible real-world functions. It’s a beguiling and addictive subject and, as you’ll see in the video, once you start looking into it you may soon find yourself hooked!
Table des matières
How do I get started in IoT Windows development?
Serge and I discussed the basics of what is meant by an IoT device, what does IoT really mean, and what can an IoT device do. As you will see in the video, I brought along a selection of different IoT devices, ranging from commercial biometric units like fingerprint readers and face scanners to tiny keyfob-like Bluetooth Low Energy (BLE) tags.
How to program an IoT device and link it to a Delphi program
In the video I show how I program a really cool tiny Arduino-based computer, smaller than my thumb, and then write a short Delphi program to respond to button pushes on that midget computer on my Windows development PC. This all happens with just a few lines of code. It’s the wonderful thing about Delphi, how it enables low code Windows development of all sorts of apps.
What sort of IoT devices are shown in the video?
In the video I show a BLE device from Blue Charms which is detected using Delphi’s BLE device scanner sample app. The sample app gets installed when you install RAD Studio Delphi if you tick the “samples” option on the installer. You can also find it on the DocWiki.
Serge and I also talked about an excellent internet and cloud-connected relay from Shelley. The actual Shelley IoT device I showed was the Shelley 1PM. You can get your Delphi app to communicate with the Shelley device either via REST – the built-in RAD Studio Delphi REST Debugger helps a lot with that – or use IoT communication protocols like MQTT and Windows sockets which are also built in to that particular device.
What is the Arduino IDE and how can it be used for IoT Windows development?
The real star of the show is the super tiny, smaller than my thumb M5StickCPlus.
Serge and I talked about quite how amazing this tiny device is and how easy it is to program. It is based on the mighty Arduino system, and you can use the Arduino IDE to send down your own code to it.
How do I make an IoT device talk to a Delphi app?
Once the IoT code, written in embedded C, is sent down to the M5Stick I got it to register itself on the free to use Mosquitto MQTT server found at http://test.mosquitto.org
I used the MQTT component from Embarcadero tech partner TMS Software to handle the actual technicalities of communicating using the MQTT publish and subscribe protocol. It made it easy and in only a few lines of code I was receiving messages from the IoT device and making it beep every time I pressed the button on the M5Stick. Simple, really. As always, Delphi makes IoT Windows development easy.
Watch the whole IoT Windows development video between Serge and Ian Barker
The whole IoT video can be found here. Ignore the “Baker” on the thumbnail – Serge gets my last name right but throughout my life people seem to want to call me “Baker” instead of “Barker”, they even got it wrong on my marriage license, luckily, we spotted it before my wife accidentally became Mrs Baker instead of Mrs Barker!
Further reading on IoT Windows development
- Articles on the Embarcadero Blog
- Articles about IoT and Internet of things on the LearnDelphi.org blog
- More from me on STOMP which is a similar IoT protocol to MQTT
- Visuino from Embarcadero Tech Partner Boian Mitov is a visual IDE way to program the IoT devices which is often a lot easier to use than the Arduino IDE.
Download a copy of Delphi today and try out your own IoT Windows development.