Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP]Lastest 3.6.3. Modbus RTU doesnt work on RPi3 #1648

Open
Jonnik84 opened this issue Jan 10, 2025 · 6 comments
Open

[HELP]Lastest 3.6.3. Modbus RTU doesnt work on RPi3 #1648

Jonnik84 opened this issue Jan 10, 2025 · 6 comments
Assignees

Comments

@Jonnik84
Copy link

I'm using TB Gateway for testing purposes now I want to test the simple MODBUS RTU
I have hardware Raspberry Pi 3B
Raspbian OS 64Bit Lastest stable

I use Docker installation for tb gateway
Have lastest version 3.6.3

Attaching my simple config
modbus_serial.json

Here is LOG
tb-gateway Logging error.txt

my hardware is working well. here is log using mbpoll:
_


smr-admin@raspberrypi:~ $ sudo mbpoll -m rtu -a 1 -r 2 -b 9600 -d 8 -P none -s 1 /dev/ttyAMA0
mbpoll 1.0-0 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright © 2015-2019 Pascal JEAN, https://github.com/epsilonrt/mbpoll
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type 'mbpoll -w' for details.

Protocol configuration: Modbus RTU
Slave configuration...: address = [1]
start reference = 2, count = 1
Communication.........: /dev/ttyAMA0, 9600-8N1
t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave 1... Ctrl-C to stop)
[2]: 1286

Pls help me. Cant do anything further... Im not a Python engineer
Thanks

@Jonnik84 Jonnik84 changed the title [HELP] [HELP]Lastest 3.6.3. Modbus RTU doesnt work on RPi3 Jan 10, 2025
@imbeacon
Copy link
Member

Hi @Jonnik84,

In order to connect to device from docker container you need to add forwarding of device to docker compose file.
To do this - you need to add devices section. Please find example below:

version: '3.4'
services:
  # ThingsBoard IoT Gateway Service Configuration
  tb-gateway:
    image: thingsboard/tb-gateway
    container_name: tb-gateway
    restart: always

    # Ports bindings - required by some connectors
    ports:
        - "5000:5000" # Comment if you don't use REST connector and change if you use another port
        # Uncomment and modify the following ports based on connector usage:
#        - "1052:1052" # BACnet connector
#        - "5026:5026" # Modbus TCP connector (Modbus Slave)
#        - "50000:50000/tcp" # Socket connector with type TCP
#        - "50000:50000/udp" # Socket connector with type UDP
    devices:
        - /dev/ttyAMA0:/dev/ttyAMA0

    # Necessary mapping for Linux
    extra_hosts:
      - "host.docker.internal:host-gateway"

    # Environment variables
    environment:
      - host=host.docker.internal
      - port=1883
      - accessToken=YOUR_ACCESS_TOKEN

    # Volumes bind
    volumes:
      - tb-gw-config:/thingsboard_gateway/config
      - tb-gw-logs:/thingsboard_gateway/logs
      - tb-gw-extensions:/thingsboard_gateway/extensions

# Volumes declaration for configurations, extensions and configuration
volumes:
  tb-gw-config:
    name: tb-gw-config
  tb-gw-logs:
    name: tb-gw-logs
  tb-gw-extensions:
    name: tb-gw-extensions

@Jonnik84
Copy link
Author

I've done this already. nothing changed

@Jonnik84
Copy link
Author

Look pls at logs
Logs.txt

docker-compose-yml.txt

@Jonnik84
Copy link
Author

here is screenshot of modbus testing tool . everything works fine
image

@imbeacon
Copy link
Member

I have added fix for error from logs, could you pull new image from Dockerhub and try with it.

If new image won’t help, please try to access this port from the container.

to do this - you will need to enter to container CLI, install mbpoll there and try to read from it.:

docker exec -it tb-gateway bash
apt update && apt upgrade -y
apt install mbpoll
mbpoll -m rtu -a 1 -r 2 -b 9600 -d 8 -p none -s 1 /dev/ttyAMA0

@Jonnik84
Copy link
Author

Jonnik84 commented Jan 14, 2025

Thanks .. definately something changed... but still not working! Pls assist

modpoll is working fine inside container
But, I had to correct your string mbpoll -m rtu -a 1 -r 2 -b 9600 -d 8 -P none -s 1 /dev/ttyAMA0, so it could work:
-P parameter should be uppercase!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants