# an experience for arudino serial port communication[share to every arduino fans on freebsd]



## Raffeale (Mar 17, 2020)

Recently I restart my quater flight project, my remote controller was created with arduino nano ( usb chipset is ch340), I need upload new code to fix some code bug. I find some guide, but I found the guide is wrong.

You just need put your usb chipset driver into loader.conf, it works fine. Don't user Ardueno kernel module in arduino nano, this module is only for arduino uno board.

Fist of all, add your username to dialer group
`pw groupmod dialer -m username`

You need know what USB chipset is your Arduino ,  the arduino usb chipset commonly are cp210x , ch340 or ftdixxx
You can look at your Arduino board to find out that chipset, and put USB driver to /boot/loader.conf


```
uftdi_load="YES"     ### for ftdi chipset
uchcom_load="YES"   ### for chxxx chipset
uarduno_load="YES" ### only for arduino uno cp210x chipset    if you don't find this module in /boot/module , you need compile from ports  /usr/ports/comms/uarduno/
```

Or you can load module by hand if you didn't open securelevel 


When you loaded usb chipset driver, you will get some message in you dmesg

```
ugen1.2: <vendor 0x1a86 USB2.0-Serial> at usbus1
uchcom0: <vendor 0x1a86 USB2.0-Serial, rev 1.10/2.54, addr 1> on usbus1
uchcom0: CH340 detected
ugen1.2: <vendor 0x1a86 USB2.0-Serial> at usbus1 (disconnected)
uchcom0: at uhub1, port 3, addr 1 (disconnected)
ugen1.2: <vendor 0x1a86 USB2.0-Serial> at usbus1
uchcom0: <vendor 0x1a86 USB2.0-Serial, rev 1.10/2.54, addr 1> on usbus1
uchcom0: CH340 detected
```

And you will find a serial device in /dev directory like this, this device was created by USB serial chipset drivers.
If you can't find any /dev/ttyUx or /dev/cuaUx device, that means your USB serial driver didn't recognize. Maybe you loaded USB chipset driver  dismatch with your usb serial chipset

```
crw-rw----  1 uucp  dialer  0x1a3  3月 17 19:24 /dev/cuaU0
```

Now , you could run arduino ide to test it ,arduino ide will recognize your serial port and use it.
If you the arduino SerialPort menu is gray , that mean your serial port permission  or device file's user group  is not right.

I have already test arduino IDE 1.8.5 and 1.0.6, it works fine! 

NOTE:  
1.if the serial device file group is not dialer , you need change its group to dialer then you can upload
2.you need pay attention the serial port device file permission, normally it's 660, you could change it to 666 with chmod 666 /dev/cuaU0


----------

