SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By quique
#195274
Currently I have this script on the Arduino, constantly sending info to the raspberry pi 2:
rpibluno.jpg
Code: Select all
float flow = 111.22;

void setup() {
  Serial.begin(9600);    // 9600 is the default baud rate for the serial Bluetooth module
}

void loop() {
  if (Serial.available()>0) {
    Serial.print(Serial.read());
    if (Serial.read() == 'S') {
      Serial.print(flow);
      Serial.write("\n");
    }
  }    
}
The rpi runs this script to receive the data:
Code: Select all
#! /usr/bin/env python

import serial
from time import sleep

ser = serial.Serial(
        port='/dev/serial0', baudrate = 9600,
        parity=serial.PARITY_NONE,
        stopbits=serial.STOPBITS_ONE,
        bytesize=serial.EIGHTBITS,
        timeout=0
        )

while 1:
        try:
                sleep(3)
                ser.write("S")
                myData = ser.readline()
                print myData
        except KeyboardInterrupt:
                exit()
The rpi is using bluetooth serial to communicate with the arduino. The pi and the bluno nano connect and I can send data from the serial monitor on the arduino IDE to the pi and it shows up in the pi terminal. But I am unable to send data from the pi to the Arduino in the form of:

1. In the python script, any ser.write() commands if they are AT commands are recognized by the pi's hm10 module because I get responses showing up in the pi terminal. However those AT commands are going from the python script to the hm10 module and from the hm10 module over bluetooth to the bluno nano, right? That is why when I do ser.write("AT+CONNL") the pi connects back to the bluno nano. But if I send ser.write("S") to the bluno nano and it IS INDEED receiving those commands, they would show up on the IDE serial monitor or at least elicit the response dictated in code, which is Serial.write(Serial.read()), which should send any received data on the bluno, back to the pi terminal. This doesnt happen.

2. Either that or, the data is being sent from the pi to the bluno nano but they are just not being interpreted or received correctly by the bluno.

Any ideas?
You do not have the required permissions to view the files attached to this post.