I've previously posted about small SAMD21 modules that I've found useful for small standalone projects - SAMD21 Mini Modules .
I also frequently have the need for small modules that have WiFi or Bluetooth connectivity. I've tended to use ESP8266 boards for this purpose because they are reasonably inexpensive and easy to use. I became interested in the M5Stick modules made by M5Stack after I saw one used by kk99 in the Photonics competition back in March - Simple light flicker meter .
The unit that he used isn't offered anymore since it is EOL, but M5Stack has a couple of newer versions - the M5StckC and M5StickC Plus. All the units use the ESP32 processor and include a small display and built-in LiPo battery.
I made a spreadsheet of the differences in the models.
The newer models use smaller higher resolution TFT displays rather than the OLED on the original version. They also offer somewhat larger batteries and different sensors - like a PDM microphone and RTC.
I'm working on a project that needs multiple remote temperature sensors for HVAC tuning, so it seemed like these modules would be a good fit. I think that they should also work well for TinyML applications.
The M5StickC units also can use a variety of "Hats" that plug into the top of the unit to provide additional sensor capability (this is in addition to the Grove port at the bottom of the unit). M5Stack offers an Environment Hat with Temperature, Humidity, and Pressure sensors - https://docs.m5stack.com/#/en/hat/hat_envII that I thought would be just what I needed for my project (uses SHT30, BMP280 and BMM150 sensors).
I started out with the M5StickC - the kit that I got included a Speaker Hat, ENV II Hat, and some mounting accessories (including a wrist strap) https://m5stack.com/collections/m5-core/products/m5stickc-development-kit-with-hat?variant=17348918935642 .
Here's a real short video showing the M5StickC running on battery and using the LCD display and Speaker Hat.
I next set up to run with the ENV II Hat as it would in my application. There are actually 2 temperature sensors in the hat, so I decide to log them both (the SHT30 is supposedly more accurate than the BMP280). I am publishing MQTT data to Adafruit IO.
M5Stick_AdafruitIO_MQTT.ino
/** * M5Stick_AdafruitIO_MQTT.ino * * Created on: 12.18.2020 * */ #include <Arduino.h> #include <WiFi.h> #include <WiFiMulti.h> #include <WiFiClient.h> #include <M5StickC.h> #include "SHT3X.h" #include <Wire.h> #include "Adafruit_Sensor.h" #include <Adafruit_BMP280.h> #include "Adafruit_MQTT.h" #include "Adafruit_MQTT_Client.h" #define AIO_SERVER "io.adafruit.com" #define AIO_SERVERPORT 1883 // use 8883 for SSL #define AIO_USERNAME "aaaaa" #define AIO_KEY "bbbbbccccc" #define USE_SERIAL Serial WiFiClient client; WiFiMulti wifiMulti; SHT3X sht3x; Adafruit_BMP280 bme; float temp1 = 0.0; float temp2 = 0.0; // Setup the MQTT client class by passing in the WiFi client and MQTT server and login details. Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY); // Setup a feed called 'temperature' for publishing // Notice MQTT paths for AIO follow the form: <username>/feeds/<feedname> Adafruit_MQTT_Publish tempSHT = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/tempSHT"); Adafruit_MQTT_Publish tempBMP = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/tempBMP"); void MQTT_connect(); void setup() { M5.begin(); Wire.begin(0,26); M5.Lcd.setRotation(3); M5.Lcd.fillScreen(BLACK); M5.Lcd.setCursor(5, 5, 2); M5.Lcd.println("TEMPERATURE TEST"); pinMode(M5_BUTTON_HOME, INPUT); if (!bme.begin(0x76)){ Serial.println("Could not find a valid BMP280 sensor, check wiring!"); while (1); } USE_SERIAL.begin(115200); USE_SERIAL.println(); USE_SERIAL.println(); USE_SERIAL.println(); for(uint8_t t = 4; t > 0; t--) { USE_SERIAL.printf("[SETUP] WAIT %d...\n", t); USE_SERIAL.flush(); delay(1000); } wifiMulti.addAP("xxxxx", "yyyyyzzzzz"); // wait for WiFi connection if((wifiMulti.run() == WL_CONNECTED)) { MQTT_connect(); } } void loop() { // Ensure the connection to the MQTT server is alive (this will make the first // connection and automatically reconnect when disconnected). See the MQTT_connect // function definition further below. MQTT_connect(); if(sht3x.get()==0){ temp1 = sht3x.fTemp; // fTemp for Fahrenheit or cTemp for Celsius } M5.Lcd.setCursor(5, 30, 2); M5.Lcd.printf("TempSHT: %2.1f F", temp1); temp2 = bme.readTemperature()*1.8 + 32; M5.Lcd.setCursor(5, 50, 2); M5.Lcd.printf("TempBMP: %2.1f F", temp2); delay(100); if (!tempSHT.publish(temp1)) { //publish sensor data Serial.println(F("Failed")); } else { Serial.println(F("tempSHT sent!")); } if (!tempBMP.publish(temp2)) { Serial.println(F("Failed")); } else { Serial.println(F("tempBMP sent!")); } delay(5000); } void MQTT_connect() { int8_t ret; // Stop if already connected. if (mqtt.connected()) { return; } Serial.print("Connecting to MQTT… "); uint8_t retries = 3; while ((ret = mqtt.connect()) != 0) { // connect will return 0 for connected Serial.println(mqtt.connectErrorString(ret)); Serial.println("Retrying MQTT connection in 5 seconds…"); mqtt.disconnect(); delay(5000); // wait 5 seconds retries--; if (retries == 0) { // basically die and wait for WDT to reset me while (1); } } Serial.println("MQTT Connected!"); }
I was surprised by the temperature data because both sensors were reading about 10 degrees F too high.
I was also somewhat surprised by the long settle time (~20 minutes) and the difference between the 2 sensors (>2 degrees F).
I somewhat suspected that PCB in the hat was getting heat from the M5StickC module, so I tried adding 8 inches of wire between the module and the hat.
And here are the measurements:
So, around an 8 degree F delta between the two cases and the difference between sensors is <0.5 degrees F in the extended case. The extended data is much closer to what I would have expected.
Apparently, I won't be able to run with the hat directly attached. Quite disappointing.
Otherwise, I'm happy with the convenience of the M5StickC. I know that the battery is too small to run for an extended period, but it should be sufficient for my application - if not I'll add an external power pack.
I'll probably use M5StickC Plus modules and individual SHT30 sensors. I'll need to experiment with how much distance I need between the module and the sensor.
Top Comments