SIM800L and rp2040-zero echoes commands back

January 28, 2024, 02:40

jannik44

I have a sim800l connected via uart to the pi and wrote a sample micropython code to test it, but the weird thing is that it just replies with the same command instead of executing it, in the documentation of it ive read something about echo mode, could that be an issue? https://cdn-shop.adafruit.com/datasheets/sim800_series_at_command_manual_v1.01.pdf even if i just send pizza' to it it replies with b'pizza', same thing with the AT commands (see code below), any ideas what im doing wrong?
py
from machine import UART, Pin
import time
uart = UART(1, baudrate=9600, tx=Pin(4), rx=Pin(5))
uart.write('pizza')
time.sleep(0.1)
response = uart.read()
print(response)

oops.se

And if you send only AT you should get a reply OK

jannik44

if i only send AT i get b'AT' back instead of OK 🤔

oops.se

No, you should get "OK"

jannik44

i know, this is so confusing

oops.se

Connect a serial adapter directly to the SIM800 to check it

oops.se

I have worked with the SIM800L but a couple of years ago most 2G nets was decommisioned in Sweden so I don't have any anymore

jannik44

here in Germany GSM and GPRS will stay operational for a year or two so it should be fine, but i have already 4g modules on the way, they are like 4 times as expensive

oops.se

I know

jannik44

dont have one, where can i get that

oops.se

USB Serial adapter, they are everywhere, amazon, ebay and ...

jannik44

alr

oops.se


oops.se


oops.se

That is two types that would suit your needs

jannik44

okay, ordered one 👍

oops.se

Nice

jannik44

what else could be the issue? is the code wrong?

oops.se

Me python serial.... I uses a lib when I have done serial to network devices (Cisco)

oops.se

So yes it could be

oops.se

What about using this as a starter https://pypi.org/project/sim800l-gsm-module/

oops.se

I think I know what the issue is with the code, you don't send '\r\n', so it should look something like this uart.write('pizza'+'\r\n')

jannik44

tried uart.write('AT'+'\r\n') and the reply is
b'AT\r\n'

jannik44

will try another module probably its faulty

jannik44

alr, changed module, module is ok

jannik44

tried another tutorial, used this code:
py
import machine
gsm = machine.UART(1, 115200)
gsm.write('AT\r')
print(gsm.read())
https://www.youtube.com/watch?v=uKGD9oKQJSs but still, i followed it 1:1 and still same result

oops.se

I wished I had my SIM800L modules ...

jannik44

i finally managed to do it! and the problem was so simple😁: gsm = machine.UART(1, 115200) the baud rate was set to 9600, perhaps it missed the first message because it listened to a different one before it switched, timeout would probably also work

oops.se

Thats strange, the SIM800 module is autosensing on baud by default, but perhaps yous has been loocked to 115200