generated from jmgiacalone/esp32-template
MAX6675 added.
This commit is contained in:
@@ -22,9 +22,24 @@ monitor_speed = 115200
|
|||||||
|
|
||||||
[env:esp32cam]
|
[env:esp32cam]
|
||||||
board = esp32cam
|
board = esp32cam
|
||||||
|
lib_deps =
|
||||||
|
adafruit/Adafruit GFX Library@^1.11.9
|
||||||
|
adafruit/Adafruit SSD1306@^2.5.9
|
||||||
|
adafruit/MAX6675 library@^1.1.2
|
||||||
|
|
||||||
[env:lolin32]
|
[env:lolin32]
|
||||||
board = lolin32
|
board = lolin32
|
||||||
|
lib_deps =
|
||||||
|
adafruit/Adafruit GFX Library@^1.11.9
|
||||||
|
adafruit/Adafruit SSD1306@^2.5.9
|
||||||
|
https://github.com/me-no-dev/ESPAsyncWebServer.git
|
||||||
|
me-no-dev/AsyncTCP@^1.1.1
|
||||||
|
ayushsharma82/AsyncElegantOTA@^2.2.7
|
||||||
|
arduino-libraries/Arduino_JSON@^0.1.0
|
||||||
|
adafruit/MAX6675 library@^1.1.2
|
||||||
|
build_flags =
|
||||||
|
'-D ELEGANTOTA_USE_ASYNC_WEBSERVER=1'
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
[env:odyssey]
|
[env:odyssey]
|
||||||
board = seeed_xiao_esp32s3
|
board = seeed_xiao_esp32s3
|
||||||
@@ -32,3 +47,7 @@ platform_packages = toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
|
|||||||
build_flags =
|
build_flags =
|
||||||
'-D ARDUINO_USB_CDC_ON_BOOT=1'
|
'-D ARDUINO_USB_CDC_ON_BOOT=1'
|
||||||
'-D ARDUINO_USB_MODE=0'
|
'-D ARDUINO_USB_MODE=0'
|
||||||
|
lib_deps =
|
||||||
|
adafruit/Adafruit GFX Library@^1.11.9
|
||||||
|
adafruit/Adafruit SSD1306@^2.5.9
|
||||||
|
adafruit/MAX6675 library@^1.1.2
|
||||||
|
|||||||
113
src/main.cpp
113
src/main.cpp
@@ -3,6 +3,9 @@
|
|||||||
//Peripherals includes
|
//Peripherals includes
|
||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
#include <Adafruit_GFX.h>
|
||||||
|
#include <Adafruit_SSD1306.h>
|
||||||
|
#include <max6675.h>
|
||||||
|
|
||||||
//Web server includes
|
//Web server includes
|
||||||
#include <AsyncElegantOTA.h>
|
#include <AsyncElegantOTA.h>
|
||||||
@@ -20,6 +23,19 @@ Preferences settings;
|
|||||||
|
|
||||||
#define LED_PIN 5
|
#define LED_PIN 5
|
||||||
|
|
||||||
|
//*****
|
||||||
|
// Display defines
|
||||||
|
//*****
|
||||||
|
#define SCREEN_WIDTH 128
|
||||||
|
#define SCREEN_HEIGHT 64
|
||||||
|
|
||||||
|
#define SCREEN_REFRESH 5000
|
||||||
|
|
||||||
|
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
|
||||||
|
unsigned long lastScreenRefresh = 0;
|
||||||
|
|
||||||
|
MAX6675 tc(12, 13, 15);
|
||||||
|
|
||||||
//*********************************************************
|
//*********************************************************
|
||||||
// Web server variable declarations
|
// Web server variable declarations
|
||||||
//*********************************************************
|
//*********************************************************
|
||||||
@@ -57,6 +73,8 @@ const long interval = 10000; // interval to wait for Wi-Fi connection (millisec
|
|||||||
String ledState;
|
String ledState;
|
||||||
|
|
||||||
|
|
||||||
|
float temperature;
|
||||||
|
|
||||||
// --------- function declarations --------------
|
// --------- function declarations --------------
|
||||||
// void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len);
|
// void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len);
|
||||||
void initSPIFFS();
|
void initSPIFFS();
|
||||||
@@ -67,11 +85,18 @@ String getLEDState();
|
|||||||
void setup() {
|
void setup() {
|
||||||
pinMode(LED_PIN, OUTPUT);
|
pinMode(LED_PIN, OUTPUT);
|
||||||
|
|
||||||
|
Wire.begin(5, 4);
|
||||||
|
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
delay(2000);
|
delay(2000);
|
||||||
// while (!Serial)
|
// while (!Serial)
|
||||||
// delay(10); // will pause Zero, Leonardo, etc until serial console opens
|
// delay(10); // will pause Zero, Leonardo, etc until serial console opens
|
||||||
|
|
||||||
|
display.clearDisplay();
|
||||||
|
display.setTextColor(WHITE);
|
||||||
|
display.setTextSize(1);
|
||||||
|
display.setCursor(0, 26);
|
||||||
|
|
||||||
//*****************************************
|
//*****************************************
|
||||||
|
|
||||||
|
|
||||||
@@ -250,83 +275,27 @@ server.addHandler(new SPIFFSEditor(SPIFFS,http_username,http_password));
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
digitalWrite(LED_PIN,HIGH);
|
digitalWrite(LED_PIN,HIGH);
|
||||||
|
temperature = tc.readCelsius();
|
||||||
delay(500);
|
delay(500);
|
||||||
digitalWrite(LED_PIN,LOW);
|
digitalWrite(LED_PIN,LOW);
|
||||||
delay(500);
|
delay(500);
|
||||||
|
if ((millis() - lastScreenRefresh) > SCREEN_REFRESH) {
|
||||||
|
Serial.printf("T:%.2f,", temperature);
|
||||||
|
|
||||||
|
display.clearDisplay();
|
||||||
|
display.setTextSize(3);
|
||||||
|
display.setCursor(0, 5);
|
||||||
|
display.printf("T:%.1f\n", temperature);
|
||||||
|
display.setTextSize(1);
|
||||||
|
display.setCursor(0,48);
|
||||||
|
display.printf("%s\n",ssid);
|
||||||
|
display.printf("%s",ip);
|
||||||
|
display.display();
|
||||||
|
|
||||||
|
lastScreenRefresh = millis();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// functions
|
|
||||||
// void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){
|
|
||||||
// if(type == WS_EVT_CONNECT){
|
|
||||||
// Serial.printf("ws[%s][%u] connect\n", server->url(), client->id());
|
|
||||||
// client->printf("Hello Client %u :)", client->id());
|
|
||||||
// client->ping();
|
|
||||||
// } else if(type == WS_EVT_DISCONNECT){
|
|
||||||
// Serial.printf("ws[%s][%u] disconnect\n", server->url(), client->id());
|
|
||||||
// } else if(type == WS_EVT_ERROR){
|
|
||||||
// Serial.printf("ws[%s][%u] error(%u): %s\n", server->url(), client->id(), *((uint16_t*)arg), (char*)data);
|
|
||||||
// } else if(type == WS_EVT_PONG){
|
|
||||||
// Serial.printf("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:"");
|
|
||||||
// } else if(type == WS_EVT_DATA){
|
|
||||||
// AwsFrameInfo * info = (AwsFrameInfo*)arg;
|
|
||||||
// String msg = "";
|
|
||||||
// if(info->final && info->index == 0 && info->len == len){
|
|
||||||
// //the whole message is in a single frame and we got all of it's data
|
|
||||||
// Serial.printf("ws[%s][%u] %s-message[%llu]: ", server->url(), client->id(), (info->opcode == WS_TEXT)?"text":"binary", info->len);
|
|
||||||
|
|
||||||
// if(info->opcode == WS_TEXT){
|
|
||||||
// for(size_t i=0; i < info->len; i++) {
|
|
||||||
// msg += (char) data[i];
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// char buff[3];
|
|
||||||
// for(size_t i=0; i < info->len; i++) {
|
|
||||||
// sprintf(buff, "%02x ", (uint8_t) data[i]);
|
|
||||||
// msg += buff ;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// Serial.printf("%s\n",msg.c_str());
|
|
||||||
|
|
||||||
// if(info->opcode == WS_TEXT)
|
|
||||||
// client->text("I got your text message");
|
|
||||||
// else
|
|
||||||
// client->binary("I got your binary message");
|
|
||||||
// } else {
|
|
||||||
// //message is comprised of multiple frames or the frame is split into multiple packets
|
|
||||||
// if(info->index == 0){
|
|
||||||
// if(info->num == 0)
|
|
||||||
// Serial.printf("ws[%s][%u] %s-message start\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
|
|
||||||
// Serial.printf("ws[%s][%u] frame[%u] start[%llu]\n", server->url(), client->id(), info->num, info->len);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Serial.printf("ws[%s][%u] frame[%u] %s[%llu - %llu]: ", server->url(), client->id(), info->num, (info->message_opcode == WS_TEXT)?"text":"binary", info->index, info->index + len);
|
|
||||||
|
|
||||||
// if(info->opcode == WS_TEXT){
|
|
||||||
// for(size_t i=0; i < len; i++) {
|
|
||||||
// msg += (char) data[i];
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// char buff[3];
|
|
||||||
// for(size_t i=0; i < len; i++) {
|
|
||||||
// sprintf(buff, "%02x ", (uint8_t) data[i]);
|
|
||||||
// msg += buff ;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// Serial.printf("%s\n",msg.c_str());
|
|
||||||
|
|
||||||
// if((info->index + len) == info->len){
|
|
||||||
// Serial.printf("ws[%s][%u] frame[%u] end[%llu]\n", server->url(), client->id(), info->num, info->len);
|
|
||||||
// if(info->final){
|
|
||||||
// Serial.printf("ws[%s][%u] %s-message end\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
|
|
||||||
// if(info->message_opcode == WS_TEXT)
|
|
||||||
// client->text("I got your text message");
|
|
||||||
// else
|
|
||||||
// client->binary("I got your binary message");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Initialize SPIFFS
|
// Initialize SPIFFS
|
||||||
void initSPIFFS() {
|
void initSPIFFS() {
|
||||||
|
|||||||
Reference in New Issue
Block a user