Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pi3 serial communication
#1
Hello, I have this two pieces of codes, It is used to communicate between pi 3 and Arduno via HC-0% bluetooth. It was work about a year ago but now I try to use it it stop workin and I can't figure why,
on the python side:
#! /usr/local/bin/python3
 
import serial
from time import sleep
# for Linux
#bt_ser = serial.Serial("/dev/rfcomm0", baudrate=38400)
# for Mac
bt_ser = serial.Serial("/dev/tty.HC_05_1-DevB", baudrate=38400) #/dev/tty.HC_05_1-DevB
bt_ser.write(str.encode('1'))
duino_data=bt_ser.readline()
print (duino_data)

on the arduino sketch
#include <SoftwareSerial.h>
 
SoftwareSerial mySerial(10, 11); // RX, TX (on Arduino)



void setup()
{
  // Open serial communications and wait for port to open:
  mySerial.begin(38400);
  pinMode(13, OUTPUT);
}
 
void loop() // run over and over
{
  if (mySerial.available()) {
    //if(mySerial.read()==1) {
      mySerial.println("Hello from Duino");
      digitalWrite(13, HIGH); // turn on
      //digitalWrite(13, HIGH); // turn on
      
    //}
    digitalWrite(13, HIGH); // turn on
  }
    
    delay(1000);
}
Here when I run the python code, it does turn on the LED on the Arduino, which means the data was sent out, but what did I send out? a string '1'? And it never get the "Hello from Duino" string back from Arduino. What is wrong with my code? Thanks
Reply


Messages In This Thread
pi3 serial communication - by tony1812 - Sep-23-2018, 10:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pyserial/serial "has no attribute 'Serial' " gowb0w 9 4,334 Aug-24-2023, 07:56 AM
Last Post: gowb0w
  packet radio communication EmpireAndrew 1 2,209 Nov-01-2019, 06:35 PM
Last Post: micseydel
  WiFi communication Milad 2 2,501 Sep-07-2019, 11:53 AM
Last Post: ndc85430
  Serial communication with raspberry pi 3B and Xbee kj7 0 2,190 Mar-25-2019, 03:39 AM
Last Post: kj7
  Serial Communication Error AlphyOuseph 1 3,559 Feb-07-2019, 07:16 AM
Last Post: DeaD_EyE
  python-osc communication fauveboy 10 10,293 Jul-23-2018, 07:49 PM
Last Post: buran
  serial communication write(comand) and read(result) ricardons 1 2,930 Mar-01-2018, 04:26 PM
Last Post: mpd
  Serial communication with a board Bokka 2 5,381 Dec-07-2017, 07:34 AM
Last Post: Bokka
  code pattern for process communication Skaperen 12 8,572 Oct-08-2017, 03:14 AM
Last Post: Skaperen
  Serial port communication FatimaSameer 1 3,243 Oct-03-2017, 09:47 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020