Send message from website to SIM900 without SIM900 HTTP REQUEST - http

At the moment I'm working with the Arduino and SIM900, well, I could say I'm intermediate with the SIM, I could accomplish sending data to my website and receiving data from another phone. But now I would need that when I press a toggle button on my website it will send a message to the SIM900, for example, If I check the button it will send 1 if uncheck it, it will send 0. The problem is, I don't know how to start, I already searched up how to send data to the SIM900, But what I always get is the SIM making a request to the server, I would need the server to send the message whenever it is pressed, without the need of the SIM to keep making requests. Will I need an API for this? Please Help

Your phone (client) is behind a NAT. To reach it, you should read about NAT Traversal tactics, which will enable you to push a message to a client.
You can achieve that with Socket.IO or MQTT.
Your server will have a piece of code that the client should connect to when it's up, and the server will maintain the connection alive so that the server can push messages over this connection.

Related

How to retrieve remote client IP address esp32 soft AP mode

My goal is to retrieve the IP address of client connected to an esp32 in soft Access Point mode WITHOUT client sending a request.
So far calling "remoteIP()" method from "client" object seems to be the only way I can successfully retrieve connected client IP is when an HTTP request is made.
If I call "client.remoteIP()" before the remote client sends an HTTP request I get
All zeros, yikes.
Currently I'm polling the "softAPgetStationNum()" method from "WiFi" object and I'm alerted as soon as a device is connected or disconnected.
I would like to get the client IP along with the new connection alert.
My advanced apologies for not including my code hopefully my description has enough clarity to properly relay my intended objective. Thanks
Ps- if I could get guidance on retrieving MAC of remote client too that would be dope!
I don't know what interface Arduino has built on top of Espressif's framework, but the underlying ESP IDF v4.3 has functions esp_wifi_ap_get_sta_list() which gives you a list of all connected stations (including MACs) and esp_netif_get_sta_list() which maps this list of clients to their IP addresses.

How let two ESP8266's listen to the same Telegram bot

How do I let two ESP8266's in my home network listen to the same Telegram bot (the same chat_id) at the same time? I am using bot.getUpdates on both ESP's to check for new messages now, but then only the ESP which happens to perform a getUpdates before the other ESP does, receives the new messages. The second ESP receives none. So I think I need to use something besides, or in stead of, getUpdates but I don't know what.
What I would like to achieve is that one ESP (device 1) must only receive and respond to messages which are addressed to him, based on the message text: "1" on the first position of the message text means it's meant for device 1. Messages which don't start with "1" (they'll start with "2") are not meant for him must stay available on the Telegram server for the other ESP (device 2).
More details about the project:
I have a simple ESP8266 project running fine. When the frontdoor of my house opens, a reedcontact opens and a message is sent from the ESP in my home network to my Telegram bot and then I receive a notification in the Telegram app on my phone saying that door 1 has opened. The other way around, when I type "1" in the app, the bot returns the current state of the door. But when I add a second ESP8266 to control the backdoor (door 2), the problem starts: there is one random ESP which receives the messages. which may not be the ESP/door I am asking for.
I am using:
Arduino IDE
clone nodemcu ESP8266 (ESP-12E)
clone wemos d1 r1
Use the offset parameter of getUpdates method. As the documentation states:
By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.
You need to pass the last update_id through your ESP8266s, but this is kind of tricky.
I advise you to build a central system (or a master-slave system) that reads and processes the updates from Telegram and sends to the two ESP8266s the relative commands (like "open the door 1", etc...). In my opinion this is the easiest way to do what you want to do.
Would it be easier to have one bot for the frontdoor and one for the backdoor?
They can both send messages and you can send a command to the respective bot to get the state of the door.

specifying connection on ESP8266 with AP and STA modes

I want to try to set up an ESP8266 (using the Arduino IDE) to occasionally connect to a wifi SSID to send telemetry back. I also would really like to be able to have it running a softAP for configuration/settings purposes. (i.e. so if you want to change internal settings in your code, you can connect directly to the device to access a web form to do so)
The problem is, I am not 100% sure how I know which is which when making an outgoing telemetry json query. I want it to go out on the STATION mode connection. Presumably in most cases the AP mode won't be connected, but there may be rare instances where both are connected at the same time. Thus how do I tell the device to specifically use the STA side of things when it needs to send data back over the internet?
I can't even seem to find any specific examples to ask if one or the other is connected. (you can poll WiFi.status() but - which one is it reporting?)
Any help is appreciated

Modem GPRS indicates be connected but doesn't receive or send any data

I'm implementing an application that sends data to a server and also receives. So, to always be able to receive data, I choosed keep it always connected. To get this, I use GL865 Telit modem into the client. It's configured using TCP.
The problem I have is that sometimes the modem socket status indicates that it is connected, also, when I send data it says that is OK but nothing is arriving on server and, when I send data from server to client, it doesn't receive too.
I'm testing sending data every 1 second. Many minutes after it begins to loose data, it becomes to result error at sending data and later indicates that there isn't a connection with gprs.

Access COMPORT 1 through three different applications

I have an SMS Appliaction, which receives the messages through GPS Modem and revert back through GPS Modem. The Modem is using COM1.
Now, i need two more appliactions which can send messages through the same GPS Modem. I tried making a webservice which can access the COM1 to send data, but when i try to connect through webService, it throw an error saying, 'COM1 is already occupied, Access denied.'.
Can anybody help me to connect through the modem in above scenario.
Khushi
You have to make sure only 1 connection is made.
Easiest (and most low-tech, but probably most flexible) is having a script checking a directory for files regularly and sending the messages in the file to the modem. The webservice then just writes a file for every SMS it received. (this can be trivially extended to accept emails, web requests, etc, ...)
A bit more sophistacated is to start a thread to do the communication and push the messages on a FIFO like datastructure provided by your favorite programming platform. A BlockinQueue would be perfect. The thread reads the messages from the queue and sends them to the GSM modem.
If you want to have confirmation the SMS is sent (which in my experience does not mean anything and certainly not that the recipient actually received it) you'll need to find a way to return feedback to the caller. This can be as simple a setting a boolean flag in the message to sending another message or performing a callback. But I would not bother. I had situations where 30% of messages dissapeared even when we had confirmation of the message central.

Resources