Open Luke050 opened 3 years ago
I'm having the exact same issue. There is no serial data being sent to the hat. I have attached my logic analyser and tested with the sample code from pyserial:
`>>> import serial
ser = serial.Serial('/dev/ttyUSB0') # open serial port print(ser.name) # check which port was really used ser.write(b'hello') # write a string ser.close() # close port`
and I can see that is being transmitted, the RX led flashes and the LA shows the "hello" in binary form.
Using the examples from the readme neither of the LEDs flash and I don't see any data on the TX/RX lines.
Further trial and error, I am using the code:
gsm = GSMHat('/dev/ttyS0', 115200)
Number = '+MYNUMBER'
Message = 'Hello mobile world'
# Send SMS
print("Sending: "+Message+" - To: " + Number)
gsm.SMS_write(Number, Message)
where MYNUMBER is actually my phone number. I added the print statement to check it was running and in the debug log I get:
2021-10-16 11:11:07,161 - gsmHat.gsmHat - INFO - Worker started
2021-10-16 11:11:07,167 - gsmHat.gsmHat - DEBUG - Sent to hat: AT+CMGF=1
if I remove the print statement I just get:
2021-10-16 11:09:44,879 - gsmHat.gsmHat - INFO - Worker started
So with the print statement the script is doing something but looking at the logic analyser it is showing the Pi transmits "AT+CMGF=1" with a line feed, the Hat then replies "AT+CMGF=1"CRLF"OK"CRLF
It doesn't seem the script is sending the actual text data to be sent?
Forgot to say I am using Raspberry Pi Lite OS (latest off of the RPi site at time of writing) and using a Pi Zero W
Right I have found the problem! Basically you need the script to keep on running long enough for it to actually send the instructions to the HAT. So taking my test code:
Number = '+MYNUMBER'
Message = 'Hello mobile world'
# Send SMS
print("Sending: "+Message+" - To: " + Number)
gsm.SMS_write(Number, Message)
and adding a while true loop at the end:
Number = '+MYNUMBER'
Message = 'Hello mobile world'
# Send SMS
print("Sending: "+Message+" - To: " + Number)
gsm.SMS_write(Number, Message)
while(True):
a=0
will make the system actually send the message! At the moment it seems as long as your code is designed to run on an infinite loop (or at least run a few commands after the 'gsm' request, then it should send.
So @Luke050 it would seem all you need to do (assuming you still have the issue) is get the code to continue working after your request to call a number.
I had the same problem, but with the while loop i could not get the program to finnish so I just added the time function an set it to sleep for 5 sec. time.sleep(5) instead
I have installed your module correctly. My sim card is in HAT and it works (LED is on every 3 seconds).I turned on ttyS0 and I know it works.
when i execute your sample script:
but nothing happens after that.
i did some testing. and I can see that while executing this script
AT+CMGF=1
is written to/dev/ttyS0
and then get the answerOK
but nothing else. each time it executes the script (SMS or call) there is onlyAT+CMGF=1
OK
so i installed minicom and when it executes the call command directly call/ Hang up works :
minicom -D /dev/ttyS0
ATD+some_number;
OK
ATH
OK
log: