We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello again, after working successfully for a couple of days on the serial comm between arduino and the pi3, (receiving data) i stumbled upon this problem accidentally... i use the serial event to parse incoming data, which is in a sligtly format than the outgoing data. for example, to receive a "setpoint" variable my arduino sends this on serial with println:
SP2
the raspberry parses succesfully and sets the SP value to 2 changing the value of SP to 3 on the arduino it expects to see this on its serial port:
SP;3
so on the raspberry side i do myPort.write("SP;3\n")
and i get a serialevent parse error, after doing some debug prints, i see that the data is not at all sent to the arduino, but the write command triggers the serialevent which catches the "SP;3" command!!
is this a bug? is the serialevent supposed to be triggered upon the write command? i'm so puzzled, if this is so how can i send out data through my serial at all? Could this be a hardware connection issue? i'm using this voltage divider:
https://oscarliang.com/ctt/uploads/2013/05/arduino-raspberry-pi-serial-connect-schematics.jpg
thank you, Vangelis
Answers
Well, definitely not a bug...! since i wrote about it i got the idea to test the wiring and.... if i use a common ground i can send to the arduino but not receive from it. if i disconnect the common ground i can read from the arduino but not send to it, and that's the trap i fell into! without the common ground connected, the data sent was returning thus triggering the serialevent and the rest of errors.
so i'll have to build a better circuit for communications, i guess i'll have to try a transistor level converter! i'm very comfortable with wiring and breadboards and PCBs, has anyone tried any schematics on the net to recommend one? i wouldn't really mind trying one instead of ordering one :D
after trying out a couple of shematics, this is the only one that worked for me :)
civrays.com/images/serial_schematic.png
i didn't have any spare 2N2222 but used 2N5088 instead, and i guess 2N3904 would do. Works like a charm! in case this helps someone, don't forget to connect pi ground to arduino ground! thank you civrays!