Adafruit Soil Sensor + SH1106 display conflict

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
gnism
 
Posts: 2
Joined: Sun May 21, 2023 7:55 am

Adafruit Soil Sensor + SH1106 display conflict

Post by gnism »

Hello,
I would like to run an Adafruit soil sensor on an Adafruit HUZZAH ESP8266 breakout board and show the readings on a small LED 128x64 display (SH1106). Both, the sensor and the display are running on the i2c bus (sensor 0x36, display 0x3c) and are both connected to pins #4 and #5 on the board. The display is driven by the u8g2 library, the sensor is driven by the seesaw library. If I run each device separately, everything is ok. As soon as I run them together on the i2c bus, there seems to be a bus conflict even though the addresses are different. The display is working but the the sensor provides a max. and faulty value of 65535 (in air). It does also not change its value when put into water or when touched.
WHo can help me?

Here is the code:

Code: Select all

#include <U8g2lib.h>
#include <Adafruit_seesaw.h>

Adafruit_seesaw ss;

U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
 
const int AirValue = 350;   //you need to replace this value with Value_1
const int WaterValue = 1000;  //you need to replace this value with Value_2
int soilMoistureValue = 0;
int soilmoisturepercent = 0;

void setup() {
  Serial.begin(9600); // open serial port, set the baud rate to 9600 bps

  u8g2.begin(); //initialize 
  u8g2.clearBuffer(); //clear display
  u8g2.setFont(u8g2_font_inb16_mf);
  u8g2.setFontRefHeightExtendedText();
  u8g2.setDrawColor(1);
  u8g2.setFontPosTop();
  u8g2.setFontDirection(0);
  u8g2.enableUTF8Print();
  
  if (!ss.begin(0x36)) {
    Serial.println("ERROR! seesaw not found");
    while(1) delay(1);
  } else {
    Serial.print("seesaw started! version: ");
    Serial.println(ss.getVersion(), HEX);
  }
}
void loop() {
  float tempC = ss.getTemp();
  uint16_t capread = ss.touchRead(0);  //put Sensor insert into soil
  
  Serial.println(capread);
  
  soilmoisturepercent = map(capread, AirValue, WaterValue, 0, 100);
  Serial.print("Relative value: "); Serial.println(soilmoisturepercent);

  if(soilmoisturepercent >= 100)
    {
    Serial.println("100 %");
  
    u8g2.setCursor(15, 10);
    u8g2.print("Humidity");
    u8g2.setCursor(30, 40);
    u8g2.print("100 %");
    u8g2.sendBuffer();

  delay(1000);
  
  }
  else if(soilmoisturepercent <=0)
  {
    Serial.println("0 %");
  
    u8g2.setCursor(15, 10);
    u8g2.print("Humidity");
    u8g2.setCursor(30, 40);
    u8g2.print("  0 %");

    u8g2.sendBuffer();

    delay(1000);
  }
  else if(soilmoisturepercent >0 && soilmoisturepercent < 100)
  {
   Serial.print(soilmoisturepercent);
    Serial.println("%");
  
    u8g2.setCursor(15, 10);
    u8g2.print("Humidity");
    u8g2.setCursor(30, 40);
    u8g2.print("           ");
    u8g2.setCursor(30, 40);
    u8g2.print(" ");
    u8g2.print(soilmoisturepercent);
    u8g2.print(" %");
    u8g2.sendBuffer();

    delay(1000);
  }  
}

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adafruit Soil Sensor + SH1106 display conflict

Post by dastels »

Exactly what products are you trying to use? Please post clear pictures of your connections.

Dave

User avatar
gnism
 
Posts: 2
Joined: Sun May 21, 2023 7:55 am

Re: Adafruit Soil Sensor + SH1106 display conflict

Post by gnism »

Hardware_Setup_800x600.jpg
Hardware_Setup_800x600.jpg (123.06 KiB) Viewed 174 times
I have attached a picture of the setup.

User avatar
dastels
 
Posts: 15817
Joined: Tue Oct 20, 2015 3:22 pm

Re: Adafruit Soil Sensor + SH1106 display conflict

Post by dastels »

I'm not clear on how/where the sensor is attached.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”