- Raspberry Pi Log Files
- Advanced Serial Data Logger
- Serial Data Logger Software
- Raspberry Pi Logging
- Serial Data Logger Free
Arduino or Raspberry Pi for data logging So before I go further into my questions i will explain the project: I am apart of collegiate design team as a mechanical engineer and I need to design a system to collect data using an array of sensors. I am new to Raspberry Pi, in fact, I am just about to order my module on Amazon. I was also going to purchase an event state counter/data logger (EL-USB-5 ) to interface with my RP, but an engineer friend stated that the RP could probably be programed to do the data logging by itself.
Active5 years, 3 months ago
How can we do serial communication using the raspberry pi with a python script to send/receive data to my laptop? If yes can we use the RS232 cable to connect to the TX/RX ports on the raspberry pi directly? If yes, what pins must be used from the RS232 cable? It would be help full if anyone can post a example python script?
Since my first aim is to send/receive data to the laptop to/from the raspberry pi, i'm using a RS232 to USB cable at both end to connect to the laptop as well as the raspberry pi.
tshepang6,5421919 gold badges7474 silver badges116116 bronze badges
RanduRandu
5 Answers
RS-232/RS-485 to PC and USB to PC
![Advanced serial data logger Advanced serial data logger](/uploads/1/2/5/0/125027968/603639659.jpg)
For RS-232
1) Download Putty.
2) Buy a Serial Port RS232 to TTL Converter Module and a RS-232 serial cable for PC.
3) Follow the steps in Connection to a microcontroller or other peripheral on this link. Actually read the whole thing for better understanding.
4) Power your converter module with either 3.3V (pin 1) or 5.0V (pin 2), connect Rxd pin of the module to Rxd (pin 8) on Rpi and Txd pin to Txd (pin 10) on Rpi. How to get spore free.
5) Connect your RS-232 (from PC) cable to the converter module
Now you are ready to do some coding in Python. But before that make sure that you have the library called serial for python to create the communication. You can easliy get it via terminal by typing sudo apt-get install python-serial. Also you will see the baudrate in the code is 7200. It could be less or more depending on the synchronization. Also make sure that baudrate should be same in putty and COM1, which is the port that RS-232 is connected to your PC. You can check and set it from device manager in Windows. By the way, timeout is the time gap between each message you are receiving.
In case you can't run the code from idle (that happens for some libraries), do it in terminal. For that go to the folder where you keep your python code and type python name.py.
For USB serial to PC
You have two options
First, you can buy a USB dongle for RS-232/RS-485 so that you would not use GPIO pins. But it is better to get a USB hub for all mouse, keyboard and dongle.
Second and easier, you can buy a FTDI USB to TTL converter and use GPIOs to have a serial communication with Rpi. The code for this is exactly the same the one with above. Connection for this is easy.
Module -- Rpi
Txd -- > Txd
Rxd -- > Rxd
Gnd ---> Gnd
Caglar SekmenCaglar Sekmen
Raspberry Pi Log Files
The Raspberry Pi's serial port uses 3.3v logic; RS232 uses 12v, so a level shifter would be needed to use those pins so you cannot use RS232 directly.
Serial interfacing in Python using the PySerial module (http://pyserial.sourceforge.net) it is pretty straightforward to send and recieve data. There are examples in the documentation, but essentially to send data:
Advanced Serial Data Logger
It depends what you're doing with the data and what sort of data you're recieving to decide the best way to recieve data, but a very simple example:
This simply waits until the number of bytes specified has been retrieved or the timeout value is reached.
You can use port.inWaiting() to return how many bytes are currently in the buffer.
beesbeesbeesbees
Are you trying to issue commands to the Raspberry Pi? (like a console?) I would suggest a plain jane 3.3V FTDI cable. You can get them from Digikey or Sparkfun. Note: the Raspberry Pi runs on 3.3V so you must be sure that anything you connect to it is running 3.3V or has a level shifter. See more information about level shifters here. (go down to the Logic voltage levels section)
First, you need to make sure that Raspbian has released the serial console. You can do that with the script located here.
If you're more interested with communicating with other devices then maybe the following suits you:
Serial Data Logger Software
Do you have an Arduino? You can run a simple test by putting this sketch on your Arduino:
And wire it up using the following diagram:
Note: make sure you don't connect a usb cable to the Arduino. It will be powered by the Raspberry Pi.
You can then install and run
screen
. Screen is a dead simple way of connecting to a serial port.Then run the following:
The screen will show up blank. But, when you start typing you will notice that the characters you're writing are getting looped back to your terminal.
Note: If the screen is still blank you should double check the connections (power led on the Arduino is a good thing to check).
When in doubt you can see my whole example here.
jaredwolffjaredwolff
you should install python library for serial drivers. you can not use rs232 directly, instead you can use a max232 chip in between rx(gpio15) tx(gpio 14) pins and your usb to serial converter. or you can use usb to ttl serial cable from adafruit. here is the link for setup : http://learn.adafruit.com/adafruits-raspberry-pi-lesson-5-using-a-console-cable/overview
shreyas_patel21shreyas_patel21
Serial Communication in Raspberry pi.
There are plenty of options for serial communication
- Use Visual GDB Plugin in visual studio and deploy code remotely in raspberry pi
and loop back the txd and rxd pins and check if the send message is received or not.
Raspberry Pi Logging
- If you are familiar with java Install pi4j and in the example folder there is a sample program , compile and run using terminal. and check the output.
- if you are connecting using RS232 and Max232 , please note that uses 3.3 volt not 5 or 12v. , it may burn your board.
Serial Data Logger Free
Arun ChandArun Chand