Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#define BLYNK_PRINT Serial
- // Select your modem:
- #define TINY_GSM_MODEM_SIM800
- //#define TINY_GSM_MODEM_SIM900
- //#define TINY_GSM_MODEM_M590
- //#define TINY_GSM_MODEM_A6
- // Default heartbeat interval for GSM is 60
- // If you want override this value, uncomment and set this option:
- //#define BLYNK_HEARTBEAT 30
- #include <TinyGsmClient.h>
- #include <BlynkSimpleSIM800.h>
- // You should get Auth Token in the Blynk App.
- // Go to the Project Settings (nut icon).
- char auth[] = "YourAuthBlynk";
- // Your GPRS credentials
- // Leave empty, if missing user or pass
- char apn[] = "Internet";
- char user[] = "";
- char pass[] = "";
- int voltage1, voltage2;
- unsigned long voltage3;
- String pesan;
- // Hardware Serial on Mega, Leonardo, Micro
- //#define SerialAT Serial1
- // or Software Serial on Uno, Nano
- #include <SoftwareSerial.h>
- SoftwareSerial SerialAT(A2, A3); // RX, TX
- TinyGsm modem(SerialAT);
- BlynkTimer timer;
- WidgetTerminal terminal(V2);
- BLYNK_WRITE(V2);
- void setup()
- {
- // Debug console
- Serial.begin(9600);
- delay(10);
- // Set GSM module baud rate
- SerialAT.begin(38400);
- delay(3000);
- // Restart takes quite some time
- // To skip it, call init() instead of restart()
- Serial.println("Initializing modem...");
- modem.restart();
- // Unlock your SIM card with a PIN
- //modem.simUnlock("1234");
- Blynk.begin(auth, modem, apn, user, pass);
- timer.setInterval(1000L, sendUptime);
- }
- void loop()
- {
- Blynk.run();
- timer.run();
- }
- void sendUptime(){
- voltage1 ++;
- voltage3 ++;
- voltage2 = voltage1;
- pesan = String("Terjual: ") + voltage3;
- if ( voltage1 == 100)voltage1 = 0;
- if ( voltage3 == 1000000) voltage3 = 0;
- Blynk.virtualWrite(V0, voltage1);
- Blynk.virtualWrite(V1, voltage2);
- terminal.println(pesan);
- terminal.flush();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement