This repository contains ThingWorx and Lego SPIKE Prime code that allows the SPIKE to be trained using the analytics server extension on ThingWorx.
A simple ball launcher was built and trained using linear regression to better understand how to integrate ThingWorx with SPIKE Prime. Then, more complex methods of training (eg. neural networks, gradient boosts, random forests, etc.) were explored using the SPIKE Prime puppy system, with a MQTT protocol acting as the main communication method between SPIKE and ThingWorx Analytics.
To the right is a flowchart of the general training process. Although the SPIKE Puppy is featured, the process is applicable to any SPIKE system.
- ThingWorx instance with the following:
- Analytics Server Extension
- CSV Parser Extension
- MQTT Extension
- SPIKE Prime Kit
- ESP8266 wifi dongle
- Click here to get more info
- MQTTX- a cloud based broker app used as a bridge between SPIKE and ThingWorx
- I have not explored other MQTT broker software, but hear that Mosquitto is reputable
- LabView IDE (created by Chris Rogers)
In addition to the setup provided here, each folder will contain files detailing setups specific to the systems used. Here is a link to a Google Drive with all of the linked resources and more!
The Ball Launcher code was hosted on Google Colab, and the SPIKE Puppy code is both local & through MQTT.
The LabView IDE was used in order to code MicroPython onto the SPIKE Prime and ESP8266 either through micro USB communication (applicable for both) or bluetooth communication (only applicable for the SPIKE).
You can download the IDE from this repository here, and it is compatible with any version of LabView, including the Community Version.
The ESP8266 is a microcontroller that is cost-effective and a highly integratable Wi-Fi MCU for IoT applications. Since the Lego SPIKE Prime kit does not come with WiFi capabilities, the ESP8266 was created as a "backpack" for the SPIKE Prime. A cable was soldered to the TX, RX, Ground, and VCC pins of the ESP and can be connected to the respective RX, TX, Ground, and VCC pins of the SPIKE Prime through one of the ports. This allows the SPIKE and ESP to communicate via UART serial communication. Micropython was flashed onto the ESP and there are two versions of the dongle based on what type of communcation is used (API calls vs. MQTT).
Please follow all instructions on this website for setup. The files referenced are located in the ESP8266 folder on this repository.
Please follow up to step "III. Install the MicroPython firmware onto the ESP8266" on this website. Then follow instructions listed in the ESP8266 folder on this repository.
Follow this PDF to create an API Key.
Click this link to watch a demo of training the SPIKE Puppy to sit and stand based on ultrasonic sensor distance, communicating all through a MQTT protocol.