If Board is selected as Adafruit QT Py ESP32-S2 there is no option to set Partition Scheme as RainMaker in Arduino IDE 2.0 (even in Arduino 1.8.19)
If changed to following settings in Arduino IDE 2.0, this is the error message at end of upload:
Board : ESP32S2 Dev Module
Partition Scheme: RainMaker
Writing at 0x0010d418... (98 %)
Writing at 0x0010df34... (98 %)
Writing at 0x0010ed09... (99 %)
Writing at 0x0010f900... (99 %)
Writing at 0x00110324... (99 %)
Writing at 0x00110df0... (100 %)
Wrote 1054528 bytes (699823 compressed) at 0x00010000 in 13.3 seconds (effective 633.9 kbit/s)...
Hash of data verified.
Leaving...
WARNING: ESP32-S2FNR2 chip was placed into download mode using GPIO0.
esptool.py can not exit the download mode over USB. To run the app, reset the chip manually.
To suppress this note, set --after option to 'no_reset'.
Failed uploading: uploading error: exit status 1
Code
```
#include "RMaker.h"
#include "WiFi.h"
#include "WiFiProv.h"
#include
#include "Adafruit_SHTC3.h"
#define DEFAULT_I2C_PORT &Wire
#if defined(ARDUINO_ADAFRUIT_KB2040_RP2040) \
|| defined(ARDUINO_ADAFRUIT_ITSYBITSY_RP2040) \
|| defined(ARDUINO_ADAFRUIT_QTPY_RP2040) \
|| defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) \
|| defined(ARDUINO_ADAFRUIT_QTPY_ESP32S2) \
|| defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_NOPSRAM) \
|| defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3) \
|| defined(ARDUINO_ADAFRUIT_QTPY_ESP32_PICO) \
|| defined(ARDUINO_SAM_DUE)
#define SECONDARY_I2C_PORT &Wire1
#endif
Adafruit_SHTC3 shtc3 = Adafruit_SHTC3();
// Set Defalt Values
#define DEFAULT_Temperature 0
#define DEFAULT_Humidity 0
//GPIO for push button
#if CONFIG_IDF_TARGET_ESP32C3
static int gpio_0 = 9;
static int gpio_switch = 7;
#else
//GPIO for virtual device
static int gpio_0 = 0;
static int gpio_switch = 16;
#endif
#if CONFIG_IDF_TARGET_ESP32C3
//GPIO for push button
static int gpio_reset = 9;
//GPIO for virtual device
static int gpio_power = 7;
static int gpio_swing = 3;
static int gpio_mode_auto = 4;
static int gpio_mode_cool = 5;
static int gpio_mode_heat = 6;
static int gpio_speed = 10;
#else
//GPIO for push button
static int gpio_reset = 0;
//GPIO for virtual device
static int gpio_power = 16;
static int gpio_swing = 17;
static int gpio_mode_auto = 18;
static int gpio_mode_cool = 19;
static int gpio_mode_heat = 21;
static int gpio_speed = 22;
#endif
#define SECONDARY_I2C_PORT &Wire1
bool switch_state = true;
static Switch my_switch;
const char *service_name = "PROV_12345";
const char *pop = "1234567";
bool power_state = true;
bool wifi_connected = 0;
static TemperatureSensor temperature("Temperature");
static TemperatureSensor humidity("Humidity");
void sysProvEvent(arduino_event_t *sys_event)
{
switch (sys_event->event_id) {
case ARDUINO_EVENT_PROV_START:
#if CONFIG_IDF_TARGET_ESP32S2
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on SoftAP\n", service_name, pop);
printQR(service_name, pop, "softap");
#else
Serial.printf("\nProvisioning Started with name \"%s\" and PoP \"%s\" on BLE\n", service_name, pop);
printQR(service_name, pop, "ble");
#endif
break;
default:;
}
}
void setup()
{
Serial.begin(115200);
while (!Serial)
delay(10);
#if defined(ARDUINO_ADAFRUIT_QTPY_ESP32S2) || \
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_NOPSRAM) || \
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3) || \
defined(ARDUINO_ADAFRUIT_QTPY_ESP32_PICO)
Wire1.setPins(SDA1, SCL1);
#endif
Serial.println("SHTC3 test");
if (! shtc3.begin(SECONDARY_I2C_PORT)) {
Serial.println("Couldn't find SHTC3");
while (1) delay(1);
}
Serial.println("Found SHTC3 sensor");
pinMode(gpio_0, INPUT);
Node my_node;
my_node = RMaker.initNode("RoomTemp01");
my_node.addDevice(temperature);
my_node.addDevice(humidity);
RMaker.enableOTA(OTA_USING_PARAMS);
RMaker.enableTZService();
RMaker.enableSchedule();
RMaker.start();
WiFi.onEvent(sysProvEvent);
#if CONFIG_IDF_TARGET_ESP32S2
WiFiProv.beginProvision(WIFI_PROV_SCHEME_SOFTAP, WIFI_PROV_SCHEME_HANDLER_NONE, WIFI_PROV_SECURITY_1, pop, service_name);
#else
WiFiProv.beginProvision(WIFI_PROV_SCHEME_BLE, WIFI_PROV_SCHEME_HANDLER_FREE_BTDM, WIFI_PROV_SECURITY_1, pop, service_name);
#endif
}
void loop()
{
sensors_event_t hum, temp;
shtc3.getEvent(&hum, &temp);
Serial.print("Temperature: "); Serial.print(temp.temperature); Serial.println(" degrees C");
Serial.print("Humidity: "); Serial.print(hum.relative_humidity); Serial.println("% rH");
temperature.updateAndReportParam("Temperature", temp.temperature);
humidity.updateAndReportParam("Temperature", hum.relative_humidity);
if(digitalRead(gpio_0) == LOW) {
delay(100);
int startTime = millis();
while(digitalRead(gpio_0) == LOW) delay(50);
int endTime = millis();
if ((endTime - startTime) > 10000) {
// If key pressed for more than 10secs, reset all
Serial.printf("Reset to factory.\n");
RMakerFactoryReset(2);
} else if ((endTime - startTime) > 3000) {
Serial.printf("Reset Wi-Fi.\n");
// If key pressed for more than 3secs, but less than 10, reset Wi-Fi
RMakerWiFiReset(2);
}
}
delay(1000);
}
```
Hi @chaudhariatul ! This is to be expected on ESP32-S2 when you manually enter Download Mode and update using the onboard USB. If you update using UART+EN+IO0, it will be able to reset the board as expected.
Hi,
If Board is selected as Adafruit QT Py ESP32-S2 there is no option to set Partition Scheme as RainMaker in Arduino IDE 2.0 (even in Arduino 1.8.19)
If changed to following settings in Arduino IDE 2.0, this is the error message at end of upload:
Code
``` #include "RMaker.h" #include "WiFi.h" #include "WiFiProv.h" #include