Hi everyone.
I want to use ESP-C3-DevkitM-1 with softwareserial.h library
ESP32-C3-DevKitM-1 - ESP32-C3 - — ESP-IDF Programming Guide latest documentation (espressif.com)
#include<SoftwareSerial.h>
SoftwareSerial mySerial(5, 6);//
I already downloaded library of #include<SoftwareSerial.h
I think pin 5 and 6 of ESP32-C3-DevKitM-1 is not work.
Could you recommend me about pin for SoftwareSerial mySerial ?
Hi
Actually, I run this code on Arduino MEGA. It is success.
But I don't know how to run on ESP32
#include<SoftwareSerial.h>
SoftwareSerial mySerial(12, 13);// RX, TX - 12 yellow 13 white(this is check ok)
//COMMANDS FROM DATASHEETs
byte auto_baud = 0x55;
byte continous_exit = 0x58;
byte rd_status[5] = {0xAA, 0x80, 0x00, 0x00, 0x80};
byte rd_hw[5] = {0xAA, 0x80, 0x00, 0x0A, 0x8A};
byte rd_sw[5] = {0xAA, 0x80, 0x00, 0x0C, 0x8C};
byte rd_sn[5] = {0xAA, 0x80, 0x00, 0x0E, 0x8E};
byte rd_vo[5] = {0xAA, 0x80, 0x00, 0x06, 0x86};
byte rd_meas[5] ={0xAA, 0x80, 0x00, 0x22, 0xA2};
byte laser_on[9] = {0xAA, 0x00, 0x01, 0xBE, 0x00, 0x01, 0x00, 0x01, 0xC1};
byte laser_off[9] = {0xAA, 0x00, 0x01, 0xBE, 0x00, 0x01, 0x00, 0x00, 0xC0};
byte one_shot_auto[9] = {0xAA, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x21};
byte continous_fast[9] = {0xAA, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x06, 0x27};
//VARs FOR WORKING WITH DATA
unsigned long Data = 0;
byte Read[13];
//
void setup() {
//Serial is comms with computer & mySerial comms with sensor
Serial.begin(19200);//Baudrate with computer
pinMode(8, OUTPUT);
digitalWrite(8, LOW);
delay(1000);
Serial.println(" ");
Serial.println("M88 SERIES LASER SENSOR.......");
Serial.println("Serial ports OPEN");
digitalWrite(8, HIGH);
delay(1000);
Serial.println("Sensor ON");
Serial.println("wait...");
mySerial.begin(19200);//Baudrate for comms with sensor
mySerial.setTimeout(0.001);
while (mySerial.read()!= 0x00) {}
Serial.println("ok");
mySerial.write(0x55);//auto baudrate commas
delay(100);
//test ON and OFF pointer
Serial.println("LASER POINT ON...");
mySerial.write(laser_on, 9);
delay(1000);
Serial.println("LASER POINT OFF...");
mySerial.write(laser_off, 9);
delay(200);
}
void loop() {
Serial.println("read one shot mode: ");
Data = 0;
mySerial.write(one_shot_auto, 9); // Send command to sensor
//
//Received command in HEX format
while (mySerial.available()>0){
mySerial.readBytes(Read,13);
}
//
//Print Data for test
Serial.println(" ");
Serial.print("dato trama en HEX:");
for (int i = 0; i <= 12; i++){
Serial.print(Read[i],HEX);
}
//Print only measure data
Serial.println(" ");
Serial.print("dato medida en HEX:");
for (int i = 6; i <= 9; i++){
Serial.print(Read[i], HEX);
}