On SMS Received
This block is triggered when an SMS message is received. Use it to handle text message commands and notifications from mobile phones.

Overview
The On SMS Received block detects incoming SMS messages on cellular-enabled devices, allowing remote control and monitoring via text messaging.
Configuration
- Filter: Optional phone number or keyword filter
- Output: Variables to store message details (sender, content, timestamp)
Message Information
Access SMS message details:
- Sender: Phone number of sender
- Content: Message text
- Timestamp: When message was received
- Encoding: Text encoding (GSM-7, UCS-2)
Use Cases
Common SMS reception scenarios:
- Remote device control commands
- Emergency shutdown triggers
- Configuration updates
- Status query requests
- Alert acknowledgments
- Two-factor authentication
- Backup communication channel
Message Filtering
Filter incoming messages:
By Phone Number
Only process messages from authorized numbers
By Keyword
Trigger on specific command words
By Pattern
Match message format or structure
Use Comparison blocks to implement filtering.
Command Processing
Parse SMS commands:
SMS: "STATUS"
Response: Send device status
SMS: "REBOOT"
Action: Restart device
SMS: "SET TEMP 22"
Action: Update temperature setpoint
Security
Secure SMS handling:
- Whitelist: Only accept from known numbers
- Keywords: Require secret keywords
- Confirmation: Send acknowledgment SMS
- Logging: Log all received commands
Never trust SMS content without validation.
Response
Respond to SMS with SMS Send:
- Acknowledge command received
- Return status information
- Report action results
- Send error messages
Message Parsing
Parse SMS message content:
- Split into words/tokens
- Extract command and parameters
- Validate format
- Handle malformed messages
Character Encoding
Handle SMS encoding:
GSM-7
- Standard 7-bit encoding
- 160 characters per message
- Basic Latin characters
UCS-2
- Unicode encoding
- 70 characters per message
- All languages supported
Multi-Part Messages
Handle long messages:
- Messages > 160 chars split into parts
- Automatic reassembly
- May arrive out of order
- Consider character limits
Costs
Consider SMS costs:
- Charges per message sent/received
- Roaming charges
- Data plan vs. SMS plan
- Monitor usage
Network Requirements
SMS requires:
- Active cellular connection
- SIM card with SMS service
- Network coverage
- Active cellular account
Integration with Features
SMS integrates with:
Related Blocks
- SMS Send: Send SMS messages
- Comparison: Filter and parse messages
- Variable Set: Store message data
Example Flows
Status Query
1. SMS "STATUS" received
2. Read sensor values
3. Format status message
4. Send SMS response
Remote Control
1. SMS "TURN ON PUMP" received
2. Validate sender number
3. Set pump variable to ON
4. Send confirmation SMS
Alert Acknowledgment
1. Device sends alert SMS
2. Operator replies "ACK"
3. On SMS Received triggers
4. Clear alarm state
5. Log acknowledgment
Error Handling
Handle SMS errors:
- Invalid sender: Ignore or log
- Malformed message: Send error response
- Unknown command: Reply with help text
- Action failed: Send failure notification
Performance
SMS considerations:
- Messages may be delayed
- Not real-time communication
- Consider latency in design
- Use for non-critical commands
Alternative Communications
SMS complements:
Use SMS as backup when data connection unavailable.
Regulatory Compliance
Consider regulations:
- Opt-in requirements
- Message content restrictions
- Spam prevention
- Privacy laws
Troubleshooting
Common SMS reception issues:
- Messages not received: Check cellular signal and SIM
- Garbled messages: Check encoding support
- Delayed messages: Normal for SMS, check network
- Missing parts: Multi-part message issues