Sending codes using 433 on RPi 4 Pi4J v2 #261
Ironarrow78
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
first of all, thank you very much for your "port" from pigpiod to Java.
Currently I am using a RPi4 4GB with RaspianOS and openJDK11 64bit.
I am trying to switch a RCS 1000 N Comfort using Pi4J v2.
I found several examples for switching such a device using Python.
This script works fine for me:
singleapp.py.txt
I used PiScope to check the durations and values of the selected GPIO output.
Now I want to send such commands using Java.
So I have to kill all pigpiod processes and run my IntelliJ IDE as sudo (otherwise I can't open an DigialOutput).
I connected a LED to the 433 MHz sender, so I can see whether the output is set to high or low.
I think that I need to use the pulse method for setting the output to low or high. But in DigitalOutputBAse.java the function pulse checks for TimeUnits.MICROSECONDS and throws an exception.
The duration of the WaveStep is stored in microseconds.
So I tried it my own way:
private void sendWave(Wave wave) { for (WaveStep waveStep: wave.getSteps()) { if (waveStep.getState()==DigitalState.HIGH) { output.high(); } else { output.low(); } try { long nanosTotal = waveStep.getDuration() * 1000; Long millis = nanosTotal / 1000000; Long nanos = nanosTotal % 1000000; Thread.sleep(millis.intValue(), nanos.intValue()); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
But my workaround doesn't work. :-( I am sending the preamble sequence (high for 300 ys, low for 9000ys), followed by the required sequence for the 24 bit 0 / 1 sequence. And all of this will be repeated six times.
I can't use PiScope because the pigpiod service needs to be shut down for using Pi4j. So I can't check the diagram.
Does anyone have an example for sending such a command or any hint what I can do?
Thank you very much in advance.
Best regards,
Rainer
Beta Was this translation helpful? Give feedback.
All reactions