Go Down

Topic: bridge & sensor/device using serial communication (Read 1 time) previous topic - next topic

allairgoo

Some new sensors appear on the market. They are not simple sensor with "simple" voltage modification on a pin. They use serial communication, processors, like a device.
I have tested a PM dust laser sensor from dfrobot. It uses serial communication. It has it's library for Arduino.

The Wiki of the vendor has some words about this, my English is not precise but :
Because the laser PM2.5 sensor uses serial communication and DFRobot UNO R3 is only one independent serial ports, so you need to download arduino code and then plug the sensor , otherwise the program will have downloading problems.

I met some difficulties with a sketch using Bridge to give me access via Linux on the Yun to the datas of the laser sensor. Thinking it was a bug in the bridge library. So I opened a github issue where I got some very useful advice after tests.

May I precise that this is not a sketch problem: In this context (with this sensor/device) every simple sketch using bridge function (like console) was not working : crashing the python script on the yun. (see the github issue for details & tests), even after re-install of the Linino on the Yun.

This is sending/receiving on the serial port making all serial communication bogus. Please move communication with this sensor to SoftwareSerial. You did not ran into some bug, but a documentation issue: When using the bridge do not use serial communication to sensors or actuators on the same interface!(..) Every third party library that uses serial ports should provide a way of setting an arbitary serial port (even soft serial) before being accepted thru the library manager.

What do I need to make this sensor/device working with the Yun and access to its datas from the linux side.

allairgoo

via google I found some solution , maybe I could ask the vendor to adapt it's library with Yun SoftwareSerial



allairgoo

If I modify the Sketch to use SoftwareSerial

Code: [Select]

int length = serialRead(serial1, receiveDat, receiveDatIndex, 5);

by
Code: [Select]

int length = serialRead(mySerial, receiveDat, receiveDatIndex, 5);

 
pm10_laser_LCD.ino: In function 'void loop()':
pm10_laser_LCD.ino:44:67: error: no matching function for call to 'serialRead(SoftwareSerial&, uint8_t [24], int, int)'
pm10_laser_LCD.ino:44:67: note: candidates are:
In file included from pm10_laser_LCD.ino:6:0:
/Users/Rva/Documents/Arduino/libraries/serialReadPMValue/serialReadPMValue.h:16:9: note: uint8_t serialRead(HardwareSerial, uint8_t*, uint8_t, uint8_t)
uint8_t serialRead (HardwareSerial the_serial,
        ^
/Users/Rva/Documents/Arduino/libraries/serialReadPMValue/serialReadPMValue.h:16:9: note:   no known conversion for argument 1 from 'SoftwareSerial' to 'HardwareSerial'
/Users/Rva/Documents/Arduino/libraries/serialReadPMValue/serialReadPMValue.h:24:9: note: uint8_t serialRead(Serial_, uint8_t*, uint8_t, uint8_t)
uint8_t serialRead (Serial_ the_serial,
        ^
/Users/Rva/Documents/Arduino/libraries/serialReadPMValue/serialReadPMValue.h:24:9: note:   no known conversion for argument 1 from 'SoftwareSerial' to 'Serial_'
no matching function for call to 'serialRead(SoftwareSerial&, uint8_t [24], int, int)'


Go Up