Go Down

Topic: Arduino Due problem connecting senzors HTU21D and MPL3115A2 (Read 1 time) previous topic - next topic

zumby13

Hi,
I have a problem connecting senzors  HTU21D and MPL3115A2 to Arduino Due
Both senzors need to connect like this VCC → 3.3V GND → GND  SDA → A4  SCL → A5
After loading the code, i dont get data from them, or false data.... like -49 degrees and 999meteres...,if i remove the senzors, same data is received... Anyway same senzors with same code, but put on a Arduino uno work perfectly fine...
I connect senzors one at a time, i try to use the other two SDA and SCL pins, but no result...
Did i need to load some special libraries for Due or idk...
Code i use for senzor test:   https://learn.sparkfun.com/tutorials/htu21d-humidity-sensor-hookup-guide
and https://learn.sparkfun.com/tutorials/mpl3115a2-pressure-sensor-hookup-guide


MorganS

A4 and A5 are not I2C pins on the Due, unlike most of the other Arduinos.

It should work if you use the pins labelled SCL and SDA. Try again. Double-check your connections.
"The problem is in the code you didn't post."

zumby13

I also tried to connect them at other ports... 20 (SDA), 21 (SCL) and SDA1, SCL1 but same no results...
that's why i cant figure why it doesnt work, maybe is something with code,  a special library for ic2/twi  comunication on Due ( because on Uno works like magic ), other than wire , or idk, im kinda noob in this... :smiley-confuse: or in worse case board is broken...

zumby13

Hi
I've tried with a ic2 scanner and i cant find any senzors on board, there's nothing on it ...
I replace the wire library with a new fixed one" but same results...
I put a ESP8266 wireless modulre, same results, no comunication with board...
Instead on UNO all this parts are working perfect...
Can we say that board is broken? Is there any other test that i should do or else?

MorganS

"The problem is in the code you didn't post."

zumby13

I dont know how to use wire1 in this code... and yes i use SCL1 and SDA1
Code: [Select]
#include <Wire.h>
#include "HTU21D.h"

//Create an instance of the object
HTU21D myHumidity;

void setup()
{
  Serial.begin(9600);
  Serial.println("HTU21D Example!");

  myHumidity.begin();
}

void loop()
{
  float humd = myHumidity.readHumidity();
  float temp = myHumidity.readTemperature();

  Serial.print("Time:");
  Serial.print(millis());
  Serial.print(" Temperature:");
  Serial.print(temp, 1);
  Serial.print("C");
  Serial.print(" Humidity:");
  Serial.print(humd, 1);
  Serial.print("%");

  Serial.println();
  delay(1000);
}

MorganS

Go back to the scanner code. You must be able to scan for the address of the chip before trying anything else.

Code: [Select]
// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011
//Modified 16/1/2015 M Sandercock - allow re-scanning in loop()
//Modified 13/3/2015 M Sandercock - test Wire1 and allow output on DUE native port.

#include <Wire.h>

#define SerialPort SerialUSB //for testing on Arduino DUE native port (SerialUSB) or programming port (Serial)
#define I2C Wire1 //for testing either Wire or Wire1

void setup() {
  SerialPort.begin (115200); 
}  // end of setup

void loop() {
  SerialPort.println ();
  SerialPort.println ("I2C scanner. Scanning ...");
  byte count = 0;
 
  I2C.begin();
  for (byte i = 8; i < 120; i++)
  {
    I2C.beginTransmission (i);
    if (I2C.endTransmission () == 0)
      {
      SerialPort.print ("Found address: ");
      SerialPort.print (i, DEC);
      SerialPort.print (" (0x");
      SerialPort.print (i, HEX);
      SerialPort.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  SerialPort.println ("Done.");
  SerialPort.print ("Found ");
  SerialPort.print (count, DEC);
  SerialPort.println (" device(s).");
  SerialPort.println();
  SerialPort.println("Press any key to re-scan");
  SerialPort.print(">");
 
  while(!SerialPort.available()) {
    delay(100); //wait, let some characters come into the serial buffer
  }
  while(SerialPort.available()) {
    SerialPort.read(); //clear the serial buffer
  }
}[/code
"The problem is in the code you didn't post."

Go Up