I can’t think of any way that the content of the message could affect the way that the program executes. Copy and paste the exact code that you are using in that region of the program (around the lines that got changed). Use a print statement to print out the value of text_message at that point and at the point where the sending message appears. Change the text to various arbitrary strings to see if you can identify exactly the change that is causing the behaviour (eg, starting from the original and making small changes). Change the text to send literal lat and long instead of the variables. Does SMS have some rules about what text can be sent, such as //, /? or 1& having some special meaning, because that’s what seems to be happening - the error is actually occurring in the interpretation of the response to making the call (send_at()). Can you examine the variable rec_buff in the vicinity of line 81?
Hi there,
I have been following your tutorial today and it has been amazing. The SMS functionality works perfectly, however the GPS functionality gives the same issues as above with the \n+
character. I have been through a few different code editors (I am used to staring at Java code all day) and I have tried various things (pretty much everything except for retyping the code in a fresh file, which I may end up doing if I have free time).
Could you please let me know if the people above fixed their issues and if so how?
The error is the same as the above comments:
SIM7600X is starting:
SIM7600X is ready
Start GPS session…
AT+CGPS=1,1 ERROR
AT+CGPS=1,1 back: AT+CGPS=1,1
ERROR
Traceback (most recent call last):
File “/home/pi/SIM7600X-4G-HAT-Demo/Raspberry/python/python-scripts-4g-waveshare-hat/GPS-Human-Readable-Final.py”, line 115, in
get_gps_position()
File “/home/pi/SIM7600X-4G-HAT-Demo/Raspberry/python/python-scripts-4g-waveshare-hat/GPS-Human-Readable-Final.py”, line 75, in get_gps_position
answer = send_at(‘AT+CGPSINFO’,'+CGPSINFO: ',1)
File “/home/pi/SIM7600X-4G-HAT-Demo/Raspberry/python/python-scripts-4g-waveshare-hat/GPS-Human-Readable-Final.py”, line 51, in send_at
FinalLat = float(Lat) + (float(SmallLat)/60)
ValueError: could not convert string to float: ‘\n+’
If the character is not a part of the code then it must be in a variable. Look at the code in the vicinity of that call to see what variables are being handled at that point, and either uncomment the relevant debug print statements or add your own to examine the values. It is probably a string returned from the GPS which should contain a number but is empty, but is not being checked before it is converted.
Hi Jeff,
I have already had a look through the code and tried to figure it out. I would expect the code to give me an error if it can’t get a GPS location, or did I make the wrong assumption? Any help would be appreciated as I did spend a few hours trying everything I could think of.
When you uncomment the print statement at line 50 (immediately before the error line) what values do you see? You might need to also print the length of those variables or perhaps the hex version of the string, to actually see what the string is. That result will determine exactly which variable you need to track back through the code, and how far back you need to be looking at those values in order to determine the point at which it ought to be valid, but is not. For instance, it should be valid at line 34: if it isn’t then the test at line 24 is not picking up the problem, and that in turn might depend on the correct value for ‘back’ (and so on).
I would not assume that the testing for a valid GPS result is complete - testing for all conditions of N/S or E/W lat and long is difficult if you haven’t travelled to all four corners of the globe! Also just how the receiver will format the data when it can’t get a complete fix is not always predictable.
If you can’t see what the actual problem is, post the code you are using with your debug statements enabled, and the result you get for each one of them.
Hi. I’ve bought the Waveshare SIM7600X, and when I run the PhoneCall.py all I get is quote
SIM7600X is starting:
SIM7600X is ready
ATDxxxxxxxx; ERROR
ATDxxxxxxxx; back:
ERROR
Call disconnected
SIM7600X is loging off:
Good bye
unquote, where the xxxxxxx is my phone number. What am I doing wrong? Yours sincerely Magnus
Hi All
I am a bit late here but might jump in anyway.
Nothing to do with GPS but:
I had a similar problem some time ago with the copy and paste method of producing a sketch. I did just that and it just would not work. I don’t think it compiled but could not be sure now. I just could not see anything different between the sketch I finished up with and the original. I retyped it from scratch and what do you know, everything worked perfectly. No dramas at all. I tend to do this now, especially with short trial sketches.
Cheers Bob
PS. There must be some mysterious hidden non printable characters in there somewhere fouling things up.
Hey Magnus,
Double-check for me that your SIM provider allows for Phone Calls on the specific SIM card you have installed into the SIM7600X. A number of IoT Cards won’t allow phone calls through their system. Also, pop through some images of your hardware/set-up to help me troubleshoot.
Kind regards,
Tim
Hey again. I know for sure that my SIM provider allows for phone calls. It seems to be trouble with the pin code of the SIM because when I open serial monitor at dev/ttyS0 after I hit run it says :
OK
RDY
+CPIN : SIM PIN
The GPS.py and GPS_human_readable.py is working fine. But PhoneCall.py and SMS.py is not working. And both those scripts requires SIM. I have followed Your installation step by step twice. In the beginning of this thread (2)Fredrik has the same issue, and thread 8 describes the AT command. How do I use the AT command? Shall I use it with the AT.py script? Please describe.
The white ribbon cable is for the attached pi camera.
I really want this to work!
Thanks a lot. Magnus
I got the SIM7600-H M.2 and I can’t get any serial connection from a USB TLL UART adaptor. But i can though pins 1 and 0 on an Arduino UNO? Any suggestions?
hi I cant get past this error, please can you help
ERROR:
Can not create output directory: /home/pi/
mike@raspberrypi:~ $ 7z x SIM7600X-4G-HAT-Demo.7z -r -o/home/pi
7-Zip [32] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_GB.UTF-8,Utf16=on,HugeFiles=on,32 bits,4 CPUs LE)
Scanning the drive for archives:
1 file, 688315 bytes (673 KiB)
Extracting archive: SIM7600X-4G-HAT-Demo.7z
Path = SIM7600X-4G-HAT-Demo.7z
Type = 7z
Physical Size = 688315
Headers Size = 5123
Method = LZMA2:24
Solid = +
Blocks = 1
ERROR:
Can not create output directory: /home/pi/
System ERROR:
Permission denied
Hi again Tim!
Problem solved:
enter
sudo minicom -D /dev/ttyS0
in a terminal window, and then enter
at+cpin=xxxxx (where the x’'s represents pin code for sim, 4 digits that is)
and voilla, the net led flashes and the HAT works perfectly fine.
Again, thx a lot.
Magnus
Hi Mike. Change the name of the path from /home/pi to home/mike
I had the same problem. The default username is pi@raspberrypi, but You have changed it to mike@raspberrypi
Kind regards from Magnus
Hey Magnus,
Fantastic effort! Thanks for sharing the solution here as well (and supporting Mike) undoubtedly the success will help many other makers along the way .
Hope all goes super well with your project, a Raspberry Pi connected to the cellular network is a very powerful tool indeed. I’m excited to see what you end up creating.
Kindest regards,
Tim
Hey Freddy,
Here is the exact Wiki for the SIM7600G-H M.2 4G HAT. I believe this to be the exact one that you have - https://www.waveshare.com/wiki/SIM7600G-H-M2_4G_HAT
Double-check for me that you have installed the most recent drivers to it (following that above WIKI will show you exactly how) and check that the DIP Switches on the top of the board are in the right location. From the WIKI → Turn the TX and RX of the DIP switch to the ON side, connect to the computer and other equipment through the USB TO UART module, and perform AT command to debug on the corresponding COM port.
Hopefully that will get you some positive results, double check for me also that the USB TTL UART Adapter is fully operational too.
Kind regards,
Tim
Thanks Tim, I found that the wires needed to connect TX to TX and RX to RX for it to work, and the labels are mirroring the rasp pi
I’ve finally got back to this. I’m using a hologram sim and have everything working but cannot maintain a connection. After modifying the connect script I get this
“Protocol-Reject for ‘Compression Control Protocol’ (0x80fd) received”
then later
“Modem hangup
Connection terminated.”
Minicom doesn’t have any errors.
AT+COPS?
+COPS: 0,0,“Telstra Mobile Hologram”,2
I’ve tried changing CGDCONT=1 to CGDCONT=2 with no change.
Hologram uses Telstra here so I’m wondering whether its a hologram SIM issue? I’m using the twilio guide as I can’t use Tim’s method to test- no voice on hologram sims.
EDIT- Hologram sim has now swapped to Optus and the script has the same issue. I’ve ordered a telstra data sim as I think the hologram sim is the issue
Thanks
Tony
Hey Tony,
Very much look forward to seeing how you progress with the Telstra SIM. It seems like a great approach to me.
Information on AT+COPS can be found here - https://m2msupport.net/m2msupport/atcops-plmn-selection/ - Looks to me like the current SIM you are running with doesn’t require any authentication and Errors out when it tries to do the phone call.
Kind regards,
Tim
It was the Hologram SIM. I’m now on a telstra data sim and minicom now working. Just debugging my scripts now- still have the compression issue but I can now send sms and communicate with at commands
@Tim
Hello Tim,
Would you know whether the USB connection is required? I was hoping to avoid the extra space that is wasted by the USB cable and connection.
Kind regards,
Benjamin Mickler