Hot answers tagged

5

You need to keep track of multiple WiFiClients - declare an array of them, for example, and each time server.available() gives you a new one, store it in the array. Then you need to make sure your code doesn't stick waiting for data from each item. You could service each WifiClient in turn: if it has data waiting (client[i].available() is true), read the ...


5

The String object created as return from IPAddress.toString() as parameter to constructor of NtpClient is temporary. It contains the char array returned by c_str(). NTPClient doesn't copy the string, only stores a reference to it. And the referenced string (char array) doesn't exist at the time the NTPClient wants to use it. class TestClass { public: ...


3

Check out the library Modbus-TCP on Github. It has the facility for all the function codes as asked. It has provision for Wiznet W5100 and ENC28J60 Ethernet IC. All tested with Arduino Mega. See the well documented example code for the Wiznet module in the library. For detailed knowledge about the library, read the index.html inside the doc folder of the ...


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

There is no library, and there physically cannot be one. IPv4 is built into the Ethernet shield itself. (It has a Wiznet 510 chip.) Shields based on the MicroChip ENC28J60 chip (such as those sold by Ekitszone and Nuelectronics) are suitable for the implementation of an IPv6 or dual IPv4/IPv6 stack. This approach requires the TCP state machine to be ...


3

I would recommend the official Arduino GSM shield.


3

That library should work with pretty much anything that has the M10 module on it. I only have experience with the SIM900 modules. Found the cheapest one on EBay. While interfacing with these things can be a challenge at first, you really just need to read the manual for all the AT commands and execute them. I've written a couple of functions that may help: ...


2

It's time you learned the OSI 7 layer model: PDNTSPA. HTTP is a Presentation (protocol) that runs over a TCP Session. If you are interacting with a web server then you will be opening a TCP socket and sending HTTP requests. There is no other way of talking to a web server. It only speaks HTTP, and you can only connect to it through TCP.


2

The problem is, that "char" is just one character. So you have to build your return out of the chars... if you want to use the "client.read()" function. String res = ""; //this will be the resived msg after the loop do { char c = client.read(); //c will be -1 if no byte is left if(c!=-1) strcat(res, String(c)); //Append the char to the result ...


2

***** Assuming it is an ESP8266 based WI-FI shield: ***** Wifi shield > PC Open serial monitor. Baud rate 155200. Also check COM ports. Test AT commands by typing AT. If it responds OK, you're good. Type AT+CIFSR for IP adress. Full list of AT commands in this link: http://www.pridopia.co.uk/pi-doc/ESP8266ATCommandsSet.pdf


2

Well, your best bet is to import the arduino libraries in your Atmel Studio project. Then you'll be able to use existing code to connect to the "traditional" Ethernet Shield using SPI. Though, the Sam 3X features an hardware ethernet that is not wired, unlike the MBed LPC1768… Sadly that's the ethernet PHY component you saw, but won't be able to actually ...


2

There are examples in the ESP8266 library https://github.com/me-no-dev/ESPAsyncTCP/tree/master/examples


2

Assuming your request passed muster, the right way to wait for a response is: #define TIMEOUT 2000 // at the top of your sketch Serial.println("Server Response:"); uint32_t lastRead = millis(); while (millis() - lastRead < TIMEOUT){ while (client.available()){ Serial.write(client.read()); lastRead = millis(); } } This ensures that the ...


2

HTTP/1.1 requires you to provide the host name of the server. And it will keep the connection open for some time unless you explicitly opt out of this. Thus, the equivalent of the basic HTTP/1.0 request in HTTP/1.1 language is POST /the_uri HTTP/1.1 Host: foo.example.com Connection: close


2

You have declared WiFiClient client; in the scope of setup() only. Move it's declaration to the global scope by placing it above the declaration of void setup()


2

I ended up ordering an Elechouse board which uses the M10 chip. Found one on eBay for 59 USD. It appears to work fine with the official library. As the manual says, it must be given external power - the USB cable isn't enough!


2

You have the inherent problem that a TCP connection is terminated by an explicit "FIN" message from the terminating party, followed by a FIN-ACK and ACK. Refer to here. If your client (or server) just powers off without closing the connection properly, that's it. The connection hangs up and no data will be transfered if it is not explicitly handled. If ...


2

If you want to send data to a server on the internet, you will need an internet connection, or at least a connection to a internet gateway. Which type of connection you use, and how you set up that connection, depends on distance, speed, and coverage you need. Probably the most universal for your application, in the sense that it will work wherever a phone ...


1

close the disconnected socket before reconnecting if (!client.connected()) { client.stop(); client=TCPserver.available(); }


1

After searching and experimenting on this, I believe the short answer to the question is that you need to send the command string like a buffer of characters AND put your Hex Coded command for the LED controller as an escaped string of characters. Here is my code (it toggles the LED Controller between Green and Blue every 5 seconds, but you can extend this ...


1

You assume all 5 bytes of 959\r\n are received by the server at the same time. The data is sent byte after byte, based on the client.print(data) in the ESP code and assuming the underlying library doesn't buffer bytes before transmitting, so there's no way they'll arrive at the server simultaneously. Most likely, your first pass with conn.recv(1024) grabs ...


1

The numbers are ASCII Codes (here is a chart from the Arduino website). 49 is the number 1, and 13 is a carriage return ('\n'). There should be a setting in the bottom right corner of Serial Monitor to change line ending, this should be set to "no line ending." If it is, than client.print() must be adding the carriage return, so you will need to remove it in ...


1

I suspect these delays are caused by TCP buffering. For some theory on this sort of thing, perhaps read about Nagle's Algorithm which covers some of the issues with small packet buffering. It seems reasonable to me that lower-power and/or lower-speed (or even "just different") boards would use more aggressive buffering. TCP uses all manner of buffering ...


1

For Arduino UNO Wifi, you have to use library "UnoWiFi-Developer-Edition-Lib". You can directly download and install it through library manager or can get it offline through the following link "https://github.com/arduino-libraries/UnoWiFi-Developer-Edition-Lib". Hope this can help you.


1

If there are no examples provided with the library then you will have to make do with the example you have :( If you think about what a web server does it is really just a glorified Telnet server without proper security. When the web server comes up it creates a waiting socket on port 80, you want port ?? (too long ago). It sits there waiting for text ...


1

Have the app send a broadcast UDP packet, and have the ESP listen for such broadcasts. Now the ESP knows the IP address of the device on which the app is running, and it can somehow let it know its own IP address: perhaps connecting to a particular socket on which the app will listen, or sending a UDP broadcast of its own.


1

"...Please any help? Do I have to assume that my shield is faulty?..." Before trashing the shield, I'd run through a sligtly more comprehensive troubleshooting approach, from the lowest level of the network stack (the physical layer) up to the ICMP/IP layer. Let me expand over this process: Physical layer: I bet your router has some LEDs whose purpose is ...


1

Modbus TCP simply put is a Modbus packet wrapped in a TCP packet. There is no 'additional layer of Modbus' added on top. If we look at the osi model pictured below you can see there is only one Modbus application layer (i.e modbus slave/server) Essentially if the wifi->RS485 gateway strips the payload from the TCP packets and simply spits it out the ...


1

The ESP trys to connect to port 4160, but the server is listing on port 20.


1

Network problems can be complex. If these suggestions are not right I can change the answer later if other solutions present themselves. If you are connecting two Ethernet devices directly you may need a cross over cable. To test your connection with out using IP addresses, try to follow what is discussed in this answer where the MAC address is used on a ...


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