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)
asked Oct 18, 2023 at 14:20
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. Commented Oct 18, 2023 at 15:10
  • yes is a typo. I meant UDP Commented Oct 19, 2023 at 15:29
  • Ah, okay. I missed the CIPSTART line, did not realize you could send UDP packets that way. Commented 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.

answered Oct 18, 2023 at 14:43
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 Commented Oct 18, 2023 at 14:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.