Integrating IoT devices is an age-old problem which requires knowledge of the device, IoT platform, programming language, network and application. Just imagine if your generative AI assistant could take all the pain away and produce code to integrate any device on command. That would be the ultimate low code approach and worth trying, right? So, are generative AIs such as ChatGPT a cure for all device integration?
Yes and no!
The humblest of origins
Before I explain the details, let me take you back to how my investigation started.
With an increasing amount of value being delivered at the edge, I wanted to experiment with the thinnest edge I could cost efficiently build to validate a hypothesis that low-cost solutions can deliver non-linear business value.
The Raspberry Pi Pico W is an amazing single board computer based on the RP2040 microcontroller with dual-core ARM Cortex M0+ processor, multi-function GPIO pins and WiFi connectivity. Having low power consumption and a MicroPython development environment, it's the perfect ultra-low cost IoT experimentation tool. And being so accessible, there are many tutorials and code examples available.
Now for the server side of the connection. Cumulocity IoT is an industrial IoT platform with open REST, MQTT and LWM2M APIs and many device agents, including a MQTT client written in Python. But as MicroPython is not typically considered suitable for implementation in critical process scenarios using microcontrollers, there is currently no specific MicroPython client example.
AI-powered universal adapter
So, could we use Chat GPT to augment the pre-existing examples to fill the gap?
“Write a micropython programme to send measurements to and receive operations from Cumulocity via MQTT"
ChatGPT created perfectly formed MicroPython code with the following comment:
"This code connects to a Wi-Fi network, initializes an MQTT client with the specified credentials, and connects to the MQTT broker. It then sends a temperature measurement in JSON format to the s/us topic and listens for operations on the s/ds topic. The operations_callback function is called whenever an operation is received, and it currently just prints the received message. You can modify this function to perform the desired operation."
The code created moved the device integration activity rapidly from nothing to something, but unfortunately it didn't work.
It had correctly incorporated the subtle differences between MicroPython and Python, especially around the MQTT client libraries, had augmented the Wi-Fi client examples into the MQTT client, and recognized how to publish measurements to Cumulocity IoT. However, a couple of significant errors were incorporated which required a reasonable level of competence to solve.
Firstly, the ChatGPT code missed the device registration step, and secondly it didn’t use the correct MQTT message format. Once these were corrected, there was truly a moment to rejoice in the power of AI, which enabled a working device client to be created in an extremely rapid time. And by rapid, I mean less than an hour for a non-expert.
Confirming Kasparov
This then brings me back to the original question. Like with the Kasparov experiments with early AI, ChatGPT had done a lot of foundation activities that a reasonably competent developer could enhance and finalize quickly. Leveraging the power of reasonable AI and the skills of the reasonable human. However, a challenge is created if the initial output from ChatGPT is anticipated to be 100% accurate, and then attempted to be implemented by someone without competence in the domain.
The advancements of generative AI are moving at a rapid pace, and even with the inaccuracies mentioned, it has massively simplified device integration for a reasonably competent developer, like me. And with the training getting better with time and usage, it’s accuracy will improve to be able to satisfy the needs of those with less time or desire to get into the code.
So, no, ChatGPT is not currently a cure all for device integration, but I am definitely a fan watching with bated breath as it evolves.