I'm new to Nodemcu and i need your recommendations.
I'm curently doing an IOT project that can be worked in the large area and I decide to use Nodemcu - ESP8266 to transfer the data. I plan to use 3 Nodemcu to demo. Two of them are used for collecting data from sensors and transfer them to the 3rd Nodemcu. The 3rd Nodemcu will act like a gateway and it will recongnize the data from each node and send it to the Web Server that I myself created. The Web has its own domain and hosting.
With the ideas above, i have some questions:
Do i really need the 3rd nodemcu to send data to Web Server? Or i just need to send the data directly from those 2 nodemcu to a Web Server?
If it's possible to use the 3rd nodemcu, so it should be worked in station or access point mode?
If 3rd nodemcu is not necessary, so how can i extend the working range of the project?
Thanks so much for your helps. I'm really appreciated. Sorry for my bad English too.
NODEMCU can be used to send data to the server directly if it connects with a router via WiFi(Router needs to be internet connected).
You don't need the third Nodemcu to transfer data. Both esp8266 is directly connected with a router to send data to the server. MQTT is the best protocol for sending data to the server from Sensor. NodeMCU works as an MQTT client to send data. You need to host MQTT broker on a cloud server. Server store data into the database.
If you want to use a third NodeMcu device. NodeMcu can support access point + station parallelly. An access point is used to get data from both devices. ESP8266 station is used to transfer data to the server.
All devices need to have into the same WiFi network to transfer data in between. In case of transferring data to the server, One solution is, To use WiFi range extender like Google WiFi.
You can use MQTTfx desktop application to send and receive data from NodeMcu(ESP8266).
MQTT library for ESP8266
https://github.com/Imroy/pubsubclient
Use the Following link to get more familiar with MQTT protocol
https://www.hivemq.com/blog/mqtt-essentials-part-1-introducing-mqtt
MQTT basic diagram
Related
I've been tasked with figuring out how to get a mobile app to communicate with an MCU then in turn control a stepper motor. Right now I'm trying to get the WiFi module (ESP8266-01) and MCU (NUCLEO-F030R8) to play nice with each other. The catch is I have little to no experience and no education in this field. The closest experience I have is simple Arduino sketches from years ago (IE photo-resistor values driving a stepper motor) and making desktop applications with C#. I am using STM32CubeIDE but if there's a better option I can switch to that.
What I would very much like help on is send and receive simple data between a smartphone and the MCU via the WiFi module. I've read through documentation and other questions but still don't exactly know where to start.
I understand this is probably a large topic in its own right and a short blurb on the internet won't do it (and undoubtedly its multiple subcategories) justice. But I might as well ask.
Sorry if this is too much and thank you in advance.
This project would involve making the following connections.
The UART connection between STM32 and ESP8266.
The WiFi connection between ESP8266 and the mobile.
The application layer protocol between ESP8266 and the application running on the mobile.
For 1, you can actually program the ESP8266 using Arduino IDE and simply connect the UART TX/RX pins of ESP8266 with RX/TX pins of STM32 respectively. You can create a test project in which ESP8266 sends data to STM32 over UART to verify this connection.
For 2, you need to consider the wifi network mode i.e identify whether the wifi connection is going to be ad-hoc (mobile connects to ESP8266 directly) or in infrastructure mode (mobile and ESP8266 connected via a shared access point). You can configure the ESP8266 in both modes. You just have to program the SSID and password of the Wifi network in the ESP8266 (in case of ad-hoc, it is the SSID of the network advertised by ESP8266 and in the infrastructure mode, it is the SSID of the common AP). This wifi functionality is also easily programmable in Arduino IDE for ESP8266.
Finally, once the physical connection has been established between the ESP8266 and mobile device, you need an application-level protocol to connect the application running on the mobile with the ESP8266. You can either use socket connection between ESP8266 and mobile application or use a higher-level communication protocol for IoT devices like MQTT, which is also available in the Arduino IDE.
Final connection diagram could be something like this:
application -> mqtt msgs -> wifi packets -> esp8266 recv pkts -> parse mqtt msgs -> forward data to STM32 over UART
I couldn't find any documents on how to connect to Google Cloud IoT MQTT bridge from Swift-based applications. Is it possible to connect? Any references or links or samples would be appreciated.
Edited answer responding to comment: To connect using the MQTT bridge to IoT Core, check out the code here.
We don't have an IOS/Swift code example there, but you should be able to see the various pieces you need from the Node or Python examples. The URL/endpoint for IoT Core is mqtt.googleapis.com:8883. The MQTT client's user/pass is going to be blank for the user (unused) and the encoded JWT for the password. The same code has what it looks like, and should be enough to get you started hopefully.
To communicate with IoT Core, the MQTT topics are devices/<device_id>/events/ for telemetry from device to Cloud, and if you want to report state of the device to be stored by IoT Core, it's devices/<device_id>/state/ and if you want to send messages from IoT Core back down to the device, it's either devices/<device_id>/config/ for persistent messages that will be delivered on connect if the device isn't actively connected, or devices/<device_id>/command/ if it's more of a fire and forget, lower latency type message.
Original answer: We don't have any documentation around this particular use case yet, but I found this:
https://github.com/emqtt/CocoaMQTT
Which enables MQTT client connections from IOS and is written in Swift, so that should work. In addition to this, you'll need a library to encode a JWT (Json Web Token) for the auth side of things.
Having said that, you could ditch MQTT entirely and just use the HTTP bridge in IoT Core, as that might be easier? You can see the docs for doing that here: https://cloud.google.com/iot/docs/how-tos/http-bridge. You'll still need the JWT piece for the auth, but it would keep you from having to implement MQTT in the app.
I am developing a product which uses ESP8266 (arduino firmware). I am developing an Ionic app as the main controller. The product is working perfectly fine through the server. But a major feature needed is to communicate with the devices through LAN. The devices host a server so I can communicate with them using GET requests through my app using their local IP.
But the problem is discovering these devices. Currently my approach is to send a get request on all IPs on my subnet and parse the response, if any, and store the active IPs in app; then use those stored IPs to communicate for subsequent requests.
The problem is the sending request to all IPs part. It is a slow process and slower with low end phones.
What I want is a way to receive communication from the devices initiated by them, maybe. Something like signalling all IPs (just my devices) at once to send their IPs to my phone.
Can this be done easily? And quickly? And accurately?
One option is to set up the ESP8266 to publish an mDNS service (also known as zeroconf, bonjour, etc..). Luckily, mDNS is built into the ESP8266 Arduino core. There is some basic setup info here: https://tttapa.github.io/ESP8266/Chap08%20-%20mDNS.html, as well as elsewhere on the web.
Then on the ionic side, you can then use a zeroconf/mDNS plugin to automatically discover the ESP8266. I've used this one in the past, with good results: https://ionicframework.com/docs/native/zeroconf/
I want to send data from an arduino to a web page for remote monitoring as well as send data from the web page to arduino for remote control. Is it possible to create both a client and a server in the same Arduino? Also is there any method by which it is possible to control and monitor an Arduino at the same time?
Thanks
Yes, it is possible to have both a client and a server in the Arduino running at the same time. Your second question is not very clear.
How do apps like Apple's "Remote" app control mac applications and send data?
is this via php with exec() commands or some other method? and how would I do it in c?
Also, how fast is this rate of transfer (can I use it to send real-time data like streaming video or audio?)
thanks to anyone who cares to enlighten me on this issue :-)
Apps generally communicate using a TCP/IP based protocol and the wireless LAN connection (the iPhone also has Bluetooth). In the case of the Remote app the communication is via with the Digital Audio Control Protocol. iTunes implements DACP so the Remote app can control it. Other common protocols are HTTP and FTP. There are classes in the iPhone SDK to connect to noth HTTP and FTP servers. There is also the Cocoa HTTP Server project which allows the iPhone to act as a HTTP server.
iPhone apps can also use Bonjour/mDNS/zeroconfig (they're different names for the same technology) so that the user doesn't have to be concerned with configuring IP address'.
The data transfer rate of the wireless connection is faster enough to stream video.
many of these remote applications work by installing client software on the computer and establishing a network connection. In the case of Apple's remote software, the client software is built into the networking capabilities of iTunes. You must authenticate using your iTunes sign in and be on local wifi.
The third party app "intelliremote" works very similarly only has it's own client software to install and can work across a WAN with proper port forwarding enabled on your network.
I haven't encountered any realtime streaming options as most of these utilities are designed to pass control messages and meta-info on media files.