Skip to content

Commit

Permalink
add rodai sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
bunjongy committed Nov 27, 2022
1 parent b027cf3 commit 6eac986
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config.h
/build
3 changes: 2 additions & 1 deletion .vscode/arduino.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"board": "esp32:esp32:esp32",
"sketch": "rodaiSensorBlynk.ino",
"programmer": "esp32:esptool",
"port": "COM10"
"port": "COM10",
"output": "./build"
}
1 change: 1 addition & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
"C:\\Users\\Bunjong Yosapa\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.5\\variants\\esp32",
"C:\\Users\\Bunjong Yosapa\\AppData\\Local\\Arduino15\\packages\\esp32\\hardware\\esp32\\2.0.5\\libraries\\WiFi\\src",
"C:\\arduino_work\\libraries\\Blynk\\src",
"C:\\arduino_work\\libraries\\RodaiSensor",
"c:\\users\\bunjong yosapa\\appdata\\local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\gcc8_4_0-esp-2021r2-patch3\\xtensa-esp32-elf\\include\\c++\\8.4.0",
"c:\\users\\bunjong yosapa\\appdata\\local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\gcc8_4_0-esp-2021r2-patch3\\xtensa-esp32-elf\\include\\c++\\8.4.0\\xtensa-esp32-elf",
"c:\\users\\bunjong yosapa\\appdata\\local\\arduino15\\packages\\esp32\\tools\\xtensa-esp32-elf-gcc\\gcc8_4_0-esp-2021r2-patch3\\xtensa-esp32-elf\\include\\c++\\8.4.0\\backward",
Expand Down
27 changes: 22 additions & 5 deletions rodaiSensorBlynk.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@

// #define BLYNK_DEBUG // Optional, this enables more detailed prints

#define BLYNK_TEMPLATE_ID "TMPLnLAhFJqH"
#define BLYNK_DEVICE_NAME "ESP32 RODAI"
#define BLYNK_AUTH_TOKEN "kj4mYVKxPbrDwBGN7epccY5yA44Szobe"
#include "config.h"

#define BLYNK_TEMPLATE_ID BLYNK_TEMPLATE_ID_OWNER
#define BLYNK_DEVICE_NAME BLYNK_DEVICE_NAME_OWNER
#define BLYNK_AUTH_TOKEN BLYNK_AUTH_TOKEN_OWNER

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

#include "RodaiSensor.h"

#include "esp_log.h"

#define SOIL_SENSOR_1 V5
#define SOIL_SENSOR_2 V6
#define SOIL_SENSOR_3 V7
Expand All @@ -26,16 +32,27 @@ char auth[] = BLYNK_AUTH_TOKEN;

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Sang_wee_2.4G";
char pass[] = "Jong@2224";
char ssid[] = WIFI_SSID;
char pass[] = WIFI_PASS;

BlynkTimer timer;

RodaiSensor rodaiSensor = RodaiSensor();

// This function sends Arduino's up time every second to Virtual Pin (5).
// In the app, Widget's reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void myTimerEvent()
{
uint8_t data[256];

int len = rodaiSensor.ReadHoldingRegisters(16, 6, 5, data);

for (int i = 0; i < len; i++)
{
ESP_LOGI("MAIN", "DATA@%d=%0X",i, data[i]);
}

// You can send any value at any time.
// Please don't send more that 10 values per second.
Blynk.virtualWrite(SOIL_SENSOR_1, 0.4334f);
Expand Down

0 comments on commit 6eac986

Please sign in to comment.