Giter Club home page Giter Club logo

Comments (10)

rnestler avatar rnestler commented on June 18, 2024

Errors such as "previous declaration as 'typedef short unsigned int u16' typedef unsigned short u16"
If I delete the u16 typedef I get "sensirion_uart.h:61: error: unknown type name 'u16'"

Could you try and replace the typedef in sensirion_arch_config.h with the previous declaration of the Arduino library: typedef short unsigned int u16.

from embedded-uart-sps.

paultanner avatar paultanner commented on June 18, 2024

Thx @rnestler
That did the trick

//typedef uint16_t u16;
typedef short unsigned int u16;

Compiles for 3 arduinos that I tried.

from embedded-uart-sps.

paultanner avatar paultanner commented on June 18, 2024

Whoops. I then realised that I had not compiled in the specific sensirion_uart_implementation.cpp for arduino. This references a struct type called "Uart" which is not defined

'Uart' does not name a type
 Uart Serial2 (&sercom1, PIN_UART_RX, PIN_UART_TX, SERCOM_RX_PAD_0, 

Looking for this in the distribution but not finding it.
Any suggestions please.

from embedded-uart-sps.

psachs avatar psachs commented on June 18, 2024

The sample implementation was done for a Arduino M0 Pro with a ATSAMD21 and will not work on any Arduino board. Depending on the Arduino board a different approach is needed.

Since each serial port can only be used for one device, we can not use the same serial port for the SPS30 as we use to connect the PC with the Arduino for programming and debugging.

Since Arduino has different variations there is no generic solution that works for all boards. If your board already has a second (or even more) serial ports, you can just use that one.

You can check if your boards support the SoftwareSerial or AltSoftSerial library
https://www.arduino.cc/en/Reference/SoftwareSerial
https://www.pjrc.com/teensy/td_libs_AltSoftSerial.html

Let us know what Arduino boards you are using and if one of those libraries worked. Of course you have to adapt the sample implementation to use the library.

from embedded-uart-sps.

paultanner avatar paultanner commented on June 18, 2024

Thx @psachs
The boards I have do support softserial but I was thinking of using a leonardo which has 2 hardware serial ports.
So, if I understand you, no one has contributed implementations that use these standard boards so I need to write the code into sensirion_uart_implementation.c
Correct?

from embedded-uart-sps.

abrauchli avatar abrauchli commented on June 18, 2024

Thx @psachs
The boards I have do support softserial but I was thinking of using a leonardo which has 2 hardware serial ports.
So, if I understand you, no one has contributed implementations that use these standard boards so I need to write the code into sensirion_uart_implementation.c
Correct?

Spot on.

For the Leonardo it actually shouldn't be that bad:

Quote from https://www.arduino.cc/reference/en/language/functions/communication/serial/

The Arduino Leonardo board uses Serial1 to communicate via TTL (5V) serial on pins 0 (RX) and 1 (TX). Serial is reserved for USB CDC communication. For more information, refer to the Leonardo getting started page and hardware page.

Most of the example may still be valid if you remove the definition for Serial2 on L56, remove the SERCOM1_Handler function on L59 and replace all remaining instances of Serial2 with Serial1. One notable exception is sensirion_uart_open which should become much simpler:

s16 sensirion_uart_open() {
  Serial1.begin(BAUDRATE);
  return 0;
}

The defines PIN_UART_RX and PIN_UART_TX are wrong (should be 0 and 1) but they're also not used anymore..

Good luck, let us know if that works.

from embedded-uart-sps.

paultanner avatar paultanner commented on June 18, 2024

Thx @abrauchli
All pretty obvious once you realise what the distribution is supposed to be
The adapted code as you suggested compiles and seems to work OK on Leonardo
I'm posting it here now it's tested.
sensirion_hw_i2c_implementation.cpp.zip
My confusion was that the readme explained only part of the process. As there are many arduinos there could be folder full of implementations (or better one with a lot of conditionals).

from embedded-uart-sps.

abrauchli avatar abrauchli commented on June 18, 2024

Hi @paultanner, thanks for the feedback. We are trying to improve the situation for Arduino and provide ready-to-use samples for different boards, so we'd be glad to get a tested config for yours as well. Feel free to take a look or review the Arduino-specific README Sensirion/embedded-common#15 (it's for the i2c variants for now, but most things apply to the UART version as well).

from embedded-uart-sps.

abrauchli avatar abrauchli commented on June 18, 2024

Related to #17

from embedded-uart-sps.

psachs avatar psachs commented on June 18, 2024

We do have Arduino libraries for most of our newer sensors available.

from embedded-uart-sps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.