Cooking Hacks Forum
https://www.cooking-hacks.com/forum/

4-20mA Current Loop - Raspberry Pi Issue
https://www.cooking-hacks.com/forum/viewtopic.php?f=23&t=6533
Page 1 of 1

Author:  hp3525 [ Mon Dec 08, 2014 11:30 pm ]
Post subject:  4-20mA Current Loop - Raspberry Pi Issue

Hello,

I am using the 4-20mA sensor board. I have followed your tutorial and have made the board work with Arduino. Easy to do, Great!

In reality, I need to make the sensor board work with Raspberry Pi. I have followed your tutorial from downloading the arduPi library and currentLoop library. I just want to run the "4_20_connectionstate.o" example. I can compile the code without any error messages using the following ---> g++ 4_20_connectionstate.cpp arduPi.cpp currentLoop.cpp -o 4_20_connectionstate. I execute the output with the command ---> sudo ./4_20_connectionstate.o.

Here is the problem, the output always returns the following regardless of channel selected or if the sensor is ON, OFF, or even connected ---> Voltage = 5.001992 V, Current = 20.143232 mA. Besides testing each channel, I have not edited the code.

The arduPi and currentLoop libraries are saved in the same folder.

Any ideas why this is happening? Could you suggest anything for me to try? I am doubtful that my RPi is defective, I have run some python scripts controlling the GPIO pins.

Thanks in advance for any help because I couldn't find a similar forum question.

hp3525

Author:  libelium-dev [ Tue Dec 09, 2014 9:09 am ]
Post subject:  Re: 4-20mA Current Loop - Raspberry Pi Issue

Hello hp3525,

try with these lines:
Code:
g++ -c arduPi.cpp -o arduPi.o

g++ -c currentLoop.cpp -o currentLoop.o

g++ -lpthread -lrt 4_20_connectionstate.cpp arduPi.cpp currentLoop.cpp -o 4_20_connectionstate


You didn't include the words "-lpthread -lrt". Besides this, you should not get a "4_20_connectionstate.o" but a "4_20_connectionstate" file.

So now you must write:
Code:
sudo ./4_20_connectionstate


Regards

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/