Communication Help from Arduino to Raspberry Pi

Here is my setup:
Raspberry Pi B
|
|
Arduberry
|
|
Hygrometer

I have no issues sending data to the Arduberry and doing an action. My problem is reading data back from the Arduino to display on the Pi.

Here is my Pi python code:

import requests
import serial
import syslog
import time

ser = serial.Serial('/dev/ttyAMA0' ,9600)
print('Start Logic')
time.sleep(2)
print('Write to Arduino')
ser.write('g')
while True:
     print ser.read()

I also tried ser.readline() to no avail. I think the issue is within this python code but I'm not certain.

Here is my Arduino code:

int soil = 0;
char input;

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ;
  }
}

void loop() {

  if(Serial.available() > 0){
    input = Serial.read();
    Serial.print("Arduino heard: ");
    Serial.println(input);
    
    switch (input) {
      case 'g':
          Serial.println("Working...");
          int sensorValue = analogRead(0);
          sensorValue = constrain(sensorValue, 485, 1023);
          
          soil = map(sensorValue, 485, 1023, 100, 0);
          delay(5000);
          Serial.println(soil);
          //Serial.println("%");
          //Serial.println(sensorValue);
          //delay(1000
    }
    delay(100);
  }
}

Any and all help is greatly appreciated. Thanks in advance!

I opened up a very slow website to find out what an Arduberry is and it told me nothing.

What is an Arduberry?

With a normal Arduino the Python code must allow time for the Arduino to reset when the serial port is opened. This Python - Arduino demo illustrates the issue.

...R

The Arduberry is a shield for the Raspberry Pi that connects Arduino Shields.
http://www.dexterindustries.com/site/?product=arduberry-raspberry-pi-arduino-shields

The while loop takes care of any delay, I manually wait 10 seconds or so before trying to send/retrieve data. I wonder if it has something to do with me trying to grab analog input data and that being the data I want to send back. Does it need to be encoded/decoded before being sent back to the pi?

That's a different webpage than the one I looked at but it still has no useful information. I am amazed by how many websites think moving images are more useful than actual data.

Is an Arduberry an Arduino board with an Atmega microprocessor - if so which one?

OR is it just a dumb interface between an RPi and Arduino compatible shields. If so I can't see how your question is an Arduino question.

...R

I know, websites are overly complex these days.

It is running Atmega328

Here is a report with some details on it: Arduberry Brings Arduino To Raspberry Pi - Codeduino

So uh, I pulled a NOOB. Apparently you cannot monitor the serial connection and communicate at the same time. Problem solved. Wow, this was a real dumb solution. Sorry I wasted your time :frowning:

tjc19999:
Apparently you cannot monitor the serial connection and communicate at the same time.

It sounds like the communication between the RPi and the Arduberry is similar to communication between a PC and an Uno - just one serial connection.

You should be able to write Python code that prints the responses from the Arduberry for debugging purposes.

You could, perhaps, include a special character in the debug messages so the Python code could separate them from other data.

The Arduberry seems like a clever idea. Surely someone has written a user manual for it?

...R