Beto_Ismael
Posts: 5
Joined: Tue Sep 11, 2018 6:40 pm

Raspberry PI 3+ serial connection to WindSonic sensor, help needed.

Tue Sep 11, 2018 7:00 pm

hello people, I am new to what is rapsberry and in the company that I work my boss asks me to connect the raspberry PI 3 with a Windsonic sensor which communicates by RS-232.

My idea is to occupy the ports of my pi 3 (10 RX and 8TX).
I know that the RX and TX ports tolerate a voltage ttl, for this I am occupying a rs 232 converter at lower reading levels without damaging the pi 3.

then get the reading data reflected on the screen or support me with some python code to save this data.

The truth is that I do not know where to start...

I beg you, help :(

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 10938
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Raspberry PI 3+ serial connection to WindSonic sensor

Wed Sep 12, 2018 9:58 am

Note that the RPI serial input is NOT "TTL", compatible it is using 3V3 logic, not 5V (TTL) PI's are not 5V tolerant.
You need an RS232 converter that uses 3V3 levels, (based for example on a MAX3232) or you will still damage your PI.

Also people who want to say TTL can mean its using 3V3, then let me just say I think not.... 74xx 74LSxx and 74HCTxx logic (which are considered as using "TTL levels") all output 5V signals by definition.

B.Goode
Posts: 6455
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Raspberry PI 3+ serial connection to WindSonic sensor

Wed Sep 12, 2018 10:10 am

The truth is that I do not know where to start...


The relevant Raspberry Pi Foundation documentation is here: https://www.raspberrypi.org/documentati ... on/uart.md

Start in the same way you would with any other hardware/OS platform for the same purpose. For me, that would mean checking data paths to/from the RPi with a hardware data loopback test, then moving on to visually checking data acquisition from the external device, and finally to processing, displaying or storing the sensor data.

Beto_Ismael
Posts: 5
Joined: Tue Sep 11, 2018 6:40 pm

Re: Raspberry PI 3+ serial connection to WindSonic sensor

Wed Sep 12, 2018 2:05 pm

mahjongg wrote:
Wed Sep 12, 2018 9:58 am
Note that the RPI serial input is NOT "TTL", compatible it is using 3V3 logic, not 5V (TTL) PI's are not 5V tolerant.
You need an RS232 converter that uses 3V3 levels, (based for example on a MAX3232) or you will still damage your PI.

Also people who want to say TTL can mean its using 3V3, then let me just say I think not.... 74xx 74LSxx and 74HCTxx logic (which are considered as using "TTL levels") all output 5V signals by definition.

I am using this converter https://www.mcielectronics.cl/website_M ... er_SMD.pdf

Beto_Ismael
Posts: 5
Joined: Tue Sep 11, 2018 6:40 pm

Re: Raspberry PI 3+ serial connection to WindSonic sensor, help needed.

Thu Sep 13, 2018 8:15 pm

some idea?? really i cant read the serial port

B.Goode
Posts: 6455
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Raspberry PI 3+ serial connection to WindSonic sensor, help needed.

Thu Sep 13, 2018 9:02 pm

Try a usb serial port adaptor instead, as mentioned in the Raspberry Pi Foundation documentation already mentioned?

Beto_Ismael
Posts: 5
Joined: Tue Sep 11, 2018 6:40 pm

Re: Raspberry PI 3+ serial connection to WindSonic sensor, help needed.

Fri Sep 14, 2018 1:51 pm

B.Goode wrote:
Thu Sep 13, 2018 9:02 pm
Try a usb serial port adaptor instead, as mentioned in the Raspberry Pi Foundation documentation already mentioned?
when i use a usb converter rs 232 to usb directly to the notebook i can read the data, but i need to use rapsberry to be able to work with it on new development projects without the need of pc windows

Beto_Ismael
Posts: 5
Joined: Tue Sep 11, 2018 6:40 pm

Re: Raspberry PI 3+ serial connection to WindSonic sensor, help needed.

Fri Sep 14, 2018 1:52 pm

this is state of my pi 3:

Code: Select all

[email protected]:~ $ ls -lh /dev/serial0
lrwxrwxrwx 1 root root 7 sep 13 17:38 /dev/serial0 -> ttyAMA0
[email protected]:~ $ ls -lh /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 sep 13 17:38 /dev/ttyS0
[email protected]:~ $ dmesg | grep tty
[    0.000000] Kernel command line: 8250.nr_uarts=1 bcm2708_fb.fbwidth=800 bcm2708_fb.fbhe        ight=480 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000  dwc_ot        g.lpm_enable=0 console=tty1 root=PARTUUID=58cc10f9-02 rootfstype=ext4 elevator=deadline fs        ck.repair=yes rootwait quiet splash plymouth.ignore-serial-consoles
[    0.000148] console [tty1] enabled
[    0.545537] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a         PL011 rev2
[    0.546439] 3f215040.serial: ttyS0 at MMIO 0x0 (irq = 166, base_baud = 31250000) is a 1        6550
[email protected]:~ $

B.Goode
Posts: 6455
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Raspberry PI 3+ serial connection to WindSonic sensor, help needed.

Fri Sep 14, 2018 4:29 pm

Beto_Ismael wrote:
Fri Sep 14, 2018 1:51 pm
B.Goode wrote:
Thu Sep 13, 2018 9:02 pm
Try a usb serial port adaptor instead, as mentioned in the Raspberry Pi Foundation documentation already mentioned?
when i use a usb converter rs 232 to usb directly to the notebook i can read the data, but i need to use rapsberry to be able to work with it on new development projects without the need of pc windows


You haven't previously mentioned a Notebook or Microsoft Windows, so I don't think any reply will have assumed their availabilty or use.

But since you have a usb serial converter available, is there any reason for not trying it with the RPi? The most common convertors have support already implemented within linux so maybe no additional drivers or software would be needed.

Idahowalker
Posts: 333
Joined: Wed Jan 03, 2018 5:43 pm

Re: Raspberry PI 3+ serial connection to WindSonic sensor, help needed.

Fri Sep 14, 2018 5:19 pm

I'm just silly but have you configured the serial port of the Pi to be used as a serial port and have you successfully did a loop back test, before trying to communicate with the outside world?

Code: Select all

import serial


sPortToUse = "/dev/serial0"
#sPortToUse = "/dev/ttyAMA0"


sTest = "Bad Boys Race Our Young Girls Behind Victory Garden Walls Get Started Now".encode('utf-8')
#sTest = b"Bad Boys Race Our Young Girls Behind Victory Garden Walls Get Started Now"

sReceive = b""

iBytesSent = 4

serialPort = serial.Serial(sPortToUse, 9600, timeout = 2)
serialPort.flushOutput()
serialPort.flushInput()
if serialPort.open:
    print("Opened port", sPortToUse)
    #iBytesSent = serialPort.write(sTest)
    #print ("Sent", iBytesSent, "bytes")
    #sReceive = serialPort.read(iBytesSent)
    sReceive = serialPort.readline()
    #if sReceive == sTest:
        #print ("Received", len(sReceive), "bytes on, serial port", sPortToUse)
        #print (sReceive.decode('utf-8'))print
    print (sReceive.decode('utf-8')) 
    #else:
        #print ("Receive error", sReceive, "over", sPortToUse)
else:
    print("Port", sPortToUse, "failed to open")
serialPort.close()
About configuring the serial port, try an entry into your favorite search engine.

To use the above code, put a wire between Rx and Tx, after you get the serial port configured, and run the code. you may have to try sPortToUse = "/dev/ttyAMA0" if sPortToUse = "/dev/serial0" does not work.

Also, I spent quite some time with configuring the serial port to work as it seems that what worked for one person did not work for me. Thus, it was make a change, run the code, make a change, run the code...

Next, you can buy some voltage level shifter, use a resistor divider network, or build you own voltage level shifters. I choose to build my own after trying out the commercially available devices. With the build my own, I get a reliable baud rate of 230400.

Image

They are bi-directional and default to a logic level high.
Being a programmer: She says go to the store get 1 bottle of milk, if they have eggs bring back 6. She gets mad cause I brought back 6 bottles of milk.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 10938
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Raspberry PI 3+ serial connection to WindSonic sensor

Sat Sep 15, 2018 8:55 pm

Beto_Ismael wrote:
Wed Sep 12, 2018 2:05 pm
mahjongg wrote:
Wed Sep 12, 2018 9:58 am
Note that the RPI serial input is NOT "TTL", compatible it is using 3V3 logic, not 5V (TTL) PI's are not 5V tolerant.
You need an RS232 converter that uses 3V3 levels, (based for example on a MAX3232) or you will still damage your PI.

Also people who want to say TTL can mean its using 3V3, then let me just say I think not.... 74xx 74LSxx and 74HCTxx logic (which are considered as using "TTL levels") all output 5V signals by definition.

I am using this converter https://www.mcielectronics.cl/website_M ... er_SMD.pdf
did you power the board with VCC = 3.3Volt? if you used VCC = 5V, then you might have damaged your PI!
Also, this is not a very good RS232 to "TTL" converter, and it might not work. If you power it with 3V3, the "positive" RS232 signal will also be only be 3.3V, not the normal 10V or so, if you power it with 5V, the positive RS232 signal goes up a but, but not to RS232 levels, and the receive "TTL" signal goes up to 5V, which is fatal for a PI..
a board based on the MAX3232 will be much better. it internally generates the needed RS232 signals, while using 3V3 signals on the "TTL" side.

on the PI side, perhaps you can simply connect RX to TX, to check with a serial terminal emulator program (putty) if your serial port still works.

Return to “Automation, sensing and robotics”

Who is online

Users browsing this forum: No registered users and 15 guests