Hello community,
I am using 2 ESP32 for testing a One Wire software Serial:
1x az-delivery-devkit-v4 (sends data)
1x esp32-poe-iso (receives data)
The connection is GPIO5 to GPIO5. I check the pin signal by an oscilloscope,
but the receiving board cant read the data.
The sending board sends every 50ms a Byte (0xFA).
What i do wrong?
In SerialMonitor i can only read “NoData”, that means no byte reveices
Code for sending:
#include <Arduino.h>
#include “SoftwareSerial.h”
volatile bool execute; // Trigger
hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
// Code with critica section
void IRAM_ATTR onTime() {
portENTER_CRITICAL_ISR(&timerMux);
execute = true;
portEXIT_CRITICAL_ISR(&timerMux);
}
SoftwareSerial swSer1;
void setup()
{
// Configure the Prescaler at 80 the quarter of the ESP32 is cadence at 80Mhz
// 80000000 / 80 = 1000000 tics / seconde
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &onTime, true);
// Fire Interrupt every 1s (1 million ticks)
timerAlarmWrite(timer, 50000, true);
timerAlarmEnable(timer);
swSer1.begin(4800,SWSERIAL_8E1,-1,5);
}
void loop()
{
if(execute){
char inByte = 0xFA;
swSer1.write(inByte);
portENTER_CRITICAL(&timerMux);
execute = false;
portEXIT_CRITICAL(&timerMux);
}
}
Code for reveiving:
#include <Arduino.h>
#include "SoftwareSerial.h"
SoftwareSerial swSer1;
bool NoData;
char inByte;
void setup() {
// put your setup code here, to run once:
swSer1.begin(4800,SWSERIAL_8E1,5,-1);
Serial.begin(112500);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
}
void loop() {
swSer1.listen();
//Serial.println("Data from port one:");
// while there is data coming in, read it
// and send to the hardware serial port:
while (swSer1.available() > 0) {
inByte = swSer1.read();
Serial.write(inByte);
NoData = false;
}
if(!NoData){
if(inByte == 0){
Serial.println("NoData");
NoData = true;
}
}
}