FireBeetle 2 ESP32 S3 WROOM-1 getting started tutorial
Table of Contents
FireBeetle 2 ESP32-S3:
FireBeetle 2 ESP32 S3 WROOM-1 getting started tutorial- The DFRobot FireBeetle 2 ESP32 board has made things quite easy. If you compare it with the previous versions of ESP32 boards, you will get an idea of how advanced it is.
Its use is exactly the same; all the projects that I have made using the previous pervious of the ESP32 boards can also be run on this one. You just need to pay attention to the pins because the pinout of the ESP32 FireBeetle 2 is different from the previous boards.
Anyway, I will share some examples with you, so that you can easily get started with this remarkable piece of hardware. The examples will include,
- How to control the onboard LED.
- How to make an IoT-based two-way communication system using the New Blynk V2.0. We will control an LED and monitor a Potentiometer as well.
- We will explore live video streaming.
- I will explain how to use a TFT LCD. And lastly,
- We will build an intermediate-level temperature monitoring system using the MLX90614 non-contact infrared temperature sensor.
Guys we have to cover a lot of things; so, without any further delay, let’s get started!!!
Amazon Links:
FireBeetle 2 Official Product page
MLX90614 non-contact infrared temperature sensor
*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.
FireBeetle 2 ESP32 S3:
Board Overview:
The new ESP32 FireBeetle 2 is based on the ESP32-S3 WROOM-1, generic Wi-Fi + Bluetooth Low Energy Microcontroller module that is built around the ESP32 S3 series of SoCs. On top of rich set of peripherals, the acceleration for neural network computing and signal processing workloads provided by the SoC make the Modules an ideal choice for a wide variety of application scenarios related to AI and AIoT “Artificial Intelligence of Things”, such as wake word detection, speech commands recognition, face detection and recognition, smart home, smart appliances, smart control panel, smart speaker, etc.
The board has Type-C USB port.
It has an Onboard LED.
If you long press the button connected to 47/D14 for 6 seconds it will power off the board, and if you press it for 2 seconds it will power on the board.
It has the Reset and Boot buttons.
The board has the AXP313A Power Management chip and the ETA6003 Lithium-ion Battery Charging Management Chip.
The board also has Lithium-Ion battery port.
It is also provided with a charging indicator LED. If this LED is OFF it means either the Power supply is not plugged in or the battery is fully charged. And if this LED is ON then it means the battery is charging. And if this LED is blinking then it means the battery is not connected.
It has the GDI “Graphics Device interface”.
The term “GDI display interface” typically refers to the Graphics Device Interface, which is a Microsoft Windows technology used for rendering graphical elements on the screen. GDI is a core component of the Windows operating system and provides a set of functions and tools for drawing text, graphics, and images on the screen or in a window.
The GDI display interface allows applications to create and manipulate graphical objects, such as lines, shapes, and text, and then render them on the screen. It provides a high-level abstraction for working with graphics and is often used by applications like desktop programs, games, and graphical user interfaces (GUIs).
While GDI has been a fundamental part of Windows graphics for a long time, more recent versions of Windows have introduced newer graphics APIs like Direct2D and Direct3D, which offer more advanced features and better performance for graphics-intensive applications. However, GDI is still widely used for basic graphics rendering and remains an important component of the Windows graphics subsystem.
It also has the DVP “Digital Video Port” Camera Interface.
DVP camera interface, also known as Digital Video Port camera interface, is a standard interface used to connect digital cameras to various electronic devices, such as microcontrollers, single-board computers, and embedded systems. It’s a parallel interface that allows for the transmission of digital image data between the camera and the host device.
Key features of a DVP camera interface include:
Parallel Data Transmission: Unlike serial interfaces like SPI or I2C, DVP interfaces transmit data in parallel, which means multiple bits are transferred simultaneously, making it suitable for high-speed data transfer.
High-Speed Data Transfer: DVP interfaces are designed for high-speed data transmission, making them suitable for capturing high-resolution images and videos.
Dedicated Pins: DVP interfaces typically use a set of dedicated pins for transmitting image data, control signals, and clock signals. These pins are organized into data buses and control lines.
Standardized Connectors: DVP cameras often use standardized connectors, making it easier to interface with various devices that support the same interface standard.
Image Format Support: DVP interfaces can support various image formats, such as RAW or YUV, depending on the camera and host device’s capabilities.
Widely Used in Embedded Systems: DVP camera interfaces are commonly found in embedded systems, robotics, industrial automation, and other applications where capturing images or video is required.
FireBeetle 2 ESP32-S3 Specification:
Basic Parameters
- Operating Voltage: 3.3V
- Type-C Input Voltage: 5V DC
- VCC Input Voltage: 5V DC
- Max Charging Current: 1A
- Operating Temperature: -20 to 70℃
- Dimension: 25.4x60mm/1×2.36”
Hardware Information
- Processor: Xtensa® dual-core 32-bit LX7 microprocessor
- Main Frequency: 240 MHz
- SRAM: 512KB
- ROM: 384KB
- Flash: 16MB
- PSRAM: 8MB
- RTC SRAM: 16KB
- USB: USB 2.0 OTG full-speed
WIFI
- WIFI Protocol: IEEE 802.11b/g/n
- Bandwidth: Support 20 MHz and 40 MHz at 2.4 GHz band
- WIFI Mode: Station, SoftAP, SoftAP+Station combined mode
- WIFI Frequency: 2.4GHz
- Frame Aggregation: TX/RX A-MPDU, TX/RX A-MSDU
Bluetooth
- • Bluetooth Protocol: Bluetooth 5, Bluetooth mesh
- • Bluetooth Frequency: 125 Kbps, 500 Kbps, 1 Mbps, 2 Mbps
Ports
- Digital I/O x26
- LED PWM Controller 8 Channels
- SPI x4
- UART x3
- I2C x2
- I2S x2
- IR Transceiver: transmit channel x5, receive channel x5
- 2×12-bit SAR ADC, 20 Channels
- DMA Controller: transmit channel x5, receive channel x5
Pinout Diagram:
You can follow this Pin Diagram and I think there is no need to waste time by explaining all these pins; because all the pins are clearly labeled.
Now, let’s start with our first example that is blinking the Onboard LED that is connected to the Digital pin13 just like the Arduino. Anyway, to control the onboard LED for this, first of all, we will need to add the ESP32 FireBeetle 2 in the Arduino IDE. Because, by default no ESP32 board is installed in the Arduino IDE and you can confirm this by going to the Tools Menu, then to Board, and you can see there is no ESP32 board.
So, first we will need to add it in the boards list, for this copy this Board Manager URL link;
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Then go back to the Arduino IDE, go to the File Menu, then preferences, and paste this link in the Additional Boards Manager URLs and click the Ok button.
Next, go to the Tools Menu, then Board and click on the Boards Manager. Search for the ESP32. You can see we have Arduino ESP32 Boards and ESP32 by Espressif Systems.
So, make sure you install this one and don’t forget to select the latest version. Finally, the board installation has been completed and now we can confirm this by going to the boards list.
You can see all the different variants of the ESP32 Boards have been added, so, scroll down and you will see the DFrobot FireBeetle ESP32 S3 board. We are done with the difficult part, and now let’s open the LED blinking program.
FireBeetle 2 ESP32-S3 Led Blinking Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
/* * FireBeetle ESP32-S3 WROOM 1 * Led Blinking Code * https://www.electroniclinic.com/ */ int Onboard_Led = D13; void setup() { // put your setup code here, to run once: pinMode(Onboard_Led, OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(Onboard_Led, HIGH); delay(1000); digitalWrite(Onboard_Led, LOW); delay(1000); } |
This is the same exact program used to control the Arduino Uno or Arduino Nano onboard LED. The purpose of this program is to turn ON and turn OFF the onboard LED. If you are new to the Arduino IDE then I highly recommend watch my 1 hour video on the Arduino course.
Anyway, to upload the program, make sure your ESP32 FireBeetle 2 board is connected to your Laptop or PC.
Go to the Tools menu and select the DFRobot FireBeetle 2 ESP32-S3 Board. Make sure you enable the USB CDC On Boot.
Set the Flash size to 16MB (128Mb).
Set the Partition Scheme to 16M Flash (3MB).
Set the PSRAM to OPI PSRAM.
Finally, select the port and then you can upload the program.
Now, you can see; the onboard LED is blinking. Exactly the same way, you can control any IO pin.
FireBeetle 2 ESP32 with New Blynk:
Now, in this next example, we are going to control and LED and monitor a Potentiometer using the New Blynk V2.0. First, let me explain the connections.
The rightmost and leftmost legs of the Potentiometer are connected to the FireBeetle board pins 3.3V and GND. Whereas the middle leg of the potentiometer is connected to the Analog pin A0.
Cathode Leg of the LED is connected to the GND pin and the Anode leg of the LED is connected to the digital pin D12 through this 330 ohm current limiting resistor. 330-ohm resistor I usually use when I use 5 volts compatible controller boards like Arduino. But since this is a 3.3V compatible controller board, so technically you will need a resistor of 40 ohms. But, to be on the safe side, you can use a resistor of 100 ohms. But right now, I have a 330-ohm resistor and that’s why I used it and I know its going to reduce the LED brightness.
Now, before we start setting up the Blynk Cloud dashboard or the Blynk IoT App for controlling the LED and for monitoring the Potentiometer. First, we will need to install the Blynk Library in the Arduino IDE. So, let’s do it.
While the Arduino IDE is open. Go to the Sketch Menu, then to Include Library, and click on the Manage Libraries. Search for the Blynk;
And make sure you install the Blynk by this guy(Volodymyr Shymanskyy) and don’t forget to select the latest version. Anyway, you can see, I have already installed it. So, once you are done with the Blynk library installation then you can start working on the Blynk Cloud dashboard.
Altium Designer, Altium 365, & Octopart:
Altium Designer is the world’s most trusted PCB design system. Altium Designer enables engineers to effortlessly connect with every facet of the electronics design process. Over 35 years of innovation and development focused on a truly unified design environment makes it the most widely used PCB design solution. With Altium Designer you can create PCB designs with an intuitive and powerful interface that connects you to every aspect of the electronics design process. Route it your way through any angle, tune for the delay, Push, Slide, and Walkaround faster than ever.
Easily work together with your mechanical team and forget about the days of swapping design files. Every design change stays in sync between Altium Designer and SOLIDWORKS, PTC Creo, Autodesk Inventor, Autodesk Fusion 360, or Siemens NX*.
Interact and collaborate with mechanical designers like never before in a photo-realistic, 3D design environment.
One of the best things about Altium Designer is that you can share your designs with your team members using Altium 365. They can check your design, leave comments, and if there are any issues, they can fix them from anywhere in the world. Altium Designer also uses the world’s fastest components search engine, Octopart, so you won’t have any difficulty in searching for components.
Altium Designer, Altium 365, and Octopart—unleashes the full potential of electronics design by seamlessly integrating design tools, collaboration platforms, and component databases. Together, they offer engineers a comprehensive and synchronized experience, leading to improved productivity, reduced errors, and accelerated innovation in the world of electronics design.
FireBeetle 2 Blynk Web Dashboard Setup:
Click on the new template
Write the name, select ESP32 as the hardware type, set the connection type to WiFi, and you can also write some description. Finally, click on the Done button.
Select Datastreams
Add the New DataStream for the digital pin to control the led
Then add the required credentials for the digital pin and select the pin 12 and click on the create button.
Then again click on the New Datastream and this time click on the virtual pin.
Then add the required credentials and click on create button
Then click on the web Dashboard
Double click on the switch to add it to the Dashboard, or simply drag and drop it.
Click on the setting and choose the required data stream and click on the save
Then double click on the gauge.
Click on the setting and choose the required datastream and click on the save
Then click on the save button
Now click on the search button
Then click on the New device and click on choose From template
Then under the choose template select Firebeetle esp32 with Blynk and click on the create Button.
Then copy the credentials,
1 2 3 |
#define BLYNK_TEMPLATE_ID #define BLYNK_TEMPLATE_NAME #define BLYNK_AUTH_TOKEN |
Paste the credentials in the programming and upload the code to the ESP32
Firebeetle 2 ESP32 and Blynk Programming:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#define BLYNK_TEMPLATE_ID "TMPL6MpBUCnlg" #define BLYNK_TEMPLATE_NAME "firebeetle esp32 with Blynk" #define BLYNK_AUTH_TOKEN "hqgXbe5meWfWe43aeYi5zNwbeKNZQQG3" #include <WiFi.h> #include <WiFiClient.h> #include <BlynkSimpleEsp32.h> // Comment this out to disable prints and save space #define BLYNK_PRINT Serial char auth[] = BLYNK_AUTH_TOKEN; // Your WiFi credentials. // Set password to "" for open networks. char ssid[] = "AndroidAP3DEC"; char pass[] = "electroniclinic"; int ledpin = 2; int pot=A0; void setup() { // Set up serial monitor Serial.begin(115200); pinMode(ledpin,OUTPUT); pinMode(pot,INPUT); digitalWrite(ledpin,LOW); Blynk.begin(auth, ssid, pass); } void loop() { int potvalue=analogRead(pot); Serial.println(potvalue); Blynk.run(); Blynk.virtualWrite(V0,potvalue); delay(1000); } |
After uploading the program, make sure you laptop and Firebeetle 2 ESP32 board are connected to the WiFi. Then go back to your Blynk Web Dashboard, and you should be able to control the LED and monitor the Potentiometer. On my side both the LED and Potentiometer were working. As you can see in the image below.
FireBeetle 2 ESP32 Blynk IoT App setup:
Open the Blynk IoT application on your cell phone and click on firebeetle esp32 with Blynk.
Then click on the developer mode
Then click on the add button
Select the gauge
Now click on the datastream
Select the required datastream for the gauge
And click on the close button
Repeat the same steps for the button
Then click on the button to add the datastream
Select the required datastream
Now the gauge and buttons are added
Now, I can use this App to control the Led and for monitoring the Potentiometer.
Practical Demonstration:
I was able to monitor the Potentiometer and I also successfully controlled the LED.
You can replace this LED with a relay to control high voltage and high ampere AC/DC loads and the same thing applies to the potentiometer; you can replace it with any other analog or digital sensor. The Blynk web dashboard and the Blynk IoT app setup will remain exactly the same. For the better understanding you can go ahead and read my other articles on the ESP32 and New Blynk V2.0.
Now, let’s go ahead and start with the Camera.
FireBeetle 2 ESP32 S3 and Camera:
The CAM interface is compatible with both OV2640 and OV7725 cameras. Enable AXP313A power output when using a camera.
This is the pin list for using the DVP camera interface.
CAM PINS | FireBeetle ESP32-S3 PINS | Description |
NC | NC | NC |
AGND | / | Analog GND |
SDA | 1/SDA | I2C data |
AVDD | / | AXP313A Controllable Power |
SCL | 2/SCL | I2C Clock |
RST | / | Pulled up to DOVDD |
VSYNC | 6/A2 | Frame sync signal |
PWDN | / | Pulled down |
HREF | 42 | Horizontal sync signal |
DVDD | / | AXP313A Controllable Power |
DOVDD | / | AXP313A Controllable Power |
D9 | 48 | DATA 9 |
XMCLK | 45 | Clock signal |
D8 | 46 | DATA 8 |
DGND | GND | Digital GND |
D7 | 8/A3 | DATA 7 |
PCLK | 5/A1 | Pixel Clock signal |
D6 | 7/D5 | DATA 6 |
D2 | 39 | DATA 2 |
D5 | 4/A0 | DATA 5 |
D3 | 40 | DATA 3 |
D4 | 41 | DATA 4 |
NC | NC | NC |
NC | NC | NC |
This is the OV2640 Camera module that I am going to use with the FireBeetle 2 ESP32 S3 board. On the backside of the FPC “Flexible Printed Cable” you can see the pin numbering starts from the right side and on the FireBeetle board you can find a white dot next to the Camera port which indicates that this is the pin number 1. So while connecting the camera, make sure pin number 1 on the FPC is towards the Dot side.
So, the camera is connected and next we are going to add library in the Arduino IDE. So, while your Arduino IDE is open go to the Sketch Menu, then to Include Library, and click on the Add .ZIP Library.
Browse to the location and select the DFRobot_AXP313A-master.
Download DFRobot_AXP313A-master
Download the project folder, because the folder contains
app_httpd.cpp
camera_index.h
camera_pins.h
And
CameraWebServer
The CameraWebServer program is given below. Make sure, all the above files are in the same folder. When you open the CameraWebServer program; all the other files will automatically load in the Arduino IDE.
FireBeetle 2 ESP32 Live Video Streaming Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
#include "esp_camera.h" #include <WiFi.h> #include "DFRobot_AXP313A.h" // // WARNING!!! PSRAM IC required for UXGA resolution and high JPEG quality // Ensure ESP32 Wrover Module or other board with PSRAM is selected // Partial images will be transmitted if image exceeds buffer size // // You must select partition scheme from the board menu that has at least 3MB APP space. // Face Recognition is DISABLED for ESP32 and ESP32-S2, because it takes up from 15 // seconds to process single frame. Face Detection is ENABLED if PSRAM is enabled as well // =================== // Select camera model // =================== #define PWDN_GPIO_NUM -1 #define RESET_GPIO_NUM -1 #define XCLK_GPIO_NUM 45 #define SIOD_GPIO_NUM 1 #define SIOC_GPIO_NUM 2 #define Y9_GPIO_NUM 48 #define Y8_GPIO_NUM 46 #define Y7_GPIO_NUM 8 #define Y6_GPIO_NUM 7 #define Y5_GPIO_NUM 4 #define Y4_GPIO_NUM 41 #define Y3_GPIO_NUM 40 #define Y2_GPIO_NUM 39 #define VSYNC_GPIO_NUM 6 #define HREF_GPIO_NUM 42 #define PCLK_GPIO_NUM 5 DFRobot_AXP313A axp; // =========================== // Enter your WiFi credentials // =========================== const char* ssid = "AndroidAP3DEC"; const char* password = "electroniclinic"; void startCameraServer(); void setup() { Serial.begin(115200); Serial.setDebugOutput(true); Serial.println(); while(axp.begin() != 0){ Serial.println("init error"); delay(1000); } axp.enableCameraPower(axp.eOV2640);//设置摄像头供电 camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; config.pin_d0 = Y2_GPIO_NUM; config.pin_d1 = Y3_GPIO_NUM; config.pin_d2 = Y4_GPIO_NUM; config.pin_d3 = Y5_GPIO_NUM; config.pin_d4 = Y6_GPIO_NUM; config.pin_d5 = Y7_GPIO_NUM; config.pin_d6 = Y8_GPIO_NUM; config.pin_d7 = Y9_GPIO_NUM; config.pin_xclk = XCLK_GPIO_NUM; config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; config.pin_sscb_sda = SIOD_GPIO_NUM; config.pin_sscb_scl = SIOC_GPIO_NUM; config.pin_pwdn = PWDN_GPIO_NUM; config.pin_reset = RESET_GPIO_NUM; config.xclk_freq_hz = 20000000; config.frame_size = FRAMESIZE_UXGA; config.pixel_format = PIXFORMAT_JPEG; // for streaming //config.pixel_format = PIXFORMAT_RGB565; // for face detection/recognition config.grab_mode = CAMERA_GRAB_WHEN_EMPTY; config.fb_location = CAMERA_FB_IN_PSRAM; config.jpeg_quality = 12; config.fb_count = 1; // if PSRAM IC present, init with UXGA resolution and higher JPEG quality // for larger pre-allocated frame buffer. if(config.pixel_format == PIXFORMAT_JPEG){ if(psramFound()){ config.jpeg_quality = 10; config.fb_count = 2; config.grab_mode = CAMERA_GRAB_LATEST; } else { // Limit the frame size when PSRAM is not available config.frame_size = FRAMESIZE_SVGA; config.fb_location = CAMERA_FB_IN_DRAM; } } else { // Best option for face detection/recognition config.frame_size = FRAMESIZE_240X240; #if CONFIG_IDF_TARGET_ESP32S3 config.fb_count = 2; #endif } #if defined(CAMERA_MODEL_ESP_EYE) pinMode(13, INPUT_PULLUP); pinMode(14, INPUT_PULLUP); #endif // camera init esp_err_t err = esp_camera_init(&config); if (err != ESP_OK) { Serial.printf("Camera init failed with error 0x%x", err); return; } sensor_t * s = esp_camera_sensor_get(); // initial sensors are flipped vertically and colors are a bit saturated if (s->id.PID == OV3660_PID) { s->set_vflip(s, 1); // flip it back s->set_brightness(s, 1); // up the brightness just a bit s->set_saturation(s, -2); // lower the saturation } // drop down frame size for higher initial frame rate if(config.pixel_format == PIXFORMAT_JPEG){ s->set_framesize(s, FRAMESIZE_QVGA); } #if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM) s->set_vflip(s, 1); s->set_hmirror(s, 1); #endif #if defined(CAMERA_MODEL_ESP32S3_EYE) s->set_vflip(s, 1); #endif WiFi.begin(ssid, password); WiFi.setSleep(false); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); startCameraServer(); Serial.print("Camera Ready! Use 'http://"); Serial.print(WiFi.localIP()); Serial.println("' to connect"); } void loop() { // Do nothing. Everything is done in another task by the web server delay(10000); } |
After uploading the program, unplug your ESP32 FireBeetle board and plug it again, then open the serial monitor, and over there you will see a URL link; so simply copy that link and Paste it into the web browser. You should be able to see the camera settings so simply scroll down and click the Start Stream button. The live video streaming will start in no time.
Now you can play around with these different parameters. You can also do live video streaming on your cell phone, all you need is to open the web browser and paste the same URL link.
320×240 IPS TFT LCD Display:
Next, we are going to use this 320×240 IPS TFT LCD Display with the FireBeetle 2 ESP32-S3.
It supports SPI(4-wire) communication mode and GDI port. It accepts a wide range of input voltages from 3.3V to 5V which makes it compatible with multiple main-controller boards like Arduino, Leonardo, ESP32, ESP8266, and so on. Use the GDI interface on the controller board which could effectively reduce the wiring. And if you plan to use it with the Arduino or any other controller board that doesn’t come with a GDI interface then you can use the male headers. Since the FireBeetle 2 ESP32 S3 board already has a GDI port so I am going to use the FPC cable.
In the image above you can see the spi wiring and gdi wiring. You can do one of these wiring at a time. If you want to use the male headers then there is no need to connect the FPC cable and vice versa. In my case I am going to continue with the GDI “FPC cable”.
There is also an onboard MicroSD card slot underneath the display for storing and displaying images. So, this module has the advantage of high resolution, wide viewing angle, and simple wiring, and can be used in many display applications: waveform monitor display, electronic gift box, sensors monitoring, electronic weather decorations, and so on.
Anyway, the LCD is connected and next we are going to add library in the Arduino IDE. So, while your Arduino IDE is open go to the Sketch Menu, then to Include Library, and click on the Add .ZIP Library. Browse to the location and select this library,
FireBeetle 2 ESP32, TFT LCD programming:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
/*! * @file basicTest.ino * @brief Demonstrate various graphic painting effects * @n This demo supports Arduino Uno, Leonardo, Mega2560, FireBeetle-ESP32, FireBeetle-ESP8266, and FireBeetle-M0. * @copyright Copyright (c) 2010 DFRobot Co. Ltd (http://www.dfrobot.com) * @licence The MIT License (MIT) * @author [LuoYufeng] (yufeng.luo@dfrobot.com) * @version V0.1 * @date 2020-01-07 * @url https://github.com/DFRobot/DFRobot_GDL */ #include "DFRobot_GDL.h" /*M0*/ #if defined ARDUINO_SAM_ZERO #define TFT_DC 7 #define TFT_CS 5 #define TFT_RST 6 /*ESP32 and ESP8266*/ #elif defined(ESP32) || defined(ESP8266) #define TFT_DC D2 #define TFT_CS D6 #define TFT_RST D3 /*AVR series mainboard*/ #else #define TFT_DC 2 #define TFT_CS 3 #define TFT_RST 4 #endif /** * @brief Constructor Constructor of hardware SPI communication * @param dc Command/data line pin for SPI communication * @param cs Chip select pin for SPI communication * @param rst reset pin of the screen */ //DFRobot_ST7789_240x240_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); DFRobot_ST7789_240x320_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9341_240x320_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9488_320x480_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); /* M0 mainboard DMA transfer */ //DFRobot_ST7789_240x240_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ST7789_240x320_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9341_240x320_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9488_320x480_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); /* *User-selectable macro definition color *COLOR_RGB565_BLACK COLOR_RGB565_NAVY COLOR_RGB565_DGREEN COLOR_RGB565_DCYAN *COLOR_RGB565_MAROON COLOR_RGB565_PURPLE COLOR_RGB565_OLIVE COLOR_RGB565_LGRAY *COLOR_RGB565_DGRAY COLOR_RGB565_BLUE COLOR_RGB565_GREEN COLOR_RGB565_CYAN *COLOR_RGB565_RED COLOR_RGB565_MAGENTA COLOR_RGB565_YELLOW COLOR_RGB565_ORANGE *COLOR_RGB565_WHITE */ void setup() { Serial.begin(115200); screen.begin(); } void loop(){ testDrawPixel(); testLine(); testFastLines(COLOR_RGB565_PURPLE,COLOR_RGB565_YELLOW); testRects(COLOR_RGB565_BLACK,COLOR_RGB565_WHITE); testRoundRects(); testCircles(24,COLOR_RGB565_BLUE); testTriangles(COLOR_RGB565_YELLOW); testPrint(); } /* Test to draw a pixel*/ void testDrawPixel() { //Clear screen screen.fillScreen(COLOR_RGB565_BLACK); int x = 0; int y = screen.height(); for(int i = 0; i <= screen.width()/2; i += 10){ for (x = screen.width() - i; x >= i; x-=10 ){ /* * @ brief draw a pixel * @ param x coordinate * y coordinate * c pixel color */ screen.drawPixel(x, y, COLOR_RGB565_ORANGE); delay(10); } for (y = screen.height() - i; y >= i; y-=10){ screen.drawPixel(x, y, COLOR_RGB565_ORANGE); delay(10); } for (x = i; x <= screen.width() - i + 1; x+=10 ){ screen.drawPixel(x, y, COLOR_RGB565_ORANGE); delay(10); } for (y = i; y <= screen.height() - i + 1; y+=10){ screen.drawPixel(x, y, COLOR_RGB565_ORANGE); delay(10); } } } /* Test to draw a line*/ void testLine(){ // 0x00FF is the color data in the format of RGB565 uint16_t color = 0x00FF; screen.fillScreen(COLOR_RGB565_BLACK); for (int16_t x=0; x < screen.width(); x+=6) { /* * @ brief draw a line * @ param x0 The x-coordinate of the first vertex * y0 The y-coordinate of the first vertex * x1 The x-coordinate of the second vertex * y1 The y-coordinate of the second vertex * c line color */ screen.drawLine(/*x0=*/screen.width()/*Screen width*//2, /*y0=*/screen.height()/*Screen height*//2, /*x1=*/x, /*y1=*/0, /*c=*/color+=0x0700); } for (int16_t y=0; y < screen.height(); y+=6) { screen.drawLine(screen.width()/2, screen.height()/2, screen.width(), y, color+=0x0700); } for (int16_t x = screen.width(); x >= 0; x-=6) { screen.drawLine(screen.width()/2, screen.height()/2, x,screen.height(), color+=0x0700); } for (int16_t y = screen.height(); y >= 0; y-=6) { screen.drawLine(screen.width()/2, screen.height()/2, 0, y, color+=0x0700); } } /* Test to fast draw line(need to set delay), only horizontal line and vertical line */ void testFastLines(uint16_t color1, uint16_t color2) { for (int16_t y=0; y < screen.height(); y+=4) { /* * @ brief draw a line * @ param x The x-coordinate of the first vertex * y The y-coordinate of the first vertex * w Length of line segment * c line color */ screen.drawFastHLine(/*x=*/0, /*y=*/y, /*w=*/screen.width(),/*c=*/color2); delay(10); } for(int16_t x=0; x < screen.width(); x+=3) { /* * @ brief draw a line * @ param x The x-coordinate of the first vertex * y The y-coordinate of the first vertex * h length of line segment * c line color */ screen.drawFastVLine(/*x=*/x, /*y=*/0, /*h=*/screen.height(), /*c=*/color1); delay(10); } } /* Test to draw a rectangle*/ void testRects(uint16_t color1, uint16_t color2) { screen.fillScreen(COLOR_RGB565_BLACK); int16_t x=screen.width()-12; for (; x > 100; x-=screen.width()/40) { /* * @ brief draw a hollow rectangle * @ param x The x-coordinate of the vertex * @ param y The y-coordinate of the vertex * @ param w horizontal side length * @ param h longitudinal side length * @ param color Fill color, RGB color with 565 structure */ screen.drawRect(/*x=*/screen.width()/2 -x/2, /*y=*/screen.height()/2 -x/2 , /*w=*/x, /*h=*/x, /*color=*/color2+=0x0F00); delay(100); } /* * @ brief draw a filled rectangle * @ param x The x-coordinate of the vertex * @ param y The y-coordinate of the vertex * @ param w horizontal side length * @ param h longitudinal side length * @ param color Fill color, RGB color with 565 structure */ screen.fillRect(/*x=*/screen.width()/2 -x/2, /*y=*/screen.height()/2 -x/2 , /*w=*/x, /*h=*/x, /*color=*/color2); delay(100); for(; x > 6; x-=screen.width()/40){ screen.drawRect(screen.width()/2 -x/2, screen.height()/2 -x/2 , x, x, color1); delay(100); } } /* Test to draw a rounded rectangle */ void testRoundRects() { screen.fillScreen(COLOR_RGB565_BLACK); // 0xF00F is the color data in the format of RGB565 int color = 0xF00F; int i; int x = 0; int y = 0; int w = screen.width()-3; int h = screen.height()-3; for(i = 0 ; i <= 16; i+=2) { /* * @ brief Draw a hollow rounded rectangle * @ param x0 The x-coordinate of the start vertex * @ param y0 The y-coordinate of the start vertex * @ param w horizontal side length * @ param h longitudinal side length * @ param radius Round corner radius * @ param color border color, 565 structure RGB color */ screen.drawRoundRect(/*x0=*/x, /*y0=*/y, /*w=*/w, /*h=*/h, /*radius=*/20, /*color=*/color); x+=5; y+=5; w-=10; h-=10; color+=0x0100; delay(50); } for(i = 0 ; i <= 16; i+=2) { /* * @ brief Draw a filled and rounded rectangle * @ param x0 The x-coordinate of the start vertex * @ param y0 The y-coordinate of the start vertex * @ param w horizontal side length * @ param h longitudinal side length * @ param radius Round corner radius * @ param color Fill color, RGB color with 565 structure */ screen.fillRoundRect(/*x0=*/x, /*y0=*/y, /*w=*/w, /*h=*/h, /*radius=*/10, /*color=*/color); x+=5; y+=5; w-=10; h-=10; color+=0x0500; delay(50); } } /* Test to draw a circle */ void testCircles(uint8_t radius, uint16_t color) { screen.fillScreen(COLOR_RGB565_BLACK); for (int16_t x=radius; x <=screen.width()-radius; x+=radius*2) { for (int16_t y=radius; y <=screen.height()-radius; y+=radius*2) { /* * @ brief Draw a hollow circle * @ param x0 The x-coordinate of the center point * @ param y0 The y-coordinate of the center point * @ param r radius * @ param color Circle color, RGB color with 565 structure */ screen.drawCircle(/*x0=*/x, /*y0=*/y, /*r=*/radius, /*color=*/color); if(x == y ||x == -y ||x == y + 2*radius) /* * @ brief Draw a filled circle * @ param x0 The x-coordinate of the center point * @ param y0 The y-coordinate of the center point * @ param r radius * @ param color Fill color, RGB color with 565 structure */ screen.fillCircle(/*x0=*/x, /*y0=*/y, /*r=*/radius, /*color=*/color); color += 800; delay(100); } } } /* Test to draw a triangle */ void testTriangles(uint16_t color){ screen.fillScreen(COLOR_RGB565_BLACK); for (int16_t i=0; i <=screen.width(); i+=24) /* * @ brief Draw a hollow triangle * @ param x0 The x-coordinate of the start vertex * @ param y0 The y-coordinate of the start vertex * @ param x1 The x-coordinate of the second vertex * @ param y1 The y-coordinate of the second vertex * @ param x2 The x-coordinate of the third vertex * @ param y2 The y-coordinate of the third vertex * @ param color border color, 565 structure RGB color */ screen.drawTriangle(/*x0=*/i,/*y0=*/0,/*x1=*/0,/*y1=*/screen.height()-i,/*x2=*/screen.width()-i,/*y2=*/screen.height(), /*color=*/color); for (int16_t i=0; i <screen.width(); i+=24) screen.drawTriangle(screen.width(),i*4/3,0,screen.height()-i*4/3,i,0, color); for (int16_t i=0; i <screen.width(); i+=24) screen.drawTriangle(screen.width(),i*4/3,i,0,screen.width()-i,screen.height(), color); color = COLOR_RGB565_RED; for (int16_t i=0; i <=screen.width(); i+=24) /* * @ brief Draw a filled triangle * @ param x0 The x-coordinate of the start vertex * @ param y0 The y-coordinate of the start vertex * @ param x1 The x-coordinate of the second vertex * @ param y1 The y-coordinate of the second vertex * @ param x2 The x-coordinate of the third vertex * @ param y2 The y-coordinate of the third vertex * @ param color Fill color, RGB color with 565 structure */ screen.fillTriangle(/*x0=*/i,/*y0=*/0,/*x1=*/0,/*y1=*/screen.height()-i,/*x2=*/screen.width()-i,/*y2=*/screen.height(), /*color=*/color+=100); for (int16_t i=0; i <screen.width(); i+=24) screen.fillTriangle(screen.width(),i*4/3,0,screen.height()-i*4/3,i,0, color+=100); for (int16_t i=0; i <screen.width(); i+=24) screen.fillTriangle(screen.width(),i*4/3,i,0,screen.width()-i,screen.height(), color+=100); } void testPrint() { // 0x00FF is the color data in the format of RGB565 int16_t color = 0x00FF; // Set text wrapping mode // true = Text word wrap, false = No word wrap screen.setTextWrap(false); //Fill color, RGB color with 565 structure screen.fillScreen(COLOR_RGB565_BLACK); //Set the coordinate position x = 0, y = 50 screen.setCursor(0, 50); //Set the text color; this is a changeable value screen.setTextColor(color+=0x3000); //Set text size to 0 screen.setTextSize(0); //Output text screen.println("Hello World!"); screen.setTextColor(color+=0x3000); //Set text size to 1 screen.setTextSize(1); screen.println("Hello World!"); screen.setTextColor(color+=0x3000); //Set text size to 2 screen.setTextSize(2); screen.println("Hello World!"); screen.setTextColor(color+=0x3000); //Set text size to 3 screen.setTextSize(3); screen.println("Hello World!"); screen.setTextColor(color+=0x3000); //Set text size to 4 screen.setTextSize(4); screen.println("Hello!"); //Set text size to 5 screen.setTextSize(5); screen.print("Hello!"); delay(2000); //Set coordinate position x = 0, y = 0 screen.setCursor(0, 0); //Fill color, RGB color with 565 structure screen.fillScreen(COLOR_RGB565_BLACK); screen.setTextSize(2); screen.setTextColor(color+=0x3000); screen.print("a = "); screen.setTextColor(color+=0x3000); int a = 1234; screen.println(a, 1); screen.setTextColor(color+=0x3000); screen.print(8675309, HEX); screen.println("this is HEX!"); screen.println(""); screen.setTextColor(color+=0x0F00); screen.println("running for: "); screen.setTextColor(color+=0x0F00); //Output time in millisecond screen.print(millis()); screen.setTextColor(color+=0x0F00); screen.println("/1000 seconds."); char *text = "Hi DFRobot!"; screen.setTextColor(color+=0x0F00); screen.setTextWrap(true); screen.setTextSize(3); screen.println(text); //screen.setFonts((const gdl_Font_t *)SIMKAIFont18ptBitmaps); screen.println(text); delay(2000); } |
You can use this program to check your TFT LCD.
The TFT LCD is working and now, let’s work on the temperature monitoring system using the MLX90614 non-contact infrared temperature sensor.
FireBeetle 2 ESP32 with MLX90614, Circuit Diagram:
Connect the VCC and GND of the MLX90614 non contact infrared temperature sensor to the 3.3V and GND pins. Connect the SDA and SCL pins to the SDA and SCL on the FireBeetle 2 ESP32 board.
Required Library:
You will also need to install the DFRobot_MLX90614 library. For this, go to the Sketch Menu, then to Include Library, and click on the manage libraries. Write the Library name in the search box.
You can see I have already installed this library.
FireBeetle 2 ESP32 with MLX90614, Programming:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
#include "DFRobot_GDL.h" #include <DFRobot_MLX90614.h> DFRobot_MLX90614_I2C sensor; // instantiate an object to drive our sensor float objectTemp; /*M0*/ #if defined ARDUINO_SAM_ZERO #define TFT_DC 7 #define TFT_CS 5 #define TFT_RST 6 /*ESP32 and ESP8266*/ #elif defined(ESP32) || defined(ESP8266) #define TFT_DC D2 #define TFT_CS D6 #define TFT_RST D3 /*AVR series mainboard*/ #else #define TFT_DC 2 #define TFT_CS 3 #define TFT_RST 4 #endif /** * @brief Constructor Constructors for hardware SPI communication * @param dc Command pin or data line pin of SPI communication * @param cs Chip select pin for SPI communication * @param rst Reset pin of the screen * @param bl Screen backlight pin */ //DFRobot_ST7789_240x240_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); DFRobot_ST7789_240x320_HW_SPI tft(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9341_240x320_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9488_320x480_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); /* M0 mainboard DMA transfer */ //DFRobot_ST7789_240x240_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ST7789_240x320_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9341_240x320_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9488_320x480_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF float temp =0; float ftemp =0; float pretemp =0; float preftemp =0; float currtemp =50; float currftemp=100; float i=0; float j=0; void setup(void) { Serial.begin(9600); //// uint16_t ID = tft.readID(); // Serial.print("TFT ID = 0x"); // Serial.println(ID, HEX); // Serial.println("Calibrate for your Touch Panel"); // if (ID == 0xD3D3) ID = 0x9486; // write-only shield tft.begin(); tft.setRotation(1); //PORTRAIT tft.fillScreen(COLOR_RGB565_BLACK); tft.setTextColor(COLOR_RGB565_YELLOW, COLOR_RGB565_BLACK); tft.setTextSize(2); // testing(); tft.setTextSize(2); tft.setCursor(15, 240); tft.setTextColor(COLOR_RGB565_GREEN,COLOR_RGB565_BLACK); tft.print("Electroniclinic"); // delay(1000); tft.fillScreen(COLOR_RGB565_BLACK); tft.setTextColor(COLOR_RGB565_GREEN,COLOR_RGB565_BLACK); tft.setCursor(55, 180); tft.print("0"); tft.setCursor(95, 180); tft.print("100"); tft.setCursor(55, 120); tft.print((char)247); tft.print("C"); tft.setTextColor(COLOR_RGB565_WHITE ,COLOR_RGB565_BLACK); tft.setCursor(215, 180); tft.print("0"); tft.setCursor(240, 180); tft.print("212"); tft.setCursor(210, 120); tft.print((char)247); tft.print("F"); tft.setCursor(45, 10); tft.fillRect(0,0,320,45,COLOR_RGB565_BLACK); tft.setTextColor(COLOR_RGB565_YELLOW,COLOR_RGB565_BLACK); tft.print("Temperature Monitor"); while( NO_ERR != sensor.begin() ){ Serial.println("Communication with device failed, please check connection"); delay(3000); } Serial.println("Begin ok!"); /** * adjust sensor sleep mode * mode select to enter or exit sleep mode, it's enter sleep mode by default * true is to enter sleep mode * false is to exit sleep mode (automatically exit sleep mode after power down and restart) */ sensor.enterSleepMode(); delay(50); sensor.enterSleepMode(false); delay(200); sensor.setEmissivityCorrectionCoefficient(0.91); float ambientTemp = sensor.getAmbientTempCelsius(); float objectTemp = sensor.getObjectTempCelsius(); } void loop(void) { tft.fillRect(55, 150,60,20,COLOR_RGB565_BLACK); tft.fillRect(212,150,60,20,COLOR_RGB565_BLACK); tft.setCursor(55, 150); tft.print(temp); tft.setCursor(212, 150); tft.print(ftemp); i=map(pretemp,0,100,0,300); j=map(currtemp,0,100,0,300); for (i; i<=j; i=i+0.1) { float j=i-150 ; float angle = (j / 57.2958) - 1.57; float x1= 80 + cos(angle) * 55; float y1 = 130+sin(angle) * 55; float x2= 80 + cos(angle) * 75; float y2 = 130+sin(angle) * 75; tft.drawLine(x1, y1,x2,y2, COLOR_RGB565_GREEN); } i=map(pretemp,0,100,0,300); j=map(currtemp,0,100,0,300); for (i-2; i>=j; i=i-0.05) { float j=i-150 ; float angle = (j / 57.2958) - 1.57; float x1= 80 + cos(angle) * 55; float y1 = 130+sin(angle) * 55; float x2= 80 + cos(angle) * 75; float y2 = 130+sin(angle) * 75; tft.drawLine(x1, y1,x2,y2, COLOR_RGB565_BLACK); // tft.drawLine(x1+160, y1,x2+160,y2, MAGENTA); } i=map(preftemp,0,212,0,300); j=map(currftemp,0,212,0,300); for (i; i<=j; i=i+0.1) { float j=i-150 ; float angle = (j / 57.2958) - 1.57; float x1= 80 + cos(angle) * 55; float y1 = 130+sin(angle) * 55; float x2= 80 + cos(angle) * 75; float y2 = 130+sin(angle) * 75; tft.drawLine(x1+160, y1,x2+160,y2, COLOR_RGB565_MAGENTA); } i=map(preftemp,0,100,0,300); j=map(currftemp,0,100,0,300); for (i-2; i>=j; i=i-0.05) { float j=i-150 ; float angle = (j / 57.2958) - 1.57; float x1= 80 + cos(angle) * 55; float y1 = 130+sin(angle) * 55; float x2= 80 + cos(angle) * 75; float y2 = 130+sin(angle) * 75; tft.drawLine(x1+160, y1,x2+160,y2, COLOR_RGB565_BLACK); } preftemp=currftemp; pretemp=currtemp; temp= sensor.getObjectTempCelsius(); // Temperature in Celsius ftemp=temp*9/5 + 32; // Temperature in Fahrenheit. Serial.println("TEMP:"+String(temp)); currtemp=temp; currftemp=ftemp; delay(100); } |
The program is a bit longer because we are displaying the temperature values on the Gauges. If you don’t use gauges, the program will become quite small. These are the pin definitions for various controller boards.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
/*M0*/ #if defined ARDUINO_SAM_ZERO #define TFT_DC 7 #define TFT_CS 5 #define TFT_RST 6 /*ESP32 and ESP8266*/ #elif defined(ESP32) || defined(ESP8266) #define TFT_DC D2 #define TFT_CS D6 #define TFT_RST D3 /*AVR series mainboard*/ #else #define TFT_DC 2 #define TFT_CS 3 #define TFT_RST 4 #endif |
These are the different display modules,
1 2 3 4 5 6 7 8 9 |
//DFRobot_ST7789_240x240_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); DFRobot_ST7789_240x320_HW_SPI tft(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9341_240x320_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9488_320x480_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); /* M0 mainboard DMA transfer */ //DFRobot_ST7789_240x240_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ST7789_240x320_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9341_240x320_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); //DFRobot_ILI9488_320x480_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); |
Simply uncomment the one you are using. In my case, I have uncommented this line.
1 |
DFRobot_ST7789_240x320_HW_SPI tft(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST); |
Next, I have defined some colors and variables.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF float temp =0; float ftemp =0; float pretemp =0; float preftemp =0; float currtemp =50; float currftemp=100; float i=0; float j=0; |
All these other instructions in the void setup() function are used with the TFT display Module to enable the display, set the orientation, fill the screen, set the text color, set the text size, and so on.
Next, we select the desired Emissivity correction co-efficient.
1 2 3 |
sensor.setEmissivityCorrectionCoefficient(0.91); float ambientTemp = sensor.getAmbientTempCelsius(); float objectTemp = sensor.getObjectTempCelsius(); |
0.91 is for the human skin. Every object has its own emissivity value. I have explained this in my getting started tutorial on the MLX90614 temperature sensor.
In the loop function, all these instructions are used to display the temperature values on the Gauges.
I have already uploaded this program and now let’s watch the FireBeetle 2 ESP32 based temperature monitoring system in action.
Watch Video Tutorial:
Error in running Dfrobot Firebeetle S3
ll_cam.c:231:15: error: ‘volatile union ‘ has no member named ‘in_suc_eof’
if (status.in_suc_eof) {