No data received on Arduino/SIM900 Shield

Hi guys. I am a Blynk newbee with an Arduino Uno and a GPRS/GSM SIM900 Shield.

I’ve created my GUI on the Blynk app for iOS, in which I am able to send data from the Arduino IDE to the app’s widget LEDs. However, I want to blink an LED to the hardware but no data seems to be transmitted the other way around (all virtual, digital and analog data).

Anyone who can help with this?

Here is my code:

/*************************************************************
 *************************************************************/
#define BLYNK_PRINT Serial

#define TINY_GSM_MODEM_SIM900

// 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>

int LEDPin;
int PinValue = 11;

WidgetLED led1(V0);
WidgetLED led2(V1);
WidgetLED led3(V2);
WidgetLED led4(V3);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "******************************";

// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[]  = "internet";
char user[] = "";
char pass[] = "";

// Hardware Serial on Mega, Leonardo, Micro
//#define SerialAT Serial1

// or Software Serial on Uno, Nano
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(7, 8); // RX, TX

TinyGsm modem(SerialAT);

void setup()
{
  // Debug console
  Serial.begin(9600);

  // Set GSM module baud rate
  SerialAT.begin(9600);
  delay(3000);

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  modem.restart();

  // Unlock your SIM card with a PIN
  //modem.simUnlock("1234");

  Blynk.begin(auth, modem, apn, user, pass);
  pinMode(PinValue, OUTPUT);
}

//BLYNK_CONNECTED()
//{
  //Blynk.syncVirtual(V5);
//}

BLYNK_WRITE(V5)
{
  LEDPin = param.asInt();
  Serial.print("LED status: ");
  Serial.println(param.asInt());
  if(LEDPin == 1)
  {
    Serial.print("Printing: ");
    Serial.println(LEDPin);
    digitalWrite(PinValue, HIGH);
  }
}

void loop()
{
    Blynk.run();
}

Other infomration:

  1. The Blynk library version you are using.
    V0.4.4.
  2. Android or iOS and the version of the OS.
    iOS 9.3.1
  3. Server type, Local or Cloud based.
    Cloud based
  4. If local server, which version you are using.

  1. How you powering the MCU.
    USB Port from PC
  2. Has the MCU ever connected to a Blynk server (Cloud or local).
    Yes, the connection actually becomes established.
  3. The IDE you are using, including the version number.
    Arduino IDE version 1.8.1
  4. The settings you have in the IDE for the MCU.
    Only the board setting: Arduino Uno
    9.The Arduino core version you are using.
    Arduino Uno
  5. The make and model of your phone.
    iPhone 5s
    11.Your shoe size and anything else you think is important.

I hope this becomes relevant

@Marco_Mkhize please read this thread regarding posting sketches to the forum and not doing anything in loop() other than a Blynk.run() and a call to SimpleTimer() http://community.blynk.cc/t/10000

I have reformatted the code, it is now in the correct structure. And provided more information based on my project implementation. Thanks

Perfect @Marco_Mkhize so we now know what we are working with.
I’ll start by saying I’m not a GSM user and hopefully someone with more experience in this area will be along in due course.

Meanwhile please comment out the 4 led lines in the loop() as this is an absolute no, no for Blynk. You have written lets flash the app LED’s a thousand times a second and even on none GSM hardware it would be a problem.

There is an example called PushData that will teach you the basics of SimpleTimer.

Is V5 a button in the app and is it PUSH or SWITCH mode?

What does Serial Monitor show when you press the button based on the Serial.print() commands you have in the sketch.

I see what you mean with the 4 led’s inside the loop: **removed

V5 is a button that is linked to the Blynk app on the iPhone, I’ve made it become a switch so that I can easily see the the toggling from 0 to 1.

The Serial Monitor only shows the establishment of connection, (network and cloud connection), after that it just shows “Ready [xx ms]”

Using http API should help to ensure that when you tap a button, the command is received by server.

For example, to get the current virtual pin value from server, just run in your browser: http://blynk-cloud.com/<auth_token>/pin/V5

You can also get the whole project and check widget value as it stored on server: http://blynk-cloud.com/<auth_token>/project

Thanks for replying Eugene & Costas.

I have checked these virtual pins under the Blynk-Cloud. The status on the cloud written “value” changes from “0” to “1” as I change the switch button. However, these are not read from the cloud to the Arduino IDE. I’m not too sure at this point if its the SIM900 Shield or the pin extraction in the software…

Okay I got it now, it’s working!!! Thanks guys…

Okay so for some reason you need the

BLYNK_CONNECTED()
{
  Blynk.syncVirtual(V5);
}

function to link the cloud data’s virtual pin status with the software, before utilizing BLYNK_WRITE.

Cool stuff, thanks guys.