Arduino Forum

Using Arduino => Project Guidance => Topic started by: 360modena_cs on Jul 06, 2018, 06:07 pm

Title: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 06, 2018, 06:07 pm
Hello,

I want to connect a Wifi module (Xbee) to the Arduino MEGA through serial. My question is can this work simple by sending data to the serial and be transmitted through Wifi? On the other end I will have another Wifi connected to another Arduino to get the data. So simple as this.. Because as I show on this page,

 https://www.arduino.cc/en/Tutorial/ConnectNoEncryption (https://www.arduino.cc/en/Tutorial/ConnectNoEncryption)

things are a bit complicated. I just want to open a Serial and send data, without so much configuration...
Title: Re: Arduino - WiFi connection through serial
Post by: pylon on Jul 06, 2018, 06:45 pm
Quote
My question is can this work simple by sending data to the serial and be transmitted through Wifi?
No. WiFi is a network connection and not a serial channel. So you have to open a connection on the network to send a data stream.

Quote
I just want to open a Serial and send data, without so much configuration..
In this case WiFi is probably not the best choice. Provide more information about the needs you have on that communication (speed, distance, reliability, obstacles, etc.), maybe we can suggest alternatives.
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 06, 2018, 08:54 pm
No. WiFi is a network connection and not a serial channel. So you have to open a connection on the network to send a data stream.

In this case WiFi is probably not the best choice. Provide more information about the needs you have on that communication (speed, distance, reliability, obstacles, etc.), maybe we can suggest alternatives.
Open space, around 100-200m, no obstacles (maybe some trees), as reliable as possible. Use of battery. I need an inexpensive solution because in the future I will need more nodes.

Thank you
Title: Re: Arduino - WiFi connection through serial
Post by: pert on Jul 06, 2018, 11:03 pm
XBee is not WiFi.
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 07, 2018, 11:10 am
https://www.digi.com/products/xbee-rf-solutions/2-4-ghz-modules/xbee-wi-fi#overview (https://www.digi.com/products/xbee-rf-solutions/2-4-ghz-modules/xbee-wi-fi#overview)
Title: Re: Arduino - WiFi connection through serial
Post by: srnet on Jul 07, 2018, 12:11 pm
There are many different views as to what 'inexpensive' means, whats yours ?
Title: Re: Arduino - WiFi connection through serial
Post by: hammy on Jul 07, 2018, 01:03 pm
Have a look at Moteino, Anarduino, and rfm69 .

They Are good alternatives. I've just bought 4 Moteino with rfm69 attached and there are good examples for getting  them to take to one another - the plan being to eventually just buy the rfm69 which is very cheap, and build my own system up.
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 07, 2018, 07:05 pm
Ok, Xbees are expensive if you want to use many, I need a solution with 2-5 euros for each wireless module...
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 07, 2018, 07:57 pm
The NodeMCU is at the lower end of that price point and has WiFi built in. Set one to host, the rest as clients. I think they can even do mesh networking between them.
Title: Re: Arduino - WiFi connection through serial
Post by: Robin2 on Jul 07, 2018, 09:35 pm
The NodeMCU is at the lower end of that price point and has WiFi built in. Set one to host, the rest as clients. I think they can even do mesh networking between them.
Will it give reliable 200 m range?  I know I got a pair of ESP8266's working at about 120m using ESP-NOW (http://forum.arduino.cc/index.php?topic=551310.0) and clear line of sight. ESP-NOW is not WiFi and I have not done any range checks with WiFi. The OP mentioned trees - they are not good for 2.4GHz wireless.

I would expect the high-power nRF24L01+ modules (with the external antenna) to work at 200m, but they are not WiFi. If the OP is interested in those modules this Simple nRF24L01+ Tutorial (http://forum.arduino.cc/index.php?topic=421081) may be of interest.

I think for reliable long range communication a lower wireless frequency - such as the 433MHz HC12 modules or LoRa would be better. But they, also, are not WiFi and they may be a little more expensive.


The obvious financial advantage of the ESP8266 is that it an work on its own without an Arduino whereas the other modules need to be connected to an Arduino.

The ESP8266-07 has a connector for an external antenna but I have no idea whether or by how much that improves its range.

...R
Title: Re: Arduino - WiFi connection through serial
Post by: srnet on Jul 07, 2018, 10:19 pm
Ok, Xbees are expensive if you want to use many, I need a solution with 2-5 euros for each wireless module...
Are you saying that if the only solution will cost 5.5 euros, your project is not viable ?
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 08, 2018, 04:21 am
Will it give reliable 200 m range
Depends largely on the layout of the project. Line of sight or indoors or city or forest all make a big difference.
Host node in the middle, everything else <100m away - also helps. Maybe mesh networking if there are lots of nodes, all 20-50 meters apart would definitely allow all to connect to one another - again depending on the general environment it has to operate in.
LoRa will indeed get the job done (433 Mhz or ~900 Mhz - depending on what's legal in OP's locality), but those modules by themselves blow just about all of OPs budget - which anyway is very low for a complete node (MCU + comms module + power supply + case + presumable some kind of sensors).
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 11, 2018, 08:00 pm
Thank you all for the information!!

Does this (which has also encryption - something that I need):

https://www.ebay.com/itm/331976853568?ViewItem=&item=331976853568

cooperate with this:

https://www.ebay.com/itm/Mini-USB-Nano-V3-0-ATmega328-16M-5V-Micro-controller-CH340G-board-For-Arduino/201539955347?hash=item2eecb7aa93:g:VKcAAOSwk4RbMvVf

??
Title: Re: Arduino - WiFi connection through serial
Post by: Robin2 on Jul 11, 2018, 08:13 pm
It should do.

...R
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 11, 2018, 08:18 pm
The problem is that I cannot figure out how to interface it with Arduino...
Title: Re: Arduino - WiFi connection through serial
Post by: gdsports on Jul 12, 2018, 05:10 am
Quote
The problem is that I cannot find out, how to interface it with Arduino.../
That is why people buy Moteinos. A Moteino board has a 328p with a RFM69/RFM95/RFM96 RF module of your choice soldered on the back.

https://lowpowerlab.com/shop/product/99 (https://lowpowerlab.com/shop/product/99)

The boards you link to are probably not going work together. The Nano uses 5V logic levels and the RFM69 board probably uses 3.3V logic levels. I say probably because it looks to be a clone of a HopeRF board but one can never be really sure with clone boards.
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 12, 2018, 06:27 am
Almost certainly 3.3V (and 8 MHz clock speed), as all those RF modules can't handle 5V.
Title: Re: Arduino - WiFi connection through serial
Post by: Robin2 on Jul 12, 2018, 09:52 am
Using a 3.3v devices with a 5v Arduino is quite common. You just need suitable components to drop the 5v output signals to 3.3v (such as a voltage divider). The 5v Arduino should have no trouble detecting 3.3v signals from the device.

...R
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 12, 2018, 11:51 am
Ok, thank you I will use level shifter...
In case I want to use encryption and the wireless module does not support it, how feasible it is to make the encryption on the Arduino before sending the data? Do Arduino nano support encryption/decryption, does anyone have experience with this?

Thank you.
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 12, 2018, 12:02 pm
Not very feasible on a Nano - not so long ago I looked into this, and it was mentioned that the encryption code takes almost 30 kB of Flash, leaving almost nothing left for your sketch.
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 12, 2018, 12:33 pm
Not very feasible on a Nano - not so long ago I looked into this, and it was mentioned that the encryption code takes almost 30 kB of Flash, leaving almost nothing left for your sketch.
If I use the flash for encryption and the eeprom for my code? The code is just a reading from Analog and sends the data on serial, nothing too complicated.Which library do you suggest for encryption/decryption?
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 12, 2018, 02:31 pm
No suggestions; I was just reading a bit about it while researching LoRa. I didn't pursue it as for my project encryption is not a requirement (it'd have been nice of course - encrypt everything!).
Title: Re: Arduino - WiFi connection through serial
Post by: MartynC on Jul 12, 2018, 03:23 pm
Haven't had time to play with them yet but I have a pair of DT-06 modules. These are based on the ESP-8285 and look to offer transparent wifi communication over regular UART
Title: Re: Arduino - WiFi connection through serial
Post by: Robin2 on Jul 12, 2018, 07:22 pm
Do Arduino nano support encryption/decryption, does anyone have experience with this?
That depends on what sort of encryption you want. Do you want to confuse me, or the CIA?

...R
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 12, 2018, 10:27 pm
That depends on what sort of encryption you want. Do you want to confuse me, or the CIA?

...R
Surely not CIA :P, but either someone with bruteforce attack to invade my sensors network.
Title: Re: Arduino - WiFi connection through serial
Post by: Robin2 on Jul 12, 2018, 11:04 pm
but either someone with bruteforce attack to invade my sensors network.
What sort of people would be interested in doing that?

In what way is your sensor data valuable?

Only a certain amount of paranoia is sensible. :)

...R
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 12, 2018, 11:34 pm
Haha, surely not  :)

The only thing I can say, is that in the future the major problem in IoT will be such kind of attacks. That's why serious companies provide encryption configuration for their wireless modules... (ex. Xbee)

Just google it...
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 13, 2018, 05:44 am
What CAN you do, really?

You could start listening in to the sensor values, recording them, not sure if there's any value to that.

You could start to inject fake sensor values by creating transmissions to the receiving node. But as long as your receiver is doing basic sanity checking on the values received that should never cause problems such as buffer overflows. At worst it would poison the logged data.

The ESP8266 has an OTA firmware update method, that should come with a good password. Another way to prevent attacks here is to only make OTA available for a short period of time, say 1 minute upon starting up of the device, after which it just doesn't listen. This way you can only update the device if you also have physical access to it.
Title: Re: Arduino - WiFi connection through serial
Post by: Robin2 on Jul 13, 2018, 08:30 am
The only thing I can say, is that in the future the major problem in IoT will be such kind of attacks.
So don't use IoT for anything that matters.

Surprisingly human civilisation has managed for a few thousand years without it.

...R
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 15, 2018, 09:22 pm
Haven't had time to play with them yet but I have a pair of DT-06 modules. These are based on the ESP-8285 and look to offer transparent wifi communication over regular UART
Do you know what is the maximum distance they can transmit? because I am googling it but I cannot find something..
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 15, 2018, 09:31 pm
It's WiFi, so expect to get as far. So typically 0-50 meters, depending on the environment. Maybe a little more if you have a very clean line of sight and no other networks around that cause interference.
Just try it with your phone - about as poor an antenna as those modules have. An external antenna will normally give you a better range.
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 16, 2018, 12:07 am
If I use this component:

https://www.ebay.com/itm/331976853568?ViewItem=&item=331976853568 (https://www.ebay.com/itm/331976853568?ViewItem=&item=331976853568)

with level shifters (5V to 3.3V and vice-versa)

instead of this component:

https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide (https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide)

with Arduinos of course, will it work?? Has anyone experience?

Thank you...
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 16, 2018, 04:48 am
The Sparkfun one has the same module, but on a breakout board for easy connection and the two required capacitors installed already. Otherwise, they're the same.

The e-bay module you link to fits perfectly on a standard ESP-12 breakout board, by the way. Same footprint.
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 16, 2018, 11:40 am
The Sparkfun one has the same module, but on a breakout board for easy connection and the two required capacitors installed already. Otherwise, they're the same.

Do I need those capacitors?
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 16, 2018, 11:58 am
Yes - see data sheet.
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 16, 2018, 12:44 pm
I see only one capacitor (red arrow)...see attachment

Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 17, 2018, 12:27 pm
Yes - see data sheet.
Which datasheet did you see?
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 17, 2018, 12:51 pm
Manufacturer's data sheet (http://www.hoperf.com/upload/rf/RFM69HW-V1.3.pdf).
P.77 you see the circuit - a 104 and a 105 so 100n and 1µ; the first for filtering, the second for decoupling; other circuits that I find suggest a 47µ cap, and Sparkfun apparently settled on 10µF decoupling.
Title: Re: Arduino - WiFi connection through serial
Post by: 360modena_cs on Jul 17, 2018, 04:35 pm
Manufacturer's data sheet (http://www.hoperf.com/upload/rf/RFM69HW-V1.3.pdf).
P.77 you see the circuit - a 104 and a 105 so 100n and 1µ; the first for filtering, the second for decoupling;
I suppose I put ceramic capacitors, not electrolytic, right?
Title: Re: Arduino - WiFi connection through serial
Post by: wvmarle on Jul 17, 2018, 05:03 pm
100n ceramic
1-10µ electrolytic (ceramic may work as well)