Hot answers tagged

5

The "Authorization" is simply an HTTP header. So add it in your request like: http.addHeader("Authorization", token); The value of "token" is just the string "Bearer " followed by your authorization string. Don't neglect the SPACE after the word "Bearer". It will look like: "Bearer eyJhb......" ...


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

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: *" ...


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


4

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.


4

Your line int httpResponseCode = http.POST("{\"amount\":\"total\"}"); is not doing what you think it's doing. You're not placing the contents of the variable called total in the string, you're placing the word total in the string. Instead you need to build up the string from components before sending. I'd use something like: ...


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

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


3

You already received good answer about some general ideas for replacing String objects with C strings. Here I will try to add some more tricks more specifically targeted to your actual situation. I can see two places in your program where the use of String shines by its convenience, and replacing it with C strings will require some effort. The first is the ...


3

Yes, there are systems designed to continuously receive such data and the data exchange is standardized, even some Units are standardized. OPC DA An example is OPC Data Access for real time values. It seems you want to build a graph, so OPC Historical Data Access is more what you're looking for. One would set up the data points on the server side once, i.e. ...


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

Hi all use this code below for establishing HTTP connection with the server. And to neglect the 601 or 504 error use proper posting format. Here I'm using JSON format. I just gave manual data. Ignore those errors in HTTPINIT, AT+SAPBR=2,1. The data will be posted to the server #include<SoftwareSerial.h> SoftwareSerial client(2,3); String reading="{ ...


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

You can use ESP8266Wifi Arduino Library. Here an example: #include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h> const char* ssid = "yourNetworkName"; const char* password = "yourNetworkPassword"; void setup () { Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(1000); Serial....


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.


2

Apparently you were running software serial at too high of a baud rate (57600) and bringing it down to 9600 fixed the issue.


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