working on esp32 c3

This commit is contained in:
2024-02-04 10:55:38 +01:00
parent 833ecfd1f2
commit 26c8f0cba9
2 changed files with 36 additions and 16 deletions

View File

@@ -10,12 +10,18 @@
[env:esp32dev]
platform = espressif32
board = esp32dev
; board = esp32dev # devkit
board = esp32-c3-devkitm-1
; board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
#; upload_port = COM[6]
; framework = espidf
monitor_speed = 9600
; upload_port = COM10
build_flags = -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1
; upload_protocol = espota
upload_port = 192.168.2.136
; upload_port = 192.168.2.136
upload_port = 192.168.2.147
; upload_port = 192.168.2.128
;board_build.partitions = huge_app.csv
board_build.partitions = min_spiffs.csv

View File

@@ -1,3 +1,4 @@
// #include <stdio.h>
#include <Arduino.h>
/*Program to use GATT service on ESP32 to send Battery Level
* ESP32 works as server - Mobile as client
@@ -19,8 +20,13 @@
#include <WiFi.h>
#include <WiFiUdp.h>
// #define STATUS_LED 13
#define STATUS_LED 13
#define ALARM_LED 33
// #define ALARM_LED GPIO_NUM_2
#define ALARM_LED GPIO_NUM_8
#define MODE_ADDRESS 0
#define MODE_BLE 0
#define MODE_WIFI 1
@@ -97,6 +103,8 @@ class MyAlarmCallback : public BLECharacteristicCallbacks {
void InitBLE() {
BLEDevice::init("OilCheck");
Serial.println("Start BLE");
// Create the BLE Server
BLEServer * pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());
@@ -130,7 +138,9 @@ void IRAM_ATTR onTimer() {
}
void setup() {
Serial.begin(115200);
Serial.begin(9600);
// delay(3000);
// // Serial.println("Hallo Welt");
EEPROM.begin(EEPROM_SIZE);
@@ -150,10 +160,14 @@ void setup() {
// blink led
pinMode(ALARM_LED, OUTPUT);
digitalWrite(ALARM_LED, HIGH);
// delay(1000);
// digitalWrite(ALARM_LED, LOW);
// delay(1000);
// digitalWrite(ALARM_LED, HIGH);
// status led
pinMode(STATUS_LED, OUTPUT);
// pinMode(STATUS_LED, OUTPUT);
Serial.println("Start BLE");
InitBLE();
}
else if (mode == MODE_WIFI) {
@@ -212,12 +226,12 @@ void setup() {
}
// WiFi.mode(WIFI_STA);
// WiFi.begin(ssid, password);
// while (WiFi.waitForConnectResult() != WL_CONNECTED) {
// delay(3000);
// break;
// }
// ArduinoOTA.begin();
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
delay(3000);
break;
}
ArduinoOTA.begin();
}
// toggles pin and returns new state of pin
@@ -320,13 +334,13 @@ void loop() {
// do stuff here on connecting
oldDeviceConnected = deviceConnected;
digitalWrite(ALARM_LED, HIGH);
delay(200);
digitalWrite(ALARM_LED, LOW);
delay(200);
digitalWrite(ALARM_LED, HIGH);
delay(200);
digitalWrite(ALARM_LED, LOW);
delay(200);
digitalWrite(ALARM_LED, HIGH);
}