I am trying to use joan's pigpio to write a serial command on my Rpi 3 gpio 14(UART0TX).My goal is to write a command from the pi to another device.

When i send the command i do not see the expected 11111111 on my oscope, nor do i see it on pigpio piscope. After reading some other post about serial issue i also used joan's GPIO MONITOR.

I am wondering if i am just not completely understanding the wave functions or if there is something else wrong?

Here is the relevant parts of my controller script, the send_command() function is what adds my command to the wave and sends it.

import sys
import difflib
import pigpio
import time
import os
from os import system

system('sudo pigpiod')

# rx GPIO pin constants
RX =  15       # 15
BAUD = 9600    # 9600
TX = 17        # NOT builtin gpio 14

#create instance of pigpio class
pi = pigpio.pi()
if not pi.connected:
    os.system("sudo pigpiod")
    pi = pigpio.pi()

pi.set_mode(TX, pigpio.OUTPUT) # set GPIO 14 as an output

def send_command(packet):
        pi.wave_add_serial(TX, BAUD, packet, bb_bits=8) #bb_bits=16
        wid = pi.wave_create()
        pi.wave_send_once(wid)   # transmit serial data
        while pi.wave_tx_busy(): # wait until all data sent
        print('The packet\n{}\n was sent!'.format(packet))
packet = b'11111111'
#packet = b'1'
#packet = '11111111'

here is the output of the wave_get functions:

control blocks: 98 max cbs: 25016 microseconds: 8440 max micros: 1800000000 pulses: 49 max pulses: 12000

if the packet i send is just packet = b'1' instead of packet = b'11111111' the output of the wave_get function is: control blocks: 14 max cbs: 25016 microseconds: 1146 max micros: 1800000000 **pulses: 7** max pulses: 12000 `

I thought sending a simple '1' would on be 1 pulse? the same idea above sending '11111111' i though that would be 8 pulses not 49?

  • Are you trying to use software serial or inbuilt UART? – Milliways Nov 20 '18 at 21:09
  • Have you a small but complete script? If so I can download and run it to see if there is a problem. – joan Nov 20 '18 at 21:09
  • @Milliways I am trying to use software serial. – Zack Jackson Nov 21 '18 at 13:34
  • @joan as for a complete script it would just be the the send_command() function I am using a GUI i built to pass "11111111" as the packet argument so i suppose if you just remove packet from the args and pass '11111111' to wave_add_serial() instead of packet that should do the trick. Milliways mentioned its inadvisable to use the default UART pins, ive noticed in your example scripts you dont use gpio14 either so is that true that I should use a different GPIO? – Zack Jackson Nov 21 '18 at 13:39
  • @joan i added a simple runnable script as per your request. In this version i tried using gpio17 rather than gpio14 as per Milliways suggestion. Using piscope I still am not reading the desired '11111111' data packet. I see the start bit low, the I would expect it to be high for 832usec followed by a stop bit but instead my data packet is a mix of low and high and is longer than i expected. – Zack Jackson Nov 21 '18 at 14:26

It is far from clear WHAT you are trying to do BUT the following code will DISABLE UART (assuming it was enabled in the first place).

self.pi.set_mode(self.RX, pigpio.INPUT) # set GPIO 15 as an input
self.pi.set_mode(self.TX, pigpio.OUTPUT) # set GPIO 14 as an output

You DO NOT read serial from pins but from a serial port. There are thousands of examples of serial use on the Pi.

PS you should use dev/serial0 (which is the default serial port) in all code NOT attempt to second guess what UART is in use.

If you are trying to do software serial it seems inadvisable to use the same pins as the inbuilt UART.

  • I think WHAT im trying to do is explained pretty clearly in my first sentence...."I am trying to use joan's pigpio to write a serial command on my Rpi 3 gpio 14(UART0TX)". I did notice in others code that they never used gpio14 which i thought was strange, I didnt realize it was inadvisable. I will try different pin thanks for taking the time to give me some direction albeit muddled by awkwardly placed emphasis that make you seem more rude than helpful. As for reading serial i dont really need that but from what Ive read there are several examples of people reading serial on a gpio pin. – Zack Jackson Nov 21 '18 at 13:32
  • tried changing from gpio14 to gpio17 this did not fix the issue, interestingly after the change when i run joans gpio monitor i still see activity on gpio14 so i think your correct about not using inbuilt UART , however there are still some problems when using gpio17. joans monitor shows me that there sometimes the timing is 105usec as expected but other times it is double or triple that – Zack Jackson Nov 21 '18 at 13:51

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.