Shop OBEX P1 Docs P2 Docs Learn Events
Code ideas for reading two 20818 Sensirion SHT11 sensors? — Parallax Forums

Code ideas for reading two 20818 Sensirion SHT11 sensors?

uxoriousuxorious Posts: 126
edited 2008-12-27 11:10 in General Discussion
I am trying to make a simple circuit to read two of Parallax's 20818 SHT11, but keep running into all sorts of problems. I am looking for any ideas for running the sample program from Parallax to two separate sensors. (one indoor at the board and one outdoor on a 30 foot long phone cord)I tried to convert the data and clock to a variable and just run the main program twice with a for-next loop. I couldn't get things to work right after working on it for a few hours. I tried to go back to it today only to find out I cannot find my USB memory stick where my code was. cry.gif
Anybody have any ideas before I start over at square one?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
~~ dRu ~~

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-02-08 08:01
    dRu -

    I would start by using the sample programs provided by Parallax on their web site, and work from there. Here are some additional application notes provided by Dr. Tracy Allen on his web site: http://www.emesystems.com/OL2sht1x.htm

    I hope that gets you going again.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There is no pleasure in having nothing to do;
    the fun is in having lots to do, and not doing it!
  • FranklinFranklin Posts: 4,747
    edited 2008-02-09 01:47
    Try the code with only one sensor connected then remove that one and try the other if they both work alone attach your code and we can have a look.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • uxoriousuxorious Posts: 126
    edited 2008-02-10 06:12
    Thanks for the replies. I have no problem with usage of the sensors. I have a few different programs to do different things with the sensor (logging, screen display, etc). I am just having trouble with reading two sensors in the same code. I will work on getting my code back to where I was stuck and post it. I know I can just duplicate the entire main section of the program and use different pins (IE: have a data1 and data2, clk1 and clk2) for the two sensors. I was trying to use a variable to make use of the same chunk of program code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ~~ dRu ~~
  • FranklinFranklin Posts: 4,747
    edited 2008-02-10 18:08
    You can always assign the pins to variables before you run the code. using the same code with the same variable assigned to a different pin. clk = 1 the first time then clk = 2.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2008-12-27 11:10
    Just stumbled across this thread while doing research on my current project of a 12 sensor network on a single BS2P40. I am also trying to find the cleanest way to communicate to multiple SHT11 devices, without using individual I/O pins for each. Here's what my research has come up with so far. I haven't decided if I will be controlling the selection at the BS2P40 end of the cable or at the SHT11 end.

    1, Uses 14 I/O pins)
    Connect all devices to same IO for SCK/DATA and to GND. Use individual I/O pins to power (VDD) each device, one at a time. BS2P40 can source 30mA, SHT11 needs 0.55mA for a reading. Unsure about this as a trustworthy option even though all specs say it should.

    2, Uses 13 pins)
    Connect all devices to same IO for DATA and to VDD/GND. Use individual I/O pins to clock (SCK) each device, one at a time.

    3, Uses 3 I/O pins)
    Use an I2C addressable switch (IE: Analog ADG715, but less channels)? The SHT11 clock can sit on an I2C bus without interfering, so I can use the I2C switch to power on the SHT11, use the SHT11 protocol to do the reading, then use I2C to turn off the SHT11. The SHT11 still needs its own data line.

    4, Uses 6 pins)
    Use multiplexers, 74AC251, etc., and just control which device is clocked. 4 I/O for the addressing of 12 sensors.

    5) Play around with the "reserved" bits of the status register or the NoConnect pins to see if addressability exists on the devices already even though it's listed as a future concept. Unlikely...

    6, uses 2 I/O pins)
    Add a small MCU at the sensor end to communicate with the SHT11 and BS2P40. Use I2C, SPI, or ? and program the sensor MCU with an address. Use an ATTiny, PSoC, PIC16, or other very inexpensive MCU (~$1) This MCU could also be setup to just send the readings as a text string (IE: 085046 = 85F, 46% ??)

    on a side note with multiplexing, I think I only need to separate them for the reading. I should be able to "broadcast" a "take a reading" command to all devices at the same time since they store the reading and wait in idle mode for the read request. That should work, but I need to doublecheck the effect of ignoring ACKs. (?)

    ps. see my code for two sensors here: http://forums.parallax.com/showthread.php?p=690671

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andrew Williams
    WBA Consulting
    IT / Web / PCB / Audio
Sign In or Register to comment.