Install VSCode and the PlatformIO extension
- Launch PlatformIO: From the VSCode sidebar, click on the PIO Home and select "Create New Project".
Project Configuration:
- Name: Choose a name that reflects the purpose of your project.
- Board: Look for and select 'WEMOS LOLIN C3 Mini'.
- Framework: Select 'Arduino' because it’s user-friendly and widely used.
Open platformio.ini file and add the following 3 lines:
lib_deps = https://github.com/sensora-io/sensora-library
monitor_speed = 115200
monitor_raw = true
In the src/main.cpp file paste these lines of code
#include <Arduino.h>
#include <SensoraEsp.h>
void handleLedMessage(PropertyValue& val) {
if (val.Bool()) {
SENSORA_LOGI("turn ON");
neopixelWrite(BUILTIN_LED, 0, 0, 255);
} else {
SENSORA_LOGI("turn OFF");
neopixelWrite(BUILTIN_LED, 0, 0, 0);
}
}
Property ledProperty("led", "Room LED");
void setup() {
Serial.begin(115200);
ledProperty.setDataType(DataType::Boolean)
.setAccessMode(AccessMode::Write)
.subscribe(handleLedMessage);
pinMode(LED_BUILTIN, OUTPUT);
Sensora.setup();
}
void loop() {
Sensora.loop();
}
Step 4: Build Your ProjectSave the file and build the project to make sure there are no errors. Once the build is correct, proceed with uploading the code to the device. Make sure device is already connected via USB-C cable with your machine.
Step 5: Setup Sensora CloudGo to sensora.io and create an account. Create a New project and go through the setup process.
Save your Device ID and Token in a secure place. You'll need them to configure your device later.
Step 6: Device ProvisionClick Setup device to open the provision modal
- Click Connect and the Serial popup will open. Select the same Serial port that the ESP32 is connected to.
- Confirm the selection by clicking Connect.
Provide WiFi SSID (WiFi name) and WiFi password. Click Next and wait for connection.
Provide the Device Token that you stored before.
Step 7: Create WidgetGo to the Dashboard tab and click New Widget +
In the Interactive tab select the Switch widget
Fill in all the info and click Create
Step 8: Congratulations!You have successfully created your IoT project using Sensora cloud. You can toggle the Switch widget On & Off and see the LED turning on & off instantly on your microcontroller.
YouTube tutorial: https://www.youtube.com/watch?v=RmCn_3YKQGo
Thank you! 🙏
Comments