BLE Smart Thermal Flask by M5Stack
by AkarshA2 in Circuits > Arduino
22 Views, 0 Favorites, 0 Comments
BLE Smart Thermal Flask by M5Stack
Hey, what's up, Guys! Akarsh here from CETech.
In this tutorial, I'm going to show you how to transfer the sensor readings between two ESP32 Boards via Bluetooth protocol. We will be making a Thermal Flask that senses the inside temperature and sends the information to a receiver via Bluetooth. For this purpose, we will be using an M5Stick C module and an M5Stamp Pico module. The M5Stamp Pico will be programmed as a Transmitter and will be connected to our flask to send the data. On the other hand, M5Stick C will be used as the receiver to collect the data transmitted by the Transmitter. For measuring the temperature, We will use an LM35 Temperature Sensor. The Sensor will be interfaced with the M5Stamp Pico module. The sensor will sense the data and forward it to the M5Stamp module and the module will transmit the temperature data to the M5Stamp C module on the receiver end. We will integrate the transmitter part into our flask containing water or any other liquid and this will help us get the inside temperature of the flask on our receiver with the help of which we can decide if the water in the flask needs to be reheated or it's fine to drink.
It is a simple yet fun and useful project for our daily life. So let's look at this in detail.
Supplies
Things that you need:
- M5Stick C
- M5Stamp Pico
- LM35 Temperature Sensor
Get PCBs for Your Projects Manufactured
You must check out PCBWAY for ordering PCBs online for cheap!
You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop.
What Are M5Stick and M5Stamp?
M5Stick C:
M5StickC is a mini M5Stack, powered by ESP32. It is a portable, easy-to-use, open-source, IoT development board. What it can do? This tiny block is able to realize your idea, enlighten your creativity, and help with your IoT prototyping in a very short time. It will take away a lot of pains from the development process.M5stickC is one of the core devices in the M5Stack product series.
It is built in a continually growing hardware and software ecosystem. It has a lot of compatible modules and units, as well as the open-source code & engineering communities that will help you maximize your benefits in every step of the developing process.
-------------------------------------------->Buy Link<----------------------------------------------------
Power switch operation:
- Power on: Press the power button for 2 seconds
- Power off: Press the power button for 6 seconds
Notice: Baud rate supported by M5StickC: 1200 ~115200, 250K, 500K, 750K, 1500K
Product Features:
- ESP32-based
- Built-in 6-Axis IMU
- Red LED
- IR transmitter
- MicrophoneButtons, LCD(0.96 inch)
- Built-in Lipo Battery
- Extendable Socket
- Wearable & Wall-mounted
Compatible with multi-platform development:
- UIFlow
- MicroPython
- Arduino
- .NET
- nanoFramework
M5Stamp Pico:
STAMP-PICO features an ultra-compact design with two low-power Xtensa® 32-bit LX6 microprocessors at 240MHz on a PCB as tiny and delicate as a postage stamp. low power consumption. It is ideal for any space-constrained or battery-powered devices such as wearables, medical devices, sensors, and other IoT devices.
1, MULTIFORM: 5 options of installation, means endless possibilities! (SMT, DIP, flywire, grove interface), with a high-temperature resistant plastic shell, 3D antenna and components can be better protected.
2, LOW-CODE DEVELOPMENT: STAMP-PICO supports UIFlow graphical programming platform, scripting-free, cloud push; and fully compatible with Arduino, MicroPython, ESP32-IDF, and other mainstream development platforms to quickly build various applications.
3, HIGH INTEGRATION: STAMP-PICO contains a 5V->3.3V DC/DC port, GPIOx12, programmable RGB light x1, button x1, finely tuned RF circuit, providing stable and reliable wireless communication.
4, STRONG EXPANDABILITY: Easy access to M5Stack's hardware and software ecology system: a wealth of sensors, actuators, functional modules, and accessories to choose from, and extremely fast adaptation.
-------------------------------------------->Buy Link<--------------------------------------------
Product Features:
- Chip-set: ESP32-PICO-D4 (2.4GHz Wi-Fi dual-mode)
- Support UIFlow graphical programming
- Multi-IO pinout, support multiple application forms (SMT, DIP, fly-by-wire)
- Integrated programmable RGB LEDs and buttonsMiniature module
Connecting LM35 Sensor With M5Stamp Pico
The LM35 is an integrated analog temperature sensor whose output is proportional to degrees centigrade. Sensors such as the LM35 do not require external calibration or trimming to provide typical accuracy. LM35's low output impedance, a linear output, and accurate inherent calibration make it especially easy to interface with readouts and control circuits.
Now, we know a little bit about the Sensor and other modules. Now we will connect the Sensor with the module M5Stamp Pico module. The steps for that are as given below:-
Connect the LM35's output pin to M5Stamp's 36th pin and LM35's power to 5 V and GND to GND of the PICO.
- VOUT -> G36
- GND -> GND
- VCC -> 5V
This will complete our hardware setup for the project. Now we need to program our modules which we will do in the next step.
Programming the Modules
As we are done with the Hardware connections now we are left only with programming the modules as Transmitter and Receiver. We will program the M5Stamp Pico as Transmitter and M5Stick C as Receiver. The codes that are needed to be uploaded are available in the Github repository of the project that can be accessed from here.
Programming the Transmitter:
As we are programming the M5Stamp pico as the transmitter, we will upload the "Transmitter.ino" code from the Github repository to the M5Stamp module. But before uploading, we need to take care of some things which are mentioned below:
In the code, there is a line which is: #define bleServerName "M5". You can update your server name in this line accordingly.
The lines that are mentioned below are the calibration readings of the LM35 Sensor. You do not need to change those lines. Leave them in the code as they are
#define ADC_VREF_mV 3300.0 // in millivolt
#define ADC_RESOLUTION 4096.0
#define PIN_LM35 36 // ESP32 pin GIOP36 (ADC0) connected to LM35
The below-mentioned line of the code states the Service ID of the Transmitter:
#define SERVICE_UUID "91bad492-b950-4226-aa2b-4ede9fa42f59"
Then there is the Service ID for the Temperature data:
BLECharacteristic bmeTemperatureCelsiusCharacteristics("cba1d466-344c-4be3-ab3f-189f80dd7518", BLECharacteristic::PROPERTY_NOTIFY);BLEDescriptor bmeTemperatureCelsiusDescriptor(BLEUUID((uint16_t)0x2902));
As there is no reset button, I have used a user-defined function for the same purpose:
static bool State;
State = digitalRead(Button);
if (State == 0) {
ESP.restart();
}
The details mentioned are just to give a brief description of the fields in the code. If required, you can make changes in these according to your data.
Programming the Receiver:
As we are programming the M5Stick C as the receiver, we will upload the "Receiver.ino" code from the Github repository to the M5Stick module.
In this code, rename the transmitter name the same as yours, and make sure the device service ID and Temperature Data ID match with the transmitter by checking the below-mentioned fields:
#define bleServerName "M5"
BLE Service static BLEUUID bmeServiceUUID("91bad492-b950-4226-aa2b-4ede9fa42f59");
static BLEUUID temperatureCharacteristicUUID("cba1d466-344c-4be3-ab3f-189f80dd7518");
The below mentioned lines of the code are to display the temperature data on the TFT Screen of the module:
M5.Lcd.setTextColor(RED);
M5.Lcd.setCursor(20, 18);
M5.Lcd.setTextSize(1.8);
M5.Lcd.print("[ ");
M5.Lcd.setTextColor(GREEN);
M5.Lcd.print("BLE Smart Flask");
M5.Lcd.setTextColor(RED);
M5.Lcd.print(" ]");
M5.Lcd.setCursor(18, 40);
M5.Lcd.setTextColor(GREEN);
Serial.print("Temperature:");
M5.Lcd.print("Temperature: ");
Serial.println(temperatureChar);
M5.Lcd.print(temperatureChar); M5.Lcd.print(" C");
Once done with the required changes, now we are ready to upload the code to our Receiver module. And once the code is uploaded, our project is ready to be tested.
Testing the Project
As we are done with the Hardware Setup and Programming part of the project. The only thing that we are left with is to test the Project. For that, you need to connect the Transmitter to the Computer. Open the Arduino IDE Serial Monitor and press the Reset button on both the Transmitter and Receiver. After approx. 10 seconds after doing this, you will observe that the data will start to pour in. The Same data of the Transmitter will be available on the Serial Monitor and on the TFT Screen of the Receiver. This shows that the connection is established successfully.
Now on to the highlight of the project i.e the Flask. For that, you should fix the Temperature Sensor safely into the lid of the Flask and paste the Transmitter module outside the Flask. You can power the module using a power bank for this time but for a permanent setup, you can connect a LiPo battery to the setup. But take care that the modules do not get in contact with water. After this, you need to close the lid of the flask and you will see that the temperature readings are received every 10 seconds. This will mark the end of the project. Hope you liked the project. We will be back soon with some more interesting projects.