Good evening,
I cannot get a sensor to connect when I try to connect to a giga Wire1. What do I need to do to get it on the second i2c?
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
https://create.arduino.cc/cloud/things/3bcbf2e1-2cb6-4c3e-88c0-3ceaaa4db872
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float current_Limit;
float door_Current;
int door_Activation_Level;
int illumination;
int set_Timer_Minutes;
bool door_Position;
bool requested_Door_Position;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#include <CountDown.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "Adafruit_VEML7700.h"
using namespace mbed;
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
#define Connection_Retry_Time 5000
#define BLOCK_DEVICE_SIZE 1024 * 8 // 8 KB
#define PARTITION_TYPE 0x0B // FAT 32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, OLED_RESET);
Adafruit_VEML7700 veml = Adafruit_VEML7700();
long timer_Seconds;
long WiFi_Retry;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(10000);
Serial.print("Booting");
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner
display.print(F("Duck Door Booting."));
display.println();
display.print(F("Please Wait."));
display.println();
display.display();
/*current_Limit = EEPROM.get(0, current_Limit);
door_Activation_Level = EEPROM.get(8, door_Activation_Level);
set_Timer_Minutes = EEPROM.get(12,set_Timer_Minutes);*/
timer_Seconds = set_Timer_Minutes * 60;
Wire.begin();
Wire1.begin();
Serial.println("starting temperature sensor");
if (!veml.begin(&Wire1)) {
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0,0); // Start at top-left corner
display.print(F("Sensor Not Found"));
display.println();
display.print(F("Check Wiring."));
display.display();
while (1);
}
veml.setGain(VEML7700_GAIN_1_4);
veml.setIntegrationTime(VEML7700_IT_800MS);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(4);
ArduinoCloud.printDebugInfo();
}
void loop() {
if (!WiFi.status() && WiFi_Retry > millis()){
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
WiFi_Retry = millis() + Connection_Retry_Time;
}
ArduinoCloud.update();
// Your code here
door_Current = (float)analogRead(A0) * 0.0048828125;
illumination = veml.readALS();
Display_Screen();
}
void Display_Screen(){
display.clearDisplay();
display.setTextSize(1); // Normal 1:1 pixel scale
display.setTextColor(SSD1306_WHITE); // Draw white text
display.setCursor(0,0);
display.print(F("Light Level: "));
display.println(illumination);
display.print(F("Door Current: "));
display.println(door_Current);
display.print(F("Wifi is "));
if (WiFi.status()){
display.println(F("connected."));
}
else{
display.println(F("disconnected."));
}
display.print(F("Cloud is "));
if (ArduinoCloud.connected()){
display.println(F("connected."));
}
else{
display.println(F("disconnected."));
}
display.display();
}
/*
Since CurrentLimit is READ_WRITE variable, onCurrentLimitChange() is
executed every time a new value is received from IoT Cloud.
*/
void onCurrentLimitChange() {
// Add your code here to act upon CurrentLimit change
}
/*
Since DoorActivationLevel is READ_WRITE variable, onDoorActivationLevelChange() is
executed every time a new value is received from IoT Cloud.
*/
void onDoorActivationLevelChange() {
// Add your code here to act upon DoorActivationLevel change
}
/*
Since DoorPosition is READ_WRITE variable, onDoorPositionChange() is
executed every time a new value is received from IoT Cloud.
*/
void onDoorPositionChange() {
// Add your code here to act upon DoorPosition change
}
/*
Since RequestedDoorPosition is READ_WRITE variable, onRequestedDoorPositionChange() is
executed every time a new value is received from IoT Cloud.
*/
void onRequestedDoorPositionChange() {
// Add your code here to act upon RequestedDoorPosition change
}
/*
Since SetTimerMinutes is READ_WRITE variable, onSetTimerMinutesChange() is
executed every time a new value is received from IoT Cloud.
*/
void onSetTimerMinutesChange() {
// Add your code here to act upon SetTimerMinutes change
}
As for wiring - no diagram but both the display and the temp sensor is connected:
Sensor SCL - GIGA SCL1
Sensor SDA - GIGA SDA1
Sensor Vin - GIGA 5v
Sensor Gnd - GIGA gnd
the display is working normally. Both work normally on an uno r4 wifi.