1

I'm trying to send a UDP message via GPRS service from Raspberry but nothing happens. Here is my code. Any advice? Sorry, but this is my first question on StackOverflow. Thanks

import time
import serial

def receive(ser):
    print("READ:")
    time.sleep(1)
    data_left = ser.inWaiting()
    while data_left > 0:
        received_data = ser.read()              #read serial port
        time.sleep(0.3)
        data_left = ser.inWaiting()             #check for remaining byte
        received_data += ser.read(data_left)
        print(received_data)


ser = serial.Serial("/dev/ttyS0", 9600)
time.sleep(1)
ser.write("AT+CGATT = 1".encode())
receive(ser)
ser.write("AT+CSTT=\"iot.1nce.net\"".encode())
receive(ser)
ser.write("AT+CIICR".encode())
receive(ser)
ser.write("AT+CIFSR".encode())
receive(ser)
ser.write("AT+CIPSTART=\"UDP\",\"100.22.34.22\",8000".encode())
receive(ser)
ser.write("AT+CIPSEND".encode())
receive(ser)
ser.write(("{\"testo\":\"12345\"}" + chr(26)).encode())
receive(ser)
3
  • You might want to clarify what you mean by "UDM" and "UDP" message -- I suspect one or both of these is a typo and may confuse the issue a bit.
    – goldilocks
    Oct 18, 2023 at 15:10
  • yes is a typo. I meant UDP
    – diego n
    Oct 19, 2023 at 15:29
  • Ah, okay. I missed the CIPSTART line, did not realize you could send UDP packets that way.
    – goldilocks
    Oct 19, 2023 at 16:01

1 Answer 1

0

Please check out your power supply. SIM900A needs 5V,2A. If the voltage or current is not sufficient, it will not function.

1
  • The sim900a is powered by a separate PSU at 4V and can provide 60 watt. The sim900a device should work from 3.6 to 4.5V
    – diego n
    Oct 18, 2023 at 14:49

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .