We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

4

Your incoming string, as Gerben has mentioned, will actually be more like: GET /STA/ID=HelloWorld/Pass=Testin123 HTTP/1.1 My personal preferred method is to use strtok() to split the string up. I'd use a two-pass method for this. First split the string up into three parts - one GET, one the request, and the third the request type (though you don't need ...


4

You mention two different error messages. 1. AT+HTTPINIT fail You get +CME ERROR 3. Which means "operation not allowed". This can be due to an improperly closed HTTP setup. If you get this error (or just always do before setting up), call AT+HTTPTERM to be sure that it's closed. 2. AT+HTTPACTION=1 I notice you're trying to do a POSTmessage, while your ...


4

It looks like you did not send the HTTP headers. Before sending any of the HTML content send following lines: "HTTP/1.1 200 OK\r\n" "Content-Type: text/html\r\n\r\n" Make sure you send all the \r\n !


4

As pointed out by Ignacio Vazquez-Abrams and jsotola, you need to use a state machine, like the one from the Blink Without Delay Arduino tutorial. Yours would be slightly more complicated because you need a way to turn it on and off, and because you use different on and off periods. Here is an example code that abstract the blinking logic into three ...


3

The de-facto standard way for devices to broadcast their IP address to clients is through the Multicast DNS system (mDNS). In this system the server sends a UDP message to a specific multicast group address and clients listen for it so they can work out what is where. mDNS is also known as Zeroconf or Bonjour depending on who you talk to. The ESP8266 ...


3

The string "{\"AssetSensorDistance\":\"+st+\"}" contains a literal "+st+". If you want to do string concatenation, you should terminate the string with a double quote character, then add st, then use another double quote to start the second part of the string: "{\"AssetSensorDistance\":\""+st+"\"}"


3

You declare and initialize data as a String in the global space. Then, in loop, you use a bunch of concatenations to build your request string. You never clear the contents of data, but back at the top of loop() on the next round, you concatenate all the string data again, which duplicates it. Side note, the String type is terrible for low-memory devices, ...


3

The getString() method calls writeToStream which is documented write all message body / payload to Stream. It writes all the data of the http response to he output and doesn't store them internally. The next call has nothing to read because the first call to getString() put everything out.


3

HTTP status code 400 means that your request syntax is invalid. Here's a good way to debug it: store the request in a string, print that, and then transmit it. You'd see very quickly at least one of the problems your code has. String request = String("POST ") + url + "HTTP/1.0 \r\n" + "Host: " + host + "\r\n" + "Accept: *" ...


3

You omitted the protocol part of the url. The HttpClient implementation requires it. Use http.begin("http://www.francescosoave.com/blind/getTime.php"); Do not use Content-type header. You do not send any content. Turn-on debug in Tools menu. Set Debug Port to Serial and Debug Level to HTTP_CLIENT to see the error messages.


2

Slightly off-topic, as this is not the source of your problem, but as jBot42 says, you need a proper regulator. When you use a voltage divider, your load (the ESP8266) is connected in parallel with one of the resistors (the 10K one) and effectively changes the output voltage of the regulator. As the consumption of power in the ESP8266 changes (e.g. when the ...


2

See the text from "'HTTP/1.1 200 OK'" until "'DOCTYPE html'" in the following couple of links which say the same, and you might like to read the rest of those pages: https://www.arduino.cc/en/Tutorial/WebServer http://www.allaboutcircuits.com/projects/using-an-arduino-as-a-web-server


2

The Adafruit DHT library causes a shortcut on the signal line. That can be a problem for Arduino boards, but it is a big problem for the ESP8266. Issue: DHT init sequence wrong #48 I don't know what is a bigger problem, the shortcut in the code or Adafruit not fixing it. Why do you mention the Arduino Uno with a label ? For the "GET" you should find a good ...


2

From your comment of Jul 1st, I understand that you can program your server in PHP. Then, and to expand on my own comments, I am only recommending that, whatever Web API you design, you keep it as simple as possible. For example, for telling the Arduino whether it should keep the shutter open or closed, you could write something like this in PHP: header('...


2

I get it now , a stable power source is the answer. arduino with usb can give right amount of Volts but it lacks stable power(amps i guess) while making a TCP connection, that's why module keep restarting.Although it works fine with call, text etc. powering arduino with an AC adapter solves my problem ,now it can connect to mqtt too.Thanks


2

First of all, I would avoid using the String class, because of the memory fragmentation issues that come with it. The most obvious solution is probably to store the result in a character array, then parse the array, with strstr() or sscanf(), to extract the values you want. However, this requires storing the whole response in RAM, which is expensive. A ...


2

Is this project possible without Arduino and just by programming the ESP8266 module? Yes if you use ESP-12 or an esp8266 dev board like Wemos or NodeMCU. The problem could be the current sensor. I would recommend to read it with I2C ADC module, because the esp8266 A0 can read only to 1 V and is shared with WiFi functions. Wemos boards use a circuit to ...


2

Your biggest problem is that you are trying to use a website URL as a FQDN. That's not going to work. When you connect to a remote machine you connect to the name (myname.appspot.com) which gets translated into an IP address for you to open a connection to. When you use a web browser it parses the URL to extract the protocol (http) and the FQDN (myname....


2

Did it heres the code `if (client.connectSSL(server, 443)) { Serial.println("Connected to server"); // Make a HTTP request String PostData = content + volt; Serial.println(PostData); client.println("POST /api/users HTTP/1.1"); client.println("Host: morning-cliffs-85779.herokuapp.com"); client.println("Cache-Control: no-cache"); client.println("Content-Type: ...


2

there are nice functions inherited from Stream class int parseResponse(char uuid[], int size) { if (!client.find("HTTP/1.1")) // skip HTTP/1.1 return -1; int st = client.parseInt(); // parse status code int l = -1; if (st == 200 && client.find("\"uuid\" : \"")) { int l = client.readBytesUntil('"', uuid, size); uuid[l] = 0; // ...


2

Try just using IP address for the Host line instead. I did the same thing for POST and it works fine for me. Example: Host: 13.xxx.xx.xx


2

I got clue from @esoterik answer and manage to send request successfully. The problem were in adding header parameter: http.addHeader("Content-Length", "20"); This duplicate the header( 2nd one added in PUT method). I just comment it and the code works. Thanks for every one response


2

The TinyGSM library implements Arduino networking Client base class over GSM modem's AT commands. The library is available in Library Manager.


1

Another option is Blynk who offer a server, a smartphone app, and a set of libraries and example sketches for Arduino. Also an active and helpful online user community, where the developers participate. The server does not make view-able web pages; its job is to enable the Arduino and the app to communicate with each other. The app lets the user quickly ...


1

I believe the term you want to search on is "web scraping". Assuming you are fine with people knowing the state of "things" in your home, you can simply leave the states up on your public web page. That is, you click on a button on your web page and change the text from "shutter up" to "shutter down". Mean while, your Arduino is "web scraping" the same ...


1

This way it looks more professional but Is it more efficient? No, the differences are minuscule. It's only really the location of any parameters that are different - either as part of the URL (GET) or as part of the body (POST). Is this using websockets? Is using websocket a better way? is it more robust? No, it's just a TCP connection (or maybe UDP ...


1

Your code doesn't work because you start by sending ESP-specific AT commands to open a socket, then you suddenly switch to SIM800-specific AT commands, and the ESP goes "WTF dude?!" I suggest you read some tutorials on accessing web sites with the ESP8266 not with the SIM800.


1

You can't. The factory firmware of Uno Wifi is discontinued. Uno WiFi and WiFi Link doc


1

You are lacking the required blank line between the headers and the content. Also your content length is wrong. Change client.print(postiu.length()); Into client.println(Cadenadatos.length());


1

Have the app send a broadcast UDP packet, and have the ESP listen for such broadcasts. Now the ESP knows the IP address of the device on which the app is running, and it can somehow let it know its own IP address: perhaps connecting to a particular socket on which the app will listen, or sending a UDP broadcast of its own.


Only top voted, non community-wiki answers of a minimum length are eligible