Arduino and SMS notifications
how to use Arduino and smsAPI service to send sms messages
This project show how to use Arduino and smsAPI service to send sms messages when motion is detected.
Connection diagram:
usually sending SMS in Arduino using the GSM module.
but author use smsAPI that can send sms without GSM module.
he used this company's API(link).
The company gave API key to him, so he can send the sms.
This sms API is only free in 50 text message, after that you should pay.
When I searched for Korean SMS API solution companies, there were many companies.
They supported not only SMS but also messengers such as Kakao Talk.
this is arduino code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <Ethernet.h>; #include <SPI.h>; byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x01 }; EthernetClient client; int czujnik =7; int val = 0; void setup() { pinMode(10, OUTPUT); pinMode(7, INPUT); Serial.begin(9600); if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); } } void loop(){ digitalRead(czujnik); val=digitalRead(czujnik); Serial.println(val); if (digitalRead(czujnik)==1){ digitalWrite(10, HIGH); } else { digitalWrite(10, LOW); } if(val>0){ if (client.connect("www.xxx.xx",80)) { //adres serwera client.println("GET /nazwapliku.php HTTP/1.1"); //nazwa pliku client.println("Host: www.xxx.xx"); // SERVER ADDRESS HERE TOO client.println("Connection: close"); } if (client.connected()) { client.stop(); // DISCONNECT FROM THE SERVER } } else{ Serial.println("brak danych do wyslania"); delay(300); } } |
this is PHP script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <?php require_once 'smsapi/Autoload.php'; $client = new \SMSApi\Client('login/email'); $client->setPasswordHash('hasłomd5'); $smsapi = new \SMSApi\Api\SmsFactory(); $smsapi->setClient($client); try { $actionSend = $smsapi->actionSend(); $actionSend->setTo('numer telefonu na ktory ma zostac wyslana wiadomosc'); $actionSend->setText('tekst wiadomosc'); $actionSend->setSender('INFOSMS'); //Pole nadawcy lub typ wiadomość 'ECO', '2Way' $response = $actionSend->execute(); foreach( $response->getList() as $status ) { echo $status->getNumber() . ' ' . $status->getPoints() . ' ' . $status->getStatus(); } } catch( \SMSApi\Exception\SmsapiException $e ) { echo 'ERROR: ' . $e->getMessage(); } ?> |
It is interesting that SMS transmission was burned using SMS API rather than GSM module, that's why I think this UCC is special.



