Hi everyone!
I am facing some problems reading data from mb1040 ultrasonic sensor (see link below) and send it using LoRa.
I managed to read the distance reading in its own script, without sending data via LoRa. I also managed to send random data via LoRa. But, when I combine both I does not read the sensor.
Reading data only:
`#include “Arduino.h”
//const int pwPin1 = 2;
long pulse1, sensor1;
void setup() {
Serial.begin(115200); // sets the serial port to 9600
// pinMode(pwPin1, INPUT);
pinMode(PWM1,INPUT);
}
void loop() {
pulse1 = pulseIn(PWM1, HIGH);
sensor1 = pulse1/147;
Serial.print(sensor1);
Serial.print(" “);
Serial.print(“inch from PWM”);
Serial.println(” ");
delay(500);
}`
Reading data and sending via LoRa in the same script, I include my code in the prepareTxFrame() function. Unfortunately, it does not read the data.
Any suggestion is greatly appreciated.
Thanks very much in advance!
Sensor: https://www.maxbotix.com/Ultrasonic_Sensors/MB1040.htm