Another illustration that demonstrate how to wire the ESP32-WROOM set as client talk to ThingSpeak API. As you can see the diagram below, we will be going to build a non-contact temperature sensor using MLX90614. Unlike DHTXX, LMXX, HDCXX, HTUXX, compare to MLX90614 it has an integrated IR to calculate a certain temperature featuring with high accuracy at range of -40 to 125 C. however there alternative you can use specially the TMP006 is also similar to MLX90614, Additionally, the MLX9061 sensor is suitable for human body temperature, surface temperature, heat ventilation, automotive temperature sensing, industrial applications, & more..
We use ESP32 as our client to connect with ThinkSpeak API service so we can access the data from the mobile devices. You can also expand this project to extend the capabilities by hooking up an OLED screen, LCD or E-Paper display panel to view the temperature in real-time. Perhaps, adding a database schema to log all captured temperature with a person’s profiling ex. an Id, Name, Date Stamp, Current Temperature, etc. so we can monitor a certain person if he or she has a COVID-19 symptom.
For integration with Arduino IDE please refer to this link, or if you to know more technically about the ESP32-ROOM please refer to this link. For the MLX90614 datasheet please refer to the datasheet below.
Requirements and Alternatives
- Arduino IDE | PlatformIO | Visual Studio Code
- SONY SPRESENSE Development Board
- Please refer to this link
- ESPRESSIF Microcontrollers
- MLX90614 Infrared Sensor
- NTJD4401N Dual N-Channel MOSFET
- Tactile Switch
- Push Button
- Resistors (See below required values)
- Capacitor(See below required values)
- Others (See below diagram for other requirements)
Diagram
i2C Address Finder
Just upload the code and open you serial monitor.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include <Wire.h> // I2C library, required for MLX90614 #include <SparkFunMLX90614.h> IRTherm therm; // Create an IRTherm object to interact with throughout void setup() { Serial.begin(9600); // Initialize Serial to log output therm.begin(); // Initialize the MLX90614 if (therm.readID()) // Read from the ID registers { // If the read succeeded, print the ID: Serial.println("ID: 0x" + String(therm.getIDH(), HEX) + String(therm.getIDL(), HEX)); } } void loop() { } |
Source Code
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 |
#include <Wire.h> #include <MLX90614.h> #ifdef __cplusplus extern "C" { #endif uint8_t temprature_sens_read(); #ifdef __cplusplus } #endif uint8_t temprature_sens_read(); #include <WiFi.h> String apiKey = "THIS_IS_YOUR_API_KEY_FROM_THINGSPEAK"; // Get you API Key from ThingSpeak.com const char *ssid = "THERMO"; //<-- Your SSID const char *pass = "1122334455"; //<-- Your WiFi Password const char* server = "api.thingspeak.com"; WiFiClient client; // Set as client mode IRTherm temp_tr; // Initializing the sensor String temper; String strPost = apiKey; void setup() { temp_tr.begin(); temp_tr.setUnit(TEMP_C); Serial.begin(115200); delay(10); Serial.println("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); } void loop() { if (temp_tr.read()) { temper = String(temp_tr.object(), 2); if (client.connect(server,80)) api.thingspeak.com { strPost += "&field1="; strPost += String(temper) strPost += "\r\n\r\n"; client.print("POST /update HTTP/1.1\n"); client.print("Host: api.thingspeak.com\n "); client.print("Connection: close\n") client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n"); client.print("Content-Type: application/x-www-form-urlencoded\n"); client.print("Content-Length: "); client.print(postStr.length()); client.print("\n\n"); client.print(postStr); Serial.print("VAL : ") Serial.print(temper); Serial.print("C") Serial.print("%. Sending to Cloud with ThingSpeak"); } client.stop(); Serial.println("Waiting........"); delay(200000); } |
Code with OLED 128×64
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 |
#include <WiFi.h> #include <SPI.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h> #include <Wire.h> #include <MLX90614.h> #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); #ifdef __cplusplus extern "C" { #endif uint8_t temprature_sens_read(); #ifdef __cplusplus } #endif uint8_t temprature_sens_read(); String apiKey = "THIS_IS_YOUR_API_KEY_FROM_THINGSPEAK"; // Get you API Key from ThingSpeak.com const char *ssid = "THERMO"; //<-- Your SSID const char *pass = "1122334455"; //<-- Your WiFi Password const char* server = "api.thingspeak.com"; WiFiClient client; // Set as client mode IRTherm temp_tr; // Initializing the sensor String temper; String strPost = apiKey; char dsp; // Address 0x3D for 128x64 void setup() { Serial.begin(115200); if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3D)) //0x3C OLED i2C Address if size 128x64 i2c address will be 0x3D { Serial.println(F("OLED allocation failed")); for(;;); } delay(2000); display.clearDisplay(); display.setTextSize(1); display.setTextColor(WHITE); display.setCursor(0, 10); display.display(); temp_tr.begin(); temp_tr.setUnit(TEMP_C); delay(10); display.println("14CORE | Thermometer"); display.clearDisplay(); Serial.println("Connecting to "); display.println("Connecting..."); delay(500); display.clearDisplay(); Serial.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); display.println("Connected..."); display.clearDisplay(); delay(500); } void loop() { temper = String(temp_tr.object(), 2); display.println(temper); display.println("DEG C"); display.clearDisplay(); runner++; delay(5); if (temp_tr.read()) { if (client.connect(server,80)) api.thingspeak.com { strPost += "&field1="; strPost += String(temper); strPost += "\r\n\r\n"; client.print("POST /update HTTP/1.1\n"); client.print("Host: api.thingspeak.com\n "); client.print("Connection: close\n"); client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n"); client.print("Content-Type: application/x-www-form-urlencoded\n"); client.print("Content-Length: "); client.print(postStr.length()); client.print("\n\n"); client.print(postStr); Serial.print("VAL : "); Serial.print(temper); Serial.print("C"); Serial.print("%. Sending to Cloud with ThingSpeak"); } client.stop(); Serial.println("Waiting........"); delay(200000); } if (dsp>20) dsp=0; } |
Downloads
Thank you very good resource for learning.
doing this totorial when I run the programs I get the following error ‘IRTherm’ does not name a type I’m using an esp8266 to see if they can help me. Thank you
코드를 깜박이는 동안 오류가 있습니까? 아마도 일부 변수가 선언되지 않았습니다.