Hey guys, I need to create an app by app inventor. It should be able to receive strings from Arduino via ESP8266.
I need an app inventor extension of the WiFi module.
I have seen so many module of Bluetooth or wifi module that can only send messages to Arduino.
So I need an extension that can receive data from Arduino via WiFi module.
Any idea? Thank you very much!
Thank you very much, I have read this article.
But it seems it can only send messages to Arduino, is it able for Arduino to send strings to the mit app in that way?
Thank you very much!
Do you mind having your app poll the ESP via Web component every few seconds?
Have the ESP listen for polls and respond with whatever new it has to say.
You can also try my extension com.SerialOTG.aix that can handle serial, BT Classic and WIFI in a similar way, as byte streams. BT and WIFI can be used both as client and server. A simplified message server for ascii messages with LF as delimiter is available. SerialOTG_BT_WIFI.aia is a test application that show you how to use the extension. (but you still have to use a timer to poll for incoming messages). The extension can be found at GitHub - rkl099/Appinventor-SerialOTG: Appinventor extension SerialOTG with BT/WIFI client/server support, examples of apps and Arduino code, ver 1.4 including documentation. (And an updated version in _Debug directory.)
My extension works with TCP/IP. I can’t tell if it works with your WIFI card.
If you are going to connect to the Arduino from time to time, and use your phone for other tasks as well, then I think it’s better to let the Arduino be the server and your phone be a client. Then use polling as suggested before. This will be easier to implement.
Dear @Junrong_Huang,
I'm struggling since a couple of days with a problem similar to yours.
Behind the scene: => I wanted to make something like a home automation/antitheft system on my own.
I have then bought 3 NODEMCU8266 and some PIR sensors (Arduino compatibles).
The aim is to have a PAD (or phone) with an AI2 application to behave as the "controller" of the various NODEMCU's in a totally local WiFi network, without any router (therefore no remote control via WEB).
.I've then decided to have a structure like:
1 NODEMCU (#1) acting as a soft Access Point in Server configuration. It acquires the PIR and drives two relays (when it receives the command by each of the other two NODEMCU's).
2 NODEMCU's (#2 and #3) acting as Stations (STA) in Client configuration, Every 5 seconds they send a relay ON/OFF request to the AP, just to see whether they are alive and connected.
1 PAD (Lenovo M8 Android 9) in Client configuration, acting as User Interface or Controller. It can send a relay ON/OFF command by hitting on two buttons (of the PAD screen). On the screen are also shown the HTML strings as they come from the AP. No extensions used, just blocks.
With my configuration, in which the PAD (phone) is a client, I found that the "easy" way to receive messages from the server, is to set a periodical clock (i.e. 250 ms) on the PAD, so the PAD can ask the server if there are any news (like it was sent unsolicited by the server: see [(@rkl099) Rolf's answer].
In other words, by means of a 250 ms clock, the PAD (phone) asks the server to respond with some updates. If the server has some news to transmit to the client, it sends this new information, else, it sends the string "nothing to say". As soon as the string is received by the PAD, the app parses it, and decides consequently (i.e. "nothing to say" = no actions ).
The .aia and the .ino files that you find attached are really far from being "ready to use" but, anyway, they are working in my configuration, as described above and I guess they can be a good base that you can elaborate to get your needs Auto_Home_04 _1.aia (103.0 KB) ESP_8266_base.ino (8.1 KB)
EDIT: removed yesterday's Client .ino. Replaced with a commented one:
I know you are at the experimental stage but it is best to not have any unused cables near the Arduino and no cables should be near the module other than the ones connected to it. ESP-01S ESP8266 Module should work just fine, make sure it's in good condition -check for hairline cracks with a magnifying glass and test the cabling for continuity. Need to be sure you start with a good base