Hi all, im trying to use the sensirion library to read humidity from 2 sensors, from what I read is that you can share clock lines but have different data lines for each sensor.
Using the code in the example to declare the pins used, and get a reading from the sensor
uint8_t dataPin = 2;
uint8_t clockPin = 3;
Sensirion tempSensor = Sensirion(dataPin, clockPin);
tempSensor.measure(&temperature_sensor0, &humidity_sensor0, &dewpoint_sensor0);
how do I go about re-declaring the data pin after, if I do it gives me an error.
redeclaration of 'Sensirion tempSensor'
system
January 27, 2014, 10:43am
2
how do I go about re-declaring the data pin after, if I do it gives me an error.
redeclaration of 'Sensirion tempSensor'
You need to fix your code, then. We can't see how you are attempting to change the code.
But, I would guess that you don't understand that you you need two instances of the class to read two sensors.
All I did was reuse this
uint8_t dataPin = 2;
uint8_t clockPin = 3;
Sensirion tempSensor = Sensirion(dataPin, clockPin);
changed the datapin to a different one, but it didn't work
Is a class the same as a library? (Im still new to Arduino) do I need to have a second copy of the library in-order to read a second sensor?
system
January 27, 2014, 1:47pm
4
Is a class the same as a library?
No. A library may define and implement a class or it may just provide a collection of functions.
do I need to have a second copy of the library in-order to read a second sensor?
No. You need to make a second instance of the class contained in the library. Like so:
Sensirion outdoorSensor = Sensirion(outdoorDataPin, clockPin);
Sensirion indoorSensor = Sensirion(indoorDataPin, clockPin);
Thank you, with that help I figured it out!