How to send HTTP requests with ESP8266 AT COMMAND? - firebase

I want to send HTTP requests to Firebase or Cloudant using AT commands. I'm able to connect to my router and ping to Google:
AT+PING="www.google.com"
+34
OK
For example, in Firebase:
AT+CIPMODE?
+CIPMODE:0
OK
AT+CIPMUX?
+CIPMUX:1
OK
AT+CIPSTART=1,"TCP","https://myapp.firebaseio.com/my_doc.json?mykey",80
ERROR
Or, for Cloudant:
AT+CIPSTART=3,"TCP","https://USERNAME-password#username-bluemix.cloudant.com/estado/doc_estados",8080
ERROR
Is there a way to see what error occurs?
I've seen several examples using Arduino, but I don't want use Arduino.

Related

Problems making a HTTP request with SIMCOM module

For the past few weeks, i have been trying to make a HTTP request on a SIMCOM7080. I'm controlling this module via AT Commands. Every path that i try, ends with an ERROR. Does anyone have experience on getting this module to talk with for example Thingspeak? The link that i have tried is this one:
https://prod-162.westeurope.logic.azure.com/workflows/48fcd3ff69634babaa31ef51f89e2051/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=_4eWTUWPLqk5evTp1014kcntXff4akjlFpQJZo_5dFc
The purpose for this is to eventually connect this to an arduino via a UART connection, and displaying data on an IoT device.
Thanks in advance!
Every path with AT commands ends in an error. I have looked up all the documentation given by the manufacturer but it ends with ERROR.

Connecting Arduino SocketIoClient to NextJs api route

I have a nextJs socket server in pages/api/socket hosted locally and my code is the same as what this article talks about.
My Arduino code is working in ESP8266 like this example from github
Basically, I emit a message event every 500 milliseconds from the Arduino loop and I want to console log that message when received by the nextJs api route but it does not worked for me.
I don't know the exact problem here, but when I tried this, a server using nodeJs and express and socket.io, it does work.
I am thinking that the problem is, in Arduino SocketIoClient, the websocket.begin("192.168.1.4", 3000) will connect to my http://localhost:3000 but my nextJs socket server lives in /api/socket so I added the url as the third parameter that looks like this, websocket.begin("192.168.1.4", 3000, "/api/socket"). But this does not work. NextJs cannot receive the connection from the Arduino.
Can anybody help or explain what is going on here?

Sim7080G module can't send data over TCP while using GNSS

I bought a Simcom (Sim7080G) module to use it for geolocation and send data over TCP. These modules are quite new on the market (it was first launched in mid 2019) and there is some weird functionning with it. I would like to know if people that use it struggle with the same problem.
My goal is to take GNSS (latitude/longitude) informations, and to send them over TCP.
Activate and take GNSS informations
AT+CGNSPWR=1
returns OK
AT+CGNSINF returns +CGNSINF: 1,1,20200517191239.000,4x.xxxxxx,6.xxxxxx,473.769,0.00,,0,,1.9,2.1,1.0,,7,,7.9,6.0
Connect to any TCP server
AT+CNACT=0,1 returns OK\r\n\r\n+APP PDP: 0,ACTIVE
AT+CAOPEN=0,0,"TCP",151.101.1.69,80 (151.101.1.69 is stackoverflow.com ip address)
--> Some time waiting (like +40s) and then:
+CAOPEN: 0,23\r\n\r\nOK
The code 23 means: 23 Remote refuse, but in my case the connection never reached the server.
Only GNSS or TCP can be used, but not both
What is weird about all of this, is the fact that I can connect on a TCP server, but this stops to work when I activate GNSS.
I sent an email to Simcom technical support.
After insisting that my problem be addressed by a Simcom engineer, I received an answer. I encouraged them to be more clear on their documentation because this information was nowhere (this module is pretty new so I think they missed it on documentation).
Hope to help somebody in the same way or not to do the same pricey error:
Hi Dardan,
"it is not possible to use GNSS and TCP at the same time"
This is known limitation for this module, as there are limitation for
LTE and GNSS part, they can not run simultaneously because they are
sharing part of RF components(SIM7070G low cost version of SIM7000G)
so it is time MUX for LTE and GNSS which means the GNSS performance
could not be good(if customer needs to send GNSS data to server in
very short interval such as <10 seconds), for SIM7000G LTE and GNSS
can work simultaneously without problem. so SIM7070G could be a good
solution for "parcel tracking" etc, which do not need the continue
navigation. please go for SIM7000G, thanks.
xxxx Sun
I found this issue some hours before read this post. My product publishs in AWS IoT MQTT broker; it works, but I need the GPS coordinates to be sent together in message. I'm a lot frustrated, because such problem should be said in Simcom's documents. My previous version was using sim7600g, more expensive, but works fine. I live in Brazil, everytime I need to test some different module I loose more than 1 month to buy from China or somewhere and arrive a new one to me. I tried to turn ON/OFF GNSS and the TCP conection in alternate way, but is too slow the process to reconnect on gsm network.
Ran into this as well. With MQTT it is possible to power down the GPS unit to be able to send and receive MQTT messages without reconnecting/subscribing to the broker again. I've made a 30 second interval to enable/disable the GPS unit and tested it with HiveMQ public broker. Receiving of position data every 60 seconds is possible with this setup, which might be sufficient for some applications. For the price, it has this is still a good module.
I receive no response for HTTP Get request for the http://httpbin.org/get URL. Following is the output using the AT Command Tester from https://m2msupport.net
Checking registration status...
AT+CREG?
+CREG: 2,1,"912","3D73",0
OK
The device is registered in home network.
AT+CGREG?
+CGREG: 2,1,"912","3D73",0,"1"
OK
The device is registered in home network.
Device is registered..
Check the network APN...
AT+CGNAPN
+CGNAPN: 0,""
OK
Network did not send APN to the device.
Activate the network bearer...
AT+CNACT=0,1
OK
+APP PDP: 0,ACTIVE
Set up the HTTP URL...
AT+SHCONF="URL","httpbin.org"
OK
Set up the HTTP body length...
AT+SHCONF="BODYLEN",1024
OK
Set up the HTTP header length...
AT+SHCONF="HEADERLEN",350
OK
Initiating HTTP connection...
AT+SHCONN
OK
Get the HTTP connection state...
AT+SHSTATE?
+SHSTATE: 1
OK
HTTP connection is successful...
HTTP get request...
AT+SHREQ="http://httpbin.org/get",1
OK
No reponse received..

esp8266 with arduino uno getting bad request

I am developing an arduino project in which i have to send some data on internet to my server.
but the problem is that i am always getting bad request (HTTP 400).
i have both php & asp.net servers available but neither of them are accepting the connection I am Using The Command Below On ESP8266 To Send The Data
GET /update?data=test HTTP/1.1\r\nHost: mydomain.com\r\n\r\n
I found out that i have to send some more headers but i dont know how to send those headers.Please Help.
Thank You
I'm not absolutely sure that there is mandatory headers but I usually add a few more. My usual requests are like that :
GET /update?data=test HTTP/1.1\r\nHost: mydomain.com\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n
Hope this helps.

sending HTTP requests obtained from WireShark

I have an app controlling my AVR on a local network and I'm trying to embed some of the functionality into another app written by myself. I've started up WireShark and started controlling the volume, which shows up as:
GET /ctrl-int/1/setproperty?dmcp.device-volume=-15.750000 HTTP/1.1
I'm not totally up on this type of http control but i'd like to know if this is enough data to be able to send the same request via a browser or terminal etc.
cheers
Without knowing the avr you can't realy tell. But you should be able to send the command via
avr-ip/ctrl-int/1/setproperty?dmcp.device-volume=-15.750000
in the browser or from you app. The ip should be in the wireshark logs as well.
If that works it was enough information.

Resources