adafruit HTU21D I2C setup on udoo quad?

Discussion in 'General Discussion' started by mattt, Sep 4, 2014.

  1. mattt

    mattt New Member

    Joined:
    Sep 4, 2014
    Messages:
    5
    Likes Received:
    1
    Hi, I've been trying to setup a simple I2C adafruit HTU21D temp/hum sensor so I can read sensor values using python. Initially I wanted to read the sensor value using python smbus but trying to understand how to enable the udoo's i2c by reading the manual I found completely confusing. I am unsure whether I have to recompile the kernel to do this or not. This seems overly complicated and time consuming just to read values through i2c. I have tried uploading a sample sketch to the SAM and had no success either.

    I have the sensor connected to 3V3 SCL1 SDA1 and GND on the same header as SCL1 SDA1. The sensor's I2c address is 0x40. While using i2cdetect -l I have i2c-0, i2c-1, i2c-2 but the sensor will not show when I search for the sensor using i2cdetect. I have exhausted google search to find a basic tutorial on using i2c on udoo and haven't found anything of use. Any help would be appreciated.

    This is the example sketch

    Code:
    /*************************************************** 
      This is an example for the HTU21D-F Humidity & Temp Sensor
    
      Designed specifically to work with the HTU21D-F sensor from Adafruit
      ----> https://www.adafruit.com/products/1899
    
      These displays use I2C to communicate, 2 pins are required to  
      interface
     ****************************************************/
    
    #include <Wire.h>
    #include "Adafruit_HTU21DF.h"
    
    // Connect Vin to 3-5VDC
    // Connect GND to ground
    // Connect SCL to I2C clock pin (A5 on UNO)
    // Connect SDA to I2C data pin (A4 on UNO)
    
    Adafruit_HTU21DF htu = Adafruit_HTU21DF();
    
    void setup() {
      Serial.begin(9600);
      Serial.println("HTU21D-F test");
    
      if (!htu.begin()) {
        Serial.println("Couldn't find sensor!");
        while (1);
      }
    }
    
    
    void loop() {
      Serial.print("Temp: "); Serial.print(htu.readTemperature());
      Serial.print("\t\tHum: "); Serial.println(htu.readHumidity());
      delay(500);
    }
     
    Raja likes this.
  2. francescomm

    francescomm Member

    Joined:
    Dec 14, 2013
    Messages:
    80
    Likes Received:
    4
    Hi, I have no experience with I2C or that sensor, so no great help, but I can suggest a few things:

    - using serial for communication between the processors and uploading a sketch to the SAM is probably the the best way (my opinion)

    - find a tutorial for the Arduino Due, instead of the Uno, pins might not be the same, and the Udoo has an exact Due clone inside. If it works for the Due it should work on the UDOO. Test with the IDE serial monitor, starting from simple "hello world" sketches to see if everything works fine. Leave the serial and Python parts for the end.

    - check the operative system of the UDOO you have, the old Linaro Ubuntu had issues with many sketches and libraries locking the SAM just at upload/compile time, if compiled on the provided IDE (worked if compiled on an external computer), while the new Udoobuntu works fine.

    That's my 2 cents for what I know. Sorry not to be of more help.
     
  3. indianerjones

    indianerjones New Member

    Joined:
    Mar 10, 2014
    Messages:
    18
    Likes Received:
    1
    From what I can tell, you have several problems at once. You are trying to connect the device to the imx's I2C and then use the Arduino to talk to it. The pins for both are different. So this will not work. In the code you provide it tells you to connect to A4 and A5 of the Arduino. The diagrams for Udoo's pinout will help you to locate them.

    If you want to use the imx's I2C ports, then yes, you will have to recompile the kernel. This is quite a tedious task, but gets you quite a deep insight on how the Linux kernel is configured for SoCs. When you have the pins correctly set up, you can use any tutorial on I2C under Linux, there is nothing Udoo-specific from there on.
     
  4. mattt

    mattt New Member

    Joined:
    Sep 4, 2014
    Messages:
    5
    Likes Received:
    1
    Thanks for the help. I am using Debian squeeze. I am using the udoo version of Arduino. uploading the from VNC within udoo. I tried a "Hello World" test sketch and I am not getting anything on the serial monitor. I don't get any errors when uploading the sketch but i'm getting nothing on serial monitor /dev/ttymxc3. I'm finding the Udoo increasing frustrating to setup and use and the udoo documentation is useless.
     
  5. mattt

    mattt New Member

    Joined:
    Sep 4, 2014
    Messages:
    5
    Likes Received:
    1
    I've realized that there are many problems in what I thought would be a simple task. Most arduino libraries are written for the Uno and not the Due. I don't think i'll be using the udoo for anything useful due to lack of support and tutorials. I can't even set it up to boot from SATA.
     

Share This Page