Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 17:11 03 Sep 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : how do make so picomite accept serial data from python over usb

Author Message
tenij000
Regular Member

Joined: 30/05/2025
Location: Netherlands
Posts: 51
Posted: 12:42pm 05 Aug 2025
Copy link to clipboard 
Print this post

how do make so picomite accept serial data from python over usb

this program works if data is incoming on the gpio pins



' Slave PicoMite (ONTVANGER) - Minimalistische UART test met correcte SETPIN syntax
' Ontvangt een bericht via COM1 (UART0) op GP0 (TX) en GP1 (RX)

' **BELANGRIJK: Definieer de UART pinnen met SETPIN volgens de nu werkende syntax**
' SETPIN RX_PIN, TX_PIN, COM_CHANNEL_STRING
SetPin GP1,GP0,com1

' Open de COM1 poort op 9600 baud.
Open "COM1:9600" As #1

Print "Slave PicoMite: Start. Wachten op data van Master (op GP1 (RX))."
Print "Verbind Teraterm met deze PicoMite's COM poort voor output."

Dim RX_MSG$ ' Variabele om het ontvangen bericht in op te slaan

Do
   ' Controleer of er data is in de input buffer van COM1.
   If Lof(1) > 0 Then
       ' Lees een volledige regel (tot een newline) vanaf de UART.
       Line Input #1, RX_MSG$

       ' Print het ontvangen bericht naar de console van de Slave PicoMite.
       Print "Ontvangen: " + RX_MSG$

   End If
   If RX_MSG$ = "Zon" Then
       Print "ZON"
   End If
   
   If RX_MSG$ = "water" Then
       Print "WATER"
   End If
   
   Pause 10 ' Korte pauze om de processor te ontlasten
Loop

' MMBasic sluit de poort automatisch bij een nieuw programma of stroomuitval.
 
mozzie
Senior Member

Joined: 15/06/2020
Location: Australia
Posts: 171
Posted: 03:35pm 07 Aug 2025
Copy link to clipboard 
Print this post

G'day Tenij,
The console / USB serial connection on the PicoMite is #0, so you need to point at this for any (USB) serial data i/o

Also LOF() is the transmit data buffer, LOC() is the receive buffer.

I find the following the best starting point, it will echo anything received back to sender, always my goto as a first test  


'program to test USB Serial comms

Do
 If Loc(0)>0 Then
   Print Inkey$;
 EndIf
Loop

End


Hope this helps,
Regards,
Lyle.
Edited 2025-08-08 01:55 by mozzie
 
tenij000
Regular Member

Joined: 30/05/2025
Location: Netherlands
Posts: 51
Posted: 11:45am 10 Aug 2025
Copy link to clipboard 
Print this post

cool
Edited 2025-08-10 22:03 by tenij000
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025