MadDokK
Posts: 7
Joined: Thu Feb 22, 2024 5:21 pm

Checking Power State & Flow Control for SIMN7600 GPS/4G HAT

Sat Feb 24, 2024 7:49 pm

I wish I could post a topic in more than one board. This could easily go in the HAT or Interfacing board. I've never really done anything with a pi other than load Lakka or RetroPie on it, so using a HAT with Python is very new to me. There is more information on what exactly I'm doing in the other topic I posted. I'm using a Waveshare SIM7600A-H GNSS HAT attached to my Raspberry Pi 3b with the documentation linked here. I've modified the code they provided to give myself a console so I could learn how it all worked. I'm currently focusing on the GPS aspect and have learned a LOT. There are a couple of things I'd like to do and am not sure how to go about it.

First and foremost I would like to be able to check if the SIM7600 HAT is on. I've programmed my code so that I can exit Python while leaving the module on so that I can update the code and start it again. When I do this I have to manually escape the power on method and would like to be able to just check programmatically if it's on.

Also, the provided example code uses the sleep function to wait between pressing the power button in then depressing it along with another 20 second wait for it to power up. It's a bit hackey and I'd prefer to query the HAT to see if it's ready instead of just waiting some set amount of time. It also has an 18 second wait time for the power down, though I'm not sure if that one has a better solution. The Python code I use for the console is linked here.

The documentation describes using flow control and says the SIM7600 default is hardware flow control.
1.6.1 Software flow control (XON/XOFF flow control)
Software flow control sends different characters to stop (XOFF, decimal 19) and resume (XON, decimal 17)
data flow. It is quite useful in some applications that only use three wires on the serial interface.
The default flow control approach of SIM7500&SIM7600 Series is hardware flow control (RTS/CTS flow
control), to enable software flow control in the DTE interface and within GSM engine, type the following AT
Command:
AT+IFC=1,1
Ensure that any communications software package (e.g. Hyper terminal) uses software flow control.
1.6.2 Hardware flow control (RTS/CTS flow control)
Hardware flow control achieves the data flow control by controlling the RTS/CTS line. When the data
transfer should be suspended, the CTS line is set inactive until the transfer from the receiving buffer has
completed. When the receiving buffer is ok to receive more data, CTS goes active once again.
I didn't see anything in their example code that checks the RTS/CTS line. I was going to ask how to do this, but I can find that out on my own. Is this something I should look more into? Everything has worked fine so far, but I've only been receiving GPS data. I've yet to send SMS messages, but again their SMS code doesn't have anything that seems to correspond to this.

Thank you for your time.

ame
Posts: 8960
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Checking Power State & Flow Control for SIMN7600 GPS/4G HAT

Sat Feb 24, 2024 8:23 pm

MadDokK wrote:
Sat Feb 24, 2024 7:49 pm
I wish I could post a topic in more than one board. This could easily go in the HAT or Interfacing board.
No need. In fact it's discouraged as it causes problems with keeping track of answers, and generally confuses everybody. Your message will be seen wherever it is posted.
I've never really done anything with a pi other than load Lakka or RetroPie on it, so using a HAT with Python is very new to me. There is more information on what exactly I'm doing in the other topic I posted. I'm using a Waveshare SIM7600A-H GNSS HAT attached to my Raspberry Pi 3b with the documentation linked here. I've modified the code they provided to give myself a console so I could learn how it all worked. I'm currently focusing on the GPS aspect and have learned a LOT. There are a couple of things I'd like to do and am not sure how to go about it.

First and foremost I would like to be able to check if the SIM7600 HAT is on. I've programmed my code so that I can exit Python while leaving the module on so that I can update the code and start it again. When I do this I have to manually escape the power on method and would like to be able to just check programmatically if it's on.
You could probably send a benign AT command and check if you get an OK response. If you do, it's on. If you don't, it's off. Or broken. Or not connected.
[/quote]
Also, the provided example code uses the sleep function to wait between pressing the power button in then depressing it along with another 20 second wait for it to power up. It's a bit hackey and I'd prefer to query the HAT to see if it's ready instead of just waiting some set amount of time. It also has an 18 second wait time for the power down, though I'm not sure if that one has a better solution. The Python code I use for the console is linked here.
[/quote]
"pressing the power button in then depressing it along with another 20 second wait for it to power up"

This sentence doesn't read very well. Do you mean press the power button then pressing and holding it?

What does the datasheet for the module say? If there is a 20 second startup delay then wait for 20 seconds. Nothing hacky about that.

For power off, unless you really need to have an orderly shutdown for the module you could just not care.
The documentation describes using flow control and says the SIM7600 default is hardware flow control.
1.6.1 Software flow control (XON/XOFF flow control)
Software flow control sends different characters to stop (XOFF, decimal 19) and resume (XON, decimal 17)
data flow. It is quite useful in some applications that only use three wires on the serial interface.
The default flow control approach of SIM7500&SIM7600 Series is hardware flow control (RTS/CTS flow
control), to enable software flow control in the DTE interface and within GSM engine, type the following AT
Command:
AT+IFC=1,1
Ensure that any communications software package (e.g. Hyper terminal) uses software flow control.
1.6.2 Hardware flow control (RTS/CTS flow control)
Hardware flow control achieves the data flow control by controlling the RTS/CTS line. When the data
transfer should be suspended, the CTS line is set inactive until the transfer from the receiving buffer has
completed. When the receiving buffer is ok to receive more data, CTS goes active once again.
I didn't see anything in their example code that checks the RTS/CTS line. I was going to ask how to do this, but I can find that out on my own. Is this something I should look more into? Everything has worked fine so far, but I've only been receiving GPS data. I've yet to send SMS messages, but again their SMS code doesn't have anything that seems to correspond to this.

Thank you for your time.
It is extremely unlikely that you're going to need flow control.
Oh no, not again.

MadDokK
Posts: 7
Joined: Thu Feb 22, 2024 5:21 pm

Re: Checking Power State & Flow Control for SIMN7600 GPS/4G HAT

Sat Feb 24, 2024 11:11 pm

ame wrote:
Sat Feb 24, 2024 8:23 pm
You could probably send a benign AT command and check if you get an OK response. If you do, it's on. If you don't, it's off. Or broken. Or not connected.
As long as that's the way to do it. My research has shown that damaging these components can be done surprisingly easy. It doesn't make sense that sending a command to a component that's off could damage it, but I've seen stranger things. I tried researching the answer and found solutions to identify the hat attached, but nothing to determine the power state.
ame wrote:
Sat Feb 24, 2024 8:23 pm
"pressing the power button in then depressing it along with another 20 second wait for it to power up"

This sentence doesn't read very well. Do you mean press the power button then pressing and holding it?
Yeah, I didn't word that very well. The power on method looks like this:

Code: Select all

def power_on(power_key):
	print('SIM7600X is starting:')
	GPIO.setmode(GPIO.BCM)
	GPIO.setwarnings(False)
	GPIO.setup(power_key,GPIO.OUT)
	time.sleep(0.1)
	GPIO.output(power_key,GPIO.HIGH)
	time.sleep(2)
	GPIO.output(power_key,GPIO.LOW)
	time.sleep(20)
	ser.flushInput()
	print('SIM7600X is ready')
As this is my first real dive into coding and interfacing with Python on a Pi so my understanding here is intuitive. When you physically hit a button there are two actions: you first press the button in before releasing it (what I called 'depress'). I think GPIO.output(power_key,GPIO.HIGH) is like pressing the button in where GPIO.output(power_key,GPIO.LOW) is the release. Two seconds seems like a very long time to be holding the button down. Again, I am being overly cautious here to make sure I don't break anything.

ame wrote:
Sat Feb 24, 2024 8:23 pm
What does the datasheet for the module say? If there is a 20 second startup delay then wait for 20 seconds. Nothing hacky about that.

For power off, unless you really need to have an orderly shutdown for the module you could just not care.
The documentation is inadequate to say the least. I haven't seen anything on that. Maybe this is standard practice, but I've always checked to see if something could be done before doing it. Then again, this is my first time with this.

ame wrote:
Sat Feb 24, 2024 8:23 pm
It is extremely unlikely that you're going to need flow control.
Thank you!

ame
Posts: 8960
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Checking Power State & Flow Control for SIMN7600 GPS/4G HAT

Sat Feb 24, 2024 11:44 pm

I don't think you have enough experience to say whether something doesn't make sense, or seems to be something or other.

The manufacturer's code and documentation is all you have, plus forum posts from people who have or have not got something working. If the demo code works then you're off to a great start.

In your power_on() function, what is the value of power_key? Looking at the documentation it seems like there are two ways of affecting the module's state. There is the module on/off pin, and the flight mode pin. So I'm curious as to which pin this function is controlling. No, I did not download the demo code.
Oh no, not again.

Return to “Python”