9 Replies Latest reply on Jul 12, 2016 3:25 AM by GerardVidal

    Different behavior of i2c according to power supply

    GerardVidal

      Hi all,

       

      I have been struggling to put an HTU21DF at work with my edison Arduino Breakout.

      Preliminary observation :

      if I use the Arduino IDE with sparkfun HTU21DF example everything is OK, readings are always correct and display on the serial is always nominal

      What I tried to do :

      I cloned on my Edison the git repositories mraa and upm compiled and installed the programs.

      I used the functions provided by upm library (some are missing compared to IDE example but that's not my point)) from python program. It worked like a charm (or almost see another post dealing with the consequences of a throw command added in mraa). But when I tried to execute the same python program without direct USB connection with the board (I used WIFI connection) then the measurements were wrong and it was like the Edison could not access the i2c bus

      Symptoms :

      I am connected to the Edison through WIFI on my personnal network. (I have commented the throw exception in mraa)

      • If the breakout is connected with USB connectors my program calling upm/htu21d functions works well and provide stable measurements
      • If I add the external power on the J1 barrel connector, reboot and restart the program it is unstable; at times I get wrong measurements and in some cases it does not recover if I try a test or reset I get : no change / errors/ crash.
      • If I boot with barrel power only I got bad measurements just like it was not possible to reach the bus.

       

      Am I missing something or is there a bug or possible hardware problem ? My power supply is on 9v (27VA)

       

      Let me know what I can provide if needed to explore this problem.

       

      Annex problem/question I have not been able to change the readings from HOLD to NO_HOLD  could it be the reason why if I put my HTU21D with other sensors on the bus and use this hu21D-upm Nothing works any more.

      Many thanks.

        • 1. Re: Different behavior of i2c according to power supply
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hi Gerard,

          You should be able to read data whichever the method you use, as long as the voltage in the power supply is inside the range supported (7V to 15V).
          Is this happening only with the python code? Or is it happening with the Arduino Code too? 
          I do not have the same sensor you have but I will do some tests in order to check if I get the same behavior. 
          Have you noticed other problems in the board related to power? Maybe with other interfaces while using a power supply?
          Is this the only board you have? If you have another one we could test the code and sensor in order to see if the problem is related to the hardware of the board.

          Regards,
          Charlie

          • 2. Re: Different behavior of i2c according to power supply
            Flo1991

            Can you provide more information about your power supply?

            Try a 9 V battery instead of a power supply, is the problem solved using a battery?

             

            Flo1991

            • 3. Re: Different behavior of i2c according to power supply
              GerardVidal

              Thanks Flo1991 I have checked and

               

              I can reproduce exactly the same problem with 9V Battery.

              The power supply can deliver 3 4 5 6 7 9 12 V power available is 27VA which express I think that I can get up to 3A with 9V setting.

               

              Gérard.

              • 4. Re: Different behavior of i2c according to power supply
                GerardVidal

                Hi Charlie thanks for the suggestion

                I have borrowed an edison with Arduino breakout from a friend and that one works perfectly with external power or  USB power.

                According to your guess this may demonstrate that it must be an hardware problem then ...

                Do you think the problem may come from the arduino board or the Edison itself ?????

                 

                I do not know how to compile the arduino code straight on the edison (without usb connection and without IDE) mainly because I cannot find Wire.h and Wire library containing Wire functions used in the arduino code.

                 

                Another disturbing point is that I need to comment out the "throw" instruction from mraa/api/mraa/i2c.hpp (and go back to situation before commit)

                readReg(uint8_t reg)
                {
                int x = mraa_i2c_read_byte_data(m_i2c, reg);
                /*  if (x == -1) {
                throw std::invalid_argument("Unknown error in I2c::readReg()");
                }*/
                return (uint8_t) x;
                }

                 

                I have tried many ways to try/catch the error message sent  but in all solutions I have tested, It cannot read read the second byte freom the bus to build the measurement value. I can successfully pass the try but the values sent are wrong, Maybe I am not catching properly .....  Here is the htu21d.cpp amendments :

                 

                uint16_t

                HTU21D::i2cReadReg_16 (int reg) {

                    uint16_t data;

                    m_i2ControlCtx.address(m_controlAddr);

                    try {

                    data  = (uint16_t)m_i2ControlCtx.readReg(reg) << 8;

                   }

                    catch (const std::invalid_argument& e )

                    {

                        data = 1;

                        fprintf(stdout, "  Failed to read first byte with readReg at address : %d" , reg);

                    }

                    try {

                    data |= (uint16_t)m_i2ControlCtx.readReg(reg+1);

                   }

                    catch (const std::invalid_argument& e )

                    {

                        data = 1;

                        fprintf(stdout, "  Failed to read second byte with readReg at address : %d\n", reg+1);

                    }

                    return data;

                }

                 

                Finally I tried to use 3 sensors on the same i2c  bus HTU21D-F BMP180 MPL115A2 , it works perfectly on the arduino board but no way with the edison !!!! even the HTU21D-F is not visible. Using the IDE with the Edison the message is "cannot find sensor" and when trying straight on the Edison messages are :

                 

                Executing Sensor Test

                Traceback (most recent call last):

                  File "HTU21DF.py", line 66, in <module>

                    messureTempHygro()

                  File "HTU21DF.py", line 34, in messureTempHygro

                    test()

                  File "HTU21DF.py", line 23, in test

                    htu21df.testSensor ()

                  File "/usr/lib/python2.7/site-packages/pyupm_htu21d.py", line 257, in testSensor

                    return _pyupm_htu21d.HTU21D_testSensor(self)

                ValueError: UPM Invalid Argument: i2cWriteReg: mraa_i2c_write() failed

                 

                Traceback (most recent call last):

                  File "tempPress.py", line 17, in <module>

                    bmp180 = pyupm_bmpx8x.BMPX8X(bus, pressAddress)

                  File "/usr/lib/python2.7/site-packages/pyupm_bmpx8x.py", line 170, in __init__

                    this = _pyupm_bmpx8x.new_BMPX8X(bus, devAddr, mode)

                RuntimeError: UPM Runtime Error: BMPX8X: Invalid chip ID

                 

                 

                Any suggestion

                Thanks

                Gérard

                • 5. Re: Different behavior of i2c according to power supply
                  Flo1991

                  You said that the edison is working on the USB power but not using the barrel jack. You also tried a battery and another arduino-edison plattform.

                  So you can say:

                  - the sensors are fine

                  - the edison is ok (to be shure you can try your friends breakout with your edison)

                  - the power supply is ok (the battery was to try out if the source ripple is to high)

                   

                  -> if you now look at the arduino breakout schematics on page 3 (  http://www.intel.com/content/dam/support/us/en/documents/edison/sb/edison_arduino_hvm_8_26.pdf )

                  you can see the different current path refering to different power supplies.

                  The first time both ways (USB power / Barrel Jack) cross is at the 5 V label.  This is after the diodes CR1 / CR2.

                  So I suppose there must be something wrong with the regulator U1 and its circuit.

                   

                  So you can try the following:

                  - use the arduino breakout 5 V connection as 5 V input (this should be quite accurate 5,0 V, lets say +/- 0,2 V, do not use any other power supply!)

                  --> this should work, your sensors should behave as using the USB port as power supply

                  - use the arduino breakout VIN connection and supply 9 V (battery or anything else)

                  --> I suppose this will not work

                   

                  Keep us up to date.

                   

                  Flo1991

                  • 6. Re: Different behavior of i2c according to power supply
                    GerardVidal

                    Hi Flo1991 Thanks for the follow-up

                    So you can say:

                    - the sensors are fine

                    YES I can say that plugged on a standard arduino UNO they yield acceptable measurements even when plugged all together

                    - the edison is ok (to be shure you can try your friends breakout with your edison)

                    I CANNOT CONFIRM I WILL CHECK I have not tested my Edison on his Arduino breakout I will do it (as soon as I come back home I am at a conference at the moment)

                    - the power supply is ok (the battery was to try out if the source ripple is to high)

                    YES I tested it also with a multimeter its is stable and nominal

                     

                    So you can try the following:

                    - use the arduino breakout 5 V connection as 5 V input (this should be quite accurate 5,0 V, lets say +/- 0,2 V, do not use any other power supply!)

                    I do not understand you mean I have to use 5v instead of 3.3V to power the sensors? Or I use th other arduino to power the faulty one?

                    --> this should work, your sensors should behave as using the USB port as power supply

                    - use the arduino breakout VIN connection and supply 9 V (battery or anything else)

                    --> I suppose this will not work

                    Iwill check and let you know if the Edison or the breakout is faulty.

                    Thanks again

                     

                    edit 2016-07-12

                    Sorry for the delay I was out for a conference last week.

                    to answer @charlie I am doing the changes in i2C.hpp then rebuild the library

                     

                    To sum up my arduino board is faulty and my Edison seems to work like the other one when it is on the other board.

                    But when I have double checked the other Edison on my supposed faulty board it works properly and when I have triple checked by putting back my Edison on my board confirming that the board is faulty and probably the Edison is not at its best condition.

                     

                    To conclude and close this thread if you agree

                    The strange behavior identified is due to an hardware problem.

                     

                    Another result is that it is more difficult to get the i2c sensors running with the Edison/Arduino than with the Arduino. My goal is to demonstrate the power and the immense opportunites of SOC and IoT compared to microcontrollers which is clearly possible with GPIO using controlled leds or analogic sensors but for the i2c with digital sensors  some important  problems have to be solved... I have finally ordered a new Edison to tackle these difficulties.

                     

                    Testing report

                    ==============

                    First of all I have tested the sensors on an arduino to be sure they are OK. There are four sensors 2 HTU21D-F BMP180 MPL115A2, I have put 3 of them on the same bus and I get the following measurements (the firts values are with the first HTU21D and the second with the other) :

                     

                    Time:636985

                    MPL115A2Press : 997.6128 hPa

                    MPL115A2Temp : 20.3  degC

                    HTU21DTemp :   24.6 deg C ; Humidity:52.1 %

                    BMP180Temp :   24.99 deg C ;

                    BMP180Press :   995.53 hPa,

                    relative (sea-level) pressure: 1015.71 hPa, computed altitude: 169 meters,

                     

                     

                    Time:706274

                    MPL115A2Press : 998.0930 hPa

                    MPL115A2Temp : 20.5  degC

                    HTU21DTemp :   25.0 deg C ; Humidity:50.5 %

                    BMP180Temp :   25.02 deg C ;

                    BMP180Press :   995.61 hPa,

                    relative (sea-level) pressure: 1015.79 hPa, computed altitude: 169 meters,

                     

                    There is a difference between the two Temperature measurements.... But those are microsensors . When I plug/unplug the sensors on the breadboard everything keeps on working, the remaining sensors providing measurements.

                     

                     

                    ------------------------------------------------------------------------------------------------------------------------------------------------------------

                     

                    When I connect to Edison/Arduino A to  the same wiring  the measures from HTU21D are wrong while the other are correct ! If I unplug the MPL sensor measures become correct from the HTU21D which is really weird

                     

                    Time:581080

                    MPL115A2Press : 996.8079 hPa

                    MPL115A2Temp : 20.3  degC

                    HTU21DTemp :   998.0 deg C ; Humidity:998.0 %

                    BMP180Temp :   25.03 deg C ;

                    BMP180Press :   995.46 hPa,

                    relative (sea-level) pressure: 1015.64 hPa, computed altitude: 169 meters,

                     

                    After removing HTU21D

                    *********************

                    Time:586271

                    MPL115A2Press : 86.6744 hPa

                    MPL115A2Temp : -73.1  degC

                    HTU21DTemp :   24.8 deg C ; Humidity:52.6 %

                    BMP180Temp :   25.05 deg C ;

                    BMP180Press :   995.50 hPa,

                    relative (sea-level) pressure: 1015.68 hPa, computed altitude: 169 meters,

                     

                    With2 sensors only

                    ***********************

                    Time:5517

                    MPL115A2Press : 997.2876 hPa

                    MPL115A2Temp : 20.7  degC

                    BMP180Temp :   25.01 deg C ;

                    BMP180Press :   995.18 hPa,

                    relative (sea-level) pressure: 1015.35 hPa, computed altitude: 169 meters,

                     

                    --------------------------------------------------------------------------------------------------------------------

                     

                    When I connect to Edison/Arduino B The BMP180 cannot initialize and yields bad measurements, if I unplug the MPL BMP180 works but in all cases I get bad measurements  for HTU21D except if it is alone on the bus (I have unplugged the MPL for the last measurements). If HTU21D is removed BMP180 initializes properly.

                     

                    Time:55038

                    MPL115A2Press : 998.0930 hPa

                    MPL115A2Temp : 20.3  degC

                    HTU21DTemp :   998.0 deg C ; Humidity:998.0 %

                     

                    Time:183038

                    MPL115A2Press : 86.6744 hPa

                    MPL115A2Temp : -73.1  degC

                    HTU21DTemp :   24.4 deg C ; Humidity:53.4 %

                     

                    After removing HTU21D

                    *********************

                    Time:40673

                    MPL115A2Press : 997.4396 hPa

                    MPL115A2Temp : 21.1  degC

                    BMP180Temp :   25.35 deg C ;

                    BMP180Press :   995.20 hPa,

                    relative (sea-level) pressure: 1015.38 hPa, computed altitude: 169 meters,

                     

                    As a conclusion to this step the boards used with the arduino-IDE give different results but more annoying : it is impossible to get the normal(identical toa true Arduino) behaviour with both boards and three sensors. To get correct measurements  from HTU21D it must be alone on the bus... There is something wrong with the i2c provided by the Edison/Arduino with these sensors. I have not enough competencies in electronics to investigate further.

                     

                    -----------------------------------------------------------------------------------------------------------------

                    -----------------------------------------------------------------------------------------------------------------

                    Trying now to acces the Edison through WIFI and communicate to the sensors with mraa/upm libs (no mpl115A2 is available and I had no time to convert one from the web)

                     

                    I am still on board B

                    *********************

                    Without touching the wiring If I collect the measurements on BMP180 with mraa/upm I get correct values

                    If I plug the barrel power nothing changes

                    If I unplug  the USB nothing changes

                    If I reboot the Edison (from wifi connection) in this situation (no USB connected)

                    I get again correct measurements for BMP180

                    Concerning HTU21D I can get measurements only if it is alone on the bus (after looking quickly at the code it seems that the reads may not be made with the necessary mode -> todo more investigations)

                     

                    Connectiong to the Board A

                    **************************

                    Without touching the wiring If I collect the measurements on BMP180 with mraa/upm I get correct values

                    If I plug the barrel measurements get wrong

                    If I replug they come back to normal

                    25.0            995.40          

                    -49.0            550.32          

                    -49.0            550.32          

                    -49.0            550.32          

                    -49.0            550.32          

                    -49.0            550.32          

                    -49.0            550.32          

                    -49.0            550.32          

                    -49.0            550.32          

                    -49.0            550.32          

                    25.0            995.28          

                     

                    If I switch the Edisons on Board A and Board B

                    Edison A on Board B works properly and very surprinsingly Edison B on board A works also properly !!!

                    But if I return to the original configuration I get back the problem which confirms bad board and probably an Edison which is not totally operational (the other being able to compensate the board defect)

                     

                    If I plug an  HTU21D alone on both boards it works properly....But sometimes it yields bad measurements on the faulty board.

                    Thanks to Flo1991 and Charlie for the advices and follow up

                    • 7. Re: Different behavior of i2c according to power supply
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation

                      Hi Gerard,

                       

                      I’m glad to know that you were able to identify the problem, let us know the outcome of running the suggestions from Flo1991. You can contact the store where you bought the module/board/kit and see if they offer a warranty policy. If the store do not offers a warranty policy or the limited time for it has expired you can contact Intel Support http://www.intel.com/support/mailform/maker/warrantyemail.htm.

                       

                      In order to run a sketch without using the COM port, you can use the service from older releases that loads the latest sketch, you will need to use the workaround from: https://communities.intel.com/message/319509#319509

                       

                      Are you doing the changes in /usr/include for the i2c.hpp or are you building the library?

                       

                      Let us know about your results.

                       

                      Regards,
                      Charlie

                      • 8. Re: Different behavior of i2c according to power supply
                        Intel Corporation
                        This message was posted on behalf of Intel Corporation

                        Hi Gerard,

                        I would like to know if you have been able to test if the problem was the board or module, also if you contacted the store or opened a ticket.
                        Let us know the results.

                        Regards,
                        Charlie
                         

                        • 9. Re: Different behavior of i2c according to power supply
                          GerardVidal

                          Please see edit and final proposal upstream.

                          Thanks to all