

#DEFINE ANOMALY CODE#
Remember to change BLYNK_TEMPLATE_ID and BLYNK_DEVICE_NAME to the ones from you Device template.Īfter you upload the code to Wio Terminal, it will create a hot spot, which you can connect to with your phone. The class ID of the class with highest confidence (if the confidence is above set threshold) is saved inside best_result global variable and together with light and sound sensors data is being sent to Blynk server at periodic intervals. In the main sketch file, the data collection/data processing/inference code we used for testing with LCD screen was moved to run_inference() function.
#DEFINE ANOMALY DOWNLOAD#
Download the example sketch from Seeed Wio Terminal example sketches repository – besides main sketch file it also contains helper files, where Wi-Fi manager code is located. Now the web interface is ready to receive the data from our device.

Overall, it’s very similar to Virtual Pins (which can be used too).

We compile and download the Arduino library, extract it to Arduino libraries folder and then modify nano33_ble_sense_accelerometer sketch to match the accelerometer we have in Wio Terminal. Before fixing firmly, Wio Terminal was wobbling randomly, which was introducing too much noise into normal operation samples.Īfter the model is trained and tested using Live classification mode it is time to deploy it back to the device. One thing that helped to increase the accuracy was fixing Wio Terminal on the water pump firmly with glue – for actual device you can use screws.
#DEFINE ANOMALY TRIAL#
If the distance from a cluster is too large the sample is flagged the sample as an anomaly.Īfter trial and error I found that very low cluster count and distance threshold of 0.5 works the best for anomaly detection, but this is very case-specific and depends on your data.

We can use this to our advantage by training a new (second) network that creates clusters around data that we have seen before, and compares incoming data against these clusters.
