[SOLVED]Send Serial ASCII string to Web Server

  • I have a lopy with expansion board I have connected pin 4 of the lopy to pin 3 (tx) of a serial cable aswell as ground to ground. I am using cmd echo hello > COM9 from windows shell, but I get as a hex string as an output.


    import machine

    uart1 = machine.UART(1, baudrate=9600, bits=8, parity=None, stop=1)

    while True:

    Is this expected output? My goal is my family has a weigh station and want to have the weight displayed in their office which is 10m away from weigh machine. The weigh station out puts ASCII string via RS-232 connection as follows
    STX: Start of transmission character (ASCII 02)
    ETX: End of transmission character (ASCII 03)
    SIGN: The sign of the weight reading (space for positive, dash (-) for negative)
    WEIGHT(7): A seven character string containing the current weight including decimal point, then first character isa space. Leading zero blanking applies.
    STATUS: Provides information on the weight reading. The characters G?N?U?O?M?E represent Gross/ Net/ Underload/ Overload/ Motion/ Error.

    If the output is in HEX how can I represent this to POST in usable data? Can I use ubinascii conversion?

    Any help would be great.

  • @livius @jcaron <SOLVED>

    I managed to get this to work thanks to your help, used a sparkfun MAX3232 to step down the RS232 to UART and ASCII strings appear as expected and was able to upload them to a web server.

  • @livius thanks I have a bunch of these lying around will give that a try thanks everyone

  • @jcaron damn that makes sense, so I would need some kind of step down can this be done by an ardiuno I have one lying around.

  • @jcaron
    I ommit that he say about RS232!

    RS232 is not an UART. And 5V levels can kill your lopy board it is 3V3 device.
    If you need to connect it to your PC use TTL converter e.g. USB->UART.
    You then can have virtual COM on your PC.

  • Isn’t there an issue with levels? I.e. +/- 5V for regular serial port compared to 0/3V for the LoPy or something similar?

  • @livius Yes my tx is on pin4 and rx on p3. I will try without expansion board thanks.

  • @jimpower
    Then only some wiring problem must be.
    You have connected P4 which is default RX for UART1 with TX of your serial converter
    For test connect also RX from converter to TX (P3). And look if all is ok.
    And if possible test Lopy without expansion board.

  • @livius


    I sent plain text hello with same garbage response

  • @jimpower
    no this looks like garbage
    what is your putty com settings?
    alt text


    can you clarify this

    I used putty and got this output from
    set /p x="hello world" <nul >.\COM9

    above command can be run from windows CMD after setting com settings by mode command
    you can not run it from putty it send this as text

  • @livius

    Thanks for your reply,

    I used putty and got this output from

    set /p x="hello world" <nul >\.\COM9


    Does this look accurate?

  • @jimpower said in Send Serial ASCII string to Web Server:


    this is not hello sentence
    first look if you have same port configuration on PC

    type mode into command line and look like is your port really configured
    it can be different than showing in device manager ;-)

    to see how to configure port, type

    mode /?


    mode COM1 BAUD=9600 PARITY=n DATA=8 STOP=1 rts=off cts=off

    and to send data from command without line break and spaces use

    set /p x="hello world" <nul >\\.\COM1

    but better use any com port software like putty, comport monitor from Arduino IDE ...

Log in to reply

Pycom on Twitter

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.