FGMGIT
Hello,
I have been doing tests with Circuits.UART without result and without receiving any communication in ttyS0 or ttyAMA0
It seems that in Raspberry Pi Z the default port associated with GPIO 14 and 15 serial communication is ttyS0 and what worked for me on raspbian was to disable the console service of the ttyS0 port by stopping the service with sudo systemctl stop serial-getty@ttyS0.service and remove the line console = serial0,115200 from cmdline.txt
I have also seen in Nerves that in “config.txt” it is overlaying ttyAMA0 on ttyS0 with dtoverlay = pi3-miniuart-bt so that the GPIO serial port is ttyAMA0.
According to the documentation that I have read to use serial communication over GPIO without problems it is necessary to deactivate the console through raspi-config .
https://www.raspberrypi.org/documentation/configuration/uart.md
I have tried to modify cmdline.txt and config.txt removing the overlap dtoverlay = pi3-miniuart-bt and console=serial0,115200 editing the files directly on my MicroSD but it seems to affect how ssh communications are being mapped so I have not been able to log back in with ssh. If I undo the modifications by ssh circuits@ip or via USB ssh circuits@nerves.local I can log back into the system.
So I don’t know where to continue testing.
I think the key is to disable the serial port console, is there any way in nerves to stop this service or run sudo systemctl stop serial-getty@ttyAMA0.service for the ttyAMA0 port?
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 6 of 6 Posts
outlog
I have serial comm working over ttyAMA0 with nerves rpi0 out of the box - so give that a try..
afaik there shouldn’t be any need to change things around..
FGMGIT
Hi @outlog. Thanks for the encouragement, I have used the example methods of the official documentation, without result. I am trying to send AT commands to a NB-IoT module connected via GPIO serial pins. But my little experience with Elixir and Nerves is making it very difficult to debug what is happening with the communication. Some sample use of the ttyAMA0 or some method to debug the port will be of great help.
outlog
check the wiring first and foremost - also ensure you have solid connection on the wires eg not flimsy breadboarding etc.
(also check that the wires are crossed correctly eg. nerves rx is connected to device tx and vice versa - of course except for those boards that try to be helpful by flipping the rx/tx - sic!)
start out in active mode.. ssh to the nerves system and try:
change the speed to whatever the device is communicating..
enter
flushin the console to see received messages (since you are in active mode)then send a command to the device eg:
Circuits.UART.write(uart_pid, "\xfe\x04\x00\x03\x00\x01\xd5\xc5" )(obviously change the command to something relevant to device..
and do a
flushagain to see received messages..find the datasheet for the device - and especially also find multiple arduino/python libs and find one where the code and commands are obvious and understandable..
I’ve attached code below that I use for a Senseair S8 (co2 sensor).. not cleaned up at all and far from perfect - sorry - I see it even has other irrelevant code for talking with a renogy solar controller lol..
but hopefully it can inspire/encourage you.. do pls post more about the device etc. and any code that materializes..
wip code example senseair S8:
It’s started in application.ex in the supervision tree eg:
the module itself..
FGMGIT
Hello @outlog , thank you very much for your help and encouragement.
I have tried to use your example, I got no results, through serial GPIO. I have also tried to emulate the same setup that works for me in python ttyS0 as miniUART modifying in Nerves cmdline.txt and config.txt to see if I could leave the original configuration and deactivate the serial console, which is what the manufacturer indicates. But also without result in Nerves. I’ll try to get a logic analyzer to see if I get something on serial GPIO pins. And try to see what encoding is using nerves in the sending and receiving of text strings.
Although I will also try instead of porting from python to Elixir the entire library. I will try to do the setup by USB port and microusb cable. And try using ppp protocol, with Vintage Net Mobile as a Custom Modem. Which I think will be more compatible with the entire Nerves and Nerves Hub environment for the distribution of Firmware, which is the final goal. Although I’m still trying to put all the pieces of the puzzle together and see which is the best setup.
The example code in python for mqtt communication and the results of the tests is:
The result is the same as nerves default setup, in active mode the same,
flushdoes’t give any result:Python sample code:
The python code works!!
I will post if I have any result with the logic analyzer or by ppp setup and Vintage Net Mobile.
outlog
my guess would be that you are not doing the powering “on” off the device on gpio 4 which the python code does - don’t know the specs but assume you need to replicate the
def power_on(power_key):with GitHub - elixir-circuits/circuits_gpio: Use GPIOs from Elixir · GitHubeg something like: (check if 4 is correct pin - they sometimes have different
{:ok, gpio4} = Circuits.GPIO.open(4, :output)and then a oneline
Circuits.GPIO.write(gpio4, 1); :timer.sleep(2000); Circuits.GPIO.write(gpio4, 0);depending on specs, maybe use pullup/down eg
Circuits.GPIO.set_pull_mode(gpio, pull_mode)keep us posted on any progress..
FGMGIT
It would have been fun and easy to solve if was this, justo to power on. I’m afraid it will be something more complex. With the logic analyzer the only thing I get after having turned on the board with Circuits.GPIO or with the physical button on the board. They are unreadable frames sent every so often without any specific action since I have a trigger that launches the recording when there is movement in the Tx or Rx and I only get start and stop bit missing! even without performing any action on the port. However in python the port is stable and only receives data when I receive or send data, and AT commands are correctly decoded in ASCII.
Logic Analyzer in Nerves. Channels setup Tx GPIO pin on blue in Phyton and Nerves tests.
And the example in python decoding every AT command, and launching the trigger when send the command.
I’ll post more test of the results.