Sending IP Address through serial - serial-port

first of all, I'm a bit confused about this problem so if you see any other solution it would be perfect.
I'm connecting an ESP32 to my network and sending the IP address obtained with WiFi.localIP() to a nordic nRF52 DK (works as an arduino here).
Then I write this IP in one of the BLE characteristics I created.
The problem is that I don't know how to send it, the problem is the format.
this is how I try to add the value to the characteristic:
if(Serial.available())
{
Serial.println(Serial.read());
wifiIP_Char.setValue(Serial.read());
}
Regards,
Pablo

Related

Sending and Receiving on the Same COM port using COMOCOM

I have seen several articles and videos showing how to use COM O COM Serial Port Emulator to send on one COM port and receive on another. But in my case I have to send on one ports and I also receive on the same port. Can COM O COM software do that?
I cannot find any other place to ask the question.
Hmm a bit weird question. What's the point in reading what you just wrote?
If you want to send and receive on the same port the only way is to phisically loop (wire up) TX and RX on the serial port and send and receive on it.

Can Cat 5 cable communicate with microcontroller and CPU?

So I was curious if this is possible at all. Currently i have a program running in a micro controller (digi rabbit) that reads SPI data from a chip. I also have TCP/IP protocol set in this program so it sends the SPI data to the server. Microcontroller is programmed in C. Server is in java. I convert SPI data into string and send it over, the server reads the raw data.
But i wanted to know if there is a way that I can read the data from Ethernet port. So what i want is one end of cat 5 cable on micro controller and the other on Ethernet port of the computer. Just for testing purposes that micro controller port and everything is installed properly, before i turn on the server. I am not that experienced with networking. So if anyone can point to a blog, or any tips that would be great. My question is how would i go about it?
Thank You
What you want to do is called raw Ethernet. Of course this can be done.
On the microcontroller side you need to follow its Ethernet controller datasheet to send out and receive packets. On the PC side this is a bit more complicated and depends on the OS that is running on the PC. On Windows you can use the WinPcap driver to send and receive raw Ethernet packets.
Be aware, that both Ethernet controllers, the one on the PC and the one on the microcontroller, filter all incoming packets that do not contain the receivers MAC address or any multicast/broadcast address. For a simple check the broadcast address (all address bits are 1) will do.
Also note, that the OS on your PC will transmit all kind of packets as soon as the link is established. So you may use a unique protocol identifier in the type field of your raw Ethernet frame. Check Wikipedia's article about Ethernet frames. Btw. don't get confused. You only need to send MAC-adresses, Ethertype and the payload. Everything else, like the CRC, preamble etc., is added by the Ethernet controller automatically.

Arduino Yun WifiStatus Example Failing

I am able to connect and upload the WifiStatus example per the instructions on the Arduino Site/Examples/Yun. However, when I hit the serial monitor button it is supposed to print out the relevant Wifi stats, instead it says "unable to connect" and the final line goes a bit further..."unable to connect: is the sketch using the bridge". Any ideas? A post suggested reseting the 32U4, which I did, but no luck.
Incidently, all of this is over Wifi. Board and port are set per instructions. Yun pings fine and receives the uploaded sketch fine.
More code is usually more illuminating... so you might get better answers when you provide more information.
"is the sketch using the bridge" seems to indicate that there is some problem with the Bridge library. Is it being initialized? Did initialization (i.e., "Bridge.begin()" succeed?
A sketch with bridge functional and serial monitor via network connection cannot be running simultaneously as they use the same hardware connection.
You may use the serial monitor via USB port, or Serial TX/RX pins, or SoftwareSerial for this.

Xbee, Arduino & Processing Design Query

I have a processing sketch that pumps out basic serial commands to an xbee.
Then I have two (soon to be 3, maybe 4) arduino's with their own xbee's who receive the data and do stuff.
Thing is each Arduino has it's own purpose, and therefore it's own data packet.
So, to implement this. Is there a way to send a message to a particular xbee? I.e. can I assign the xbee an index or channel of some sort, then get the broadcasting xbee to send data to whatever index or channel it needs to?
Or, will this need to be implemented in the Arduino software?
i.e. Processing prefix the data packet with an index/identifier and the arduino ignore incoming messages with that prefix?
Or is there another option entirely :P
Thanks in advance for your advice.
While not a specific answer to your question, with this type of communication some packet error checking would be beneficial. Send the data using a crc error checking algorithm. Packet structure could look something like:
0x7F 0x02 (Address Bytes) (Command Bytes) (CRC bytes) 0x7F 0x03
Where 0x7F is the DLE character used to indicate either a start byte will follow, and end byte will follow, or a data byte with the value of DLE will follow. This means any DLE character that is part of the address or command should be preceded by a 'Stuffed' DLE character. The CRC is calculated from the address and command bytes and used to check the integrity of the data that is received. The CRC check bytes are included in each packet.
This type of communication will prevent packets going to the wrong source from being used, and also packets that are in error from being used.
To read more on serial framing here is a good place to start: http://eli.thegreenplace.net/2009/08/12/framing-in-serial-communications/.
To what i understood is that you want to be able to tell the diffrence to what Xbee you are sending data to. You can do this by using IP adresses. If you have for example two Xbees with the IPs:
Xbee1 - 192.168.80.50
Xbee2 - 192.168.80.51
Xbee3 - 192.168.80.52
You can send information between them by just connecting the Xbee that will start the communication to the Xbee that will receive it. If you want to have any kind of communication over the wireless network (or ethernet) you must have an IP assigned to every Xbee.
EDIT:
If you have a server on a computer that you have made yourself in for example Java. You can connect the Xbees to that and connect of them to the computer server. Then you can set up the server to receive and send data to the diffrent Xbee clients.
I did something similar to this: Maintaining communication between Arduino and Java program , but i didn't use a Xbee, i used the official WiFi shield.
Hope this helped!
-Kad

Setting Arduino Wi-Fi shield to a static IP address

What would be an example of how to set the Arduino to have a static IP address?
I am looking for a function similar to the statement below from the Ethernet Library.
Ethernet.begin(MACadr, IPaddr);
I using a Wi-Fi shield.
Sorry, this is not possible. The reference for this claim is here.
Basically, all the DHCP stuff (the code that assigns the dynamic IP address) is baked-in to the firmware for the WiFi shield, and this code is not open, so you cannot update it.
"WiFi.config() allows you to configure a static IP address as well as change the DNS, gateway, and subnet addresses on the WiFi shield."
You can read more about this here:
http://arduino.cc/en/Reference/WiFiConfig
What I did in my situation was to set a Reservation on my router for this MAC address. This makes the code simple. For some reason, the MAC address that my WiFi shield was supposed to use isn't what it actually uses. I was able to look at the DHCP table on the router and find the MAC address it was using and create a reservation and we are good to go...

Resources