Advertisement
microrobotics

USR LTE Industrial IoT Module WH-LTE-7S1-E

May 23rd, 2023
2,138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. The USR LTE Industrial IoT Module WH-LTE-7S5 is an LTE modem that can be interfaced with a microcontroller, such as Arduino, over a serial interface (UART). It can be used to connect your Arduino to the internet over a cellular network. You would typically use it for sending/receiving data to/from cloud-based services.
  3.  
  4. Below is an example code snippet of how you might interface with this device using an Arduino. In this example, the modem is used to establish a network connection, then it makes an HTTP GET request to a web server.
  5.  
  6. Please note, you'll need a valid SIM card with a data plan from a mobile network operator.
  7.  
  8. Please replace "YOUR_OPERATOR_NUMBER" and "YOUR_APN" with the operator number and APN (Access Point Name) specific to your mobile network operator and data plan.
  9.  
  10. This is just a simple example to give you an idea of how to use the WH-LTE-7S5. Depending on your exact use case, the commands you need to use might be different. For a complete list of commands that the WH-LTE-7S5 supports and more detailed instructions on how to use them, you should refer to the WH-LTE-7S5's user manual or other official documentation.
  11.  
  12. Finally, the SoftwareSerial library used in this example is not the most reliable for communication with devices like this, especially at higher baud rates. If you're using an Arduino model that has more than one hardware serial port (like the Arduino Mega), you should use one of those instead of SoftwareSerial.
  13. */
  14.  
  15. #include <SoftwareSerial.h>
  16.  
  17. SoftwareSerial mySerial(10, 11); // RX, TX
  18.  
  19. void setup()  
  20. {
  21.   Serial.begin(9600);
  22.   mySerial.begin(9600); // Change this to the baud rate of your module
  23.  
  24.   // Give the module some time to initialize
  25.   delay(5000);
  26.  
  27.   // Connect to the cellular network
  28.   mySerial.println("AT+COPS=1,2,\"YOUR_OPERATOR_NUMBER\"");
  29.   delay(5000);
  30.  
  31.   // Set up the APN for your mobile network operator
  32.   mySerial.println("AT+CGSOCKCONT=1,\"IP\",\"YOUR_APN\"");
  33.   delay(5000);
  34.  
  35.   // Setup a HTTP GET request
  36.   mySerial.println("AT+SHCONF=\"URL\",\"http://example.com\"");
  37.   delay(2000);
  38.  
  39.   mySerial.println("AT+SHCONF=\"BODY\",\"\"");
  40.   delay(2000);
  41.  
  42.   mySerial.println("AT+SHCONF=\"HEADER\",\"Content-Type: application/json\"");
  43.   delay(2000);
  44.  
  45.   mySerial.println("AT+SHCONN");
  46.   delay(2000);
  47.  
  48.   mySerial.println("AT+SHSTATE?");
  49.   delay(2000);
  50. }
  51.  
  52. void loop() // run over and over
  53. {
  54.   if (mySerial.available())
  55.     Serial.write(mySerial.read());
  56.   if (Serial.available())
  57.     mySerial.write(Serial.read());
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement