# How to use a serial com port in Gleam?

**URL:** <https://erlangforums.com/t/how-to-use-a-serial-com-port-in-gleam/2815>\
**Category:** Gleam Forum\
**Tags:** gleam-questions\
**Created:** [August 22, 2023, 11:03am UTC](https://erlangforums.com/t/how-to-use-a-serial-com-port-in-gleam/2815 "2023-08-22T11:03:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rustasian](https://erlangforums.com/user_avatar/erlangforums.com/rustasian/32/2050_2.png) [@Rustasian](https://erlangforums.com/u/Rustasian)\
**Post date:** [August 22, 2023, 11:03am UTC](https://erlangforums.com/t/how-to-use-a-serial-com-port-in-gleam/2815/1 "2023-08-22T11:03:40Z")

</div>

Hi, I’m new to this community and I want to learn Gleam. But I want to know one thing first:

How can I use a serial Com Port from Gleam? e.g. Com1 in Windows or /dev/ttyUSB0 in Linux

I want to be able to communicate with embedded devices, meters, and the like. I assume I have to use some Erlang library like [GitHub - systra/erlang-serial: Erlang serial-port support; based on serial-1.0 by Johan Bevemyr](https://github.com/systra/erlang-serial). But is this still working? Last update is 12 years ago. Another one is 7 years old.

How can I do this?

---

<div class="post-metadata">

**Author:** ![igorclark](https://erlangforums.com/user_avatar/erlangforums.com/igorclark/32/1089_2.png) [@igorclark](https://erlangforums.com/u/igorclark)\
**Post date:** [August 22, 2023, 11:38am UTC](https://erlangforums.com/t/how-to-use-a-serial-com-port-in-gleam/2815/2 "2023-08-22T11:38:57Z")

</div>

Hi! I think the most recent version is [GitHub - tomscii/gen\_serial: Generic serial driver for Erlang on UNIX and Windows](https://github.com/tomscii/gen_serial) - I just cloned it and it built fine with Erlang/OTP 25. I used it for a project in 2019 and it worked great. I think historically the older forks didn’t work with Windows but this one does. I’ve no idea about using it in Gleam though, I _think_ you can just pull in dependencies in the rebar3 config but I haven’t done it myself and I’m not sure if it loves native code. It’s not a NIF but a port so it should in theory just build it separately and run. Good luck 🍀

---

<div class="post-metadata">

**Author:** ![Rustasian](https://erlangforums.com/user_avatar/erlangforums.com/rustasian/32/2050_2.png) [@Rustasian](https://erlangforums.com/u/Rustasian)\
**Post date:** [August 22, 2023, 2:19pm UTC](https://erlangforums.com/t/how-to-use-a-serial-com-port-in-gleam/2815/3 "2023-08-22T14:19:46Z")

</div>

Does this driver works with Windows 10 and 11? I only see support up to Win7

---

<div class="post-metadata">

**Author:** ![igorclark](https://erlangforums.com/user_avatar/erlangforums.com/igorclark/32/1089_2.png) [@igorclark](https://erlangforums.com/u/igorclark)\
**Post date:** [August 22, 2023, 4:38pm UTC](https://erlangforums.com/t/how-to-use-a-serial-com-port-in-gleam/2815/4 "2023-08-22T16:38:33Z")

</div>

Dunno! That README is probably really out of date. Give it a try? I don’t have a windows box to test it on 🤷🏻‍♂️

---

<div class="post-metadata">

**Author:** ![lpil](https://erlangforums.com/user_avatar/erlangforums.com/lpil/32/222_2.png) [@lpil](https://erlangforums.com/u/lpil)\
**Post date:** [August 22, 2023, 5:36pm UTC](https://erlangforums.com/t/how-to-use-a-serial-com-port-in-gleam/2815/5 "2023-08-22T17:36:38Z")

</div>

> [@igorclark](#):
>
> I’ve no idea about using it in Gleam though, I _think_ you can just pull in dependencies in the rebar3 config but I haven’t done it myself and I’m not sure if it loves native code.

The Gleam build tool supports rebar3 dependencies, though it’s not heavily tested for NIFs so there may be some situations in which it doesn’t work.

If you find a place where it doesn’t work please open an issue in the Gleam repo 💜

---

<div class="post-metadata">

**Author:** ![Rustasian](https://erlangforums.com/user_avatar/erlangforums.com/rustasian/32/2050_2.png) [@Rustasian](https://erlangforums.com/u/Rustasian)\
**Post date:** [August 22, 2023, 8:58pm UTC](https://erlangforums.com/t/how-to-use-a-serial-com-port-in-gleam/2815/6 "2023-08-22T20:58:35Z")

</div>

I just start learning Gleam. If it doesn’t work well on Beam it is not a big issue. I can use Python or something to run a server to bridge the com port to something that Beam can handle, like a Rest API.

But I will try it. Thanks for your help
