2

I am trying to send a value from Arduino to a remote MySQL. I am following this tutorial.

I have tried but no data is received on the server. What is the issue? I am new to Arduino. My code is:

int led1=8;
int count=1;
void setup() {
 pinMode(led1, OUTPUT);
 delay(3000);
 // initialize serial communication at 9600 bits per second:
 Serial.begin(115200);
 Serial.println("AT+CWMODE=1");
 delay(1000);
 Serial.println("AT+CWJAP=\"mhboys\",\"mhboys123\"");
 delay(1000);
}
// the loop routine runs over and over again forever:
void loop() {
 digitalWrite(led1,HIGH);
 // turn the LED on (HIGH is the voltage level)
 delay(1000); // wait for a second
 if(digitalRead(led1)==LOW) {}
 if(digitalRead(led1)==HIGH) {
 count++;
 //code for sending updated count to mysql
 }
 digitalWrite(led1, LOW);
 // turn the LED off by making the voltage LOW
 delay(1000); // wait for a second
 int adjustedValue = count;
 // print out the value you read:
 Serial.println("AT+CIPSTART=\"TCP\",\"www.onemediagroup.in\",80");
 delay(1000);
 Serial.println("AT+CIPSEND=66");
 delay(1000);
 Serial.print("GET /energy/getUsage.php?currentValue=");
 Serial.print(adjustedValue);
 delay(1000);
 Serial.println("AT+CIPCLOSE");
 digitalWrite(13, HIGH);
 delay(100000); // delay in between reads for stability
}
dda
1,5951 gold badge12 silver badges17 bronze badges
asked Apr 30, 2017 at 18:00
3
  • You must post your code. We cannot tell what you are doing wrong unless you show your work. Commented Apr 30, 2017 at 18:07
  • I am not getting any data in my server. Commented Apr 30, 2017 at 18:09
  • The wifi module does not blink the blue light. Is it any issue? Commented Apr 30, 2017 at 18:09

1 Answer 1

2

You're sending commands blindly without checking if they actually succeeded. If you're not ready to correctly handle the responses, you're better off using a library like this. The 'HTTP GET' example should help.

answered May 1, 2017 at 5:02

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.