433MHz sender support #127
Replies: 3 comments
-
I think the only possibility here is busy waits with Thread.onSpinWait(); see https://github.com/mattjlewis/diozero/blob/main/diozero-core/src/main/java/com/diozero/util/SleepUtil.java#L92 I can knock up the most efficient example tomorrow. |
Beta Was this translation helpful? Give feedback.
-
Once Matt comes back with his example, I would also suggest you're using the |
Beta Was this translation helpful? Give feedback.
-
Which pigpio API are you using from Python? I assume the python app isn't directly controlling the GPIOs but invoking a pigpio API such as wave_create. The most efficient pure diozero code would be something like this: import java.util.concurrent.locks.LockSupport;
import com.diozero.internal.spi.MmapGpioInterface;
import com.diozero.sbc.DeviceFactoryHelper;
public class Rf433Sender {
public static void main(String[] args) {
int gpio = 26;
int iterations = 10;
int delay_ns = 300_000;
try (MmapGpioInterface mmap_gpio = DeviceFactoryHelper.getNativeDeviceFactory().getBoardInfo()
.createMmapGpio()) {
for (int i = 0; i < iterations; i++) {
mmap_gpio.gpioWrite(gpio, false);
LockSupport.parkNanos(delay_ns);
mmap_gpio.gpioWrite(gpio, true);
LockSupport.parkNanos(delay_ns);
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am new to your library and I have a problem using a 433MHz sender.
I am using a Raspberry Pi 4 running the pigpiod service. From an python app I can send the commands to pigpiod to power on and off the 433MHz receiver (RCS 1000 N Comfort).
When I am using piscop, I can see the high / low signals and durations and they match exactly to the values I used in the python app (300µs or longer).
Now I am trying to use the dizero JAVA library to send the same commands. But it is not possible to me to send signals exact 300µs or exact 900µs. Sometimes they are 340 µs sometimes 330µs.
I used the SleepUtil.sleepNanos to set the microseconds as nanoseconds, but as described in the library "Note that the accuracy of the sleep is not guaranteed". :-(
I have already tried the pi4j library, but they protected their library for using microseconds as an interval Timeunit.
So I tried the dizero library, but it is not possible for me to interrupt the application / thread for an exact short duration. So the signals won't match to the receiver and the reciver doesn't switch.
Is there any examples for setting an output (class LED) 300 microseconds to high, then 900 seconds to low, 900 seconds high, 300 seconds low ect? (Depending on the signals I have to send)
Or is there any other way I should use?
Thank you very much in advance,
Rainer
Beta Was this translation helpful? Give feedback.
All reactions