Dashboard is not showing numbers

My dashboard wont show numbers even though I have connected all the variables and etc. I have an opla, and I can see everything on the LED screen, but the dashboard wont work (web nor mobile app).

here is my code if it helps:

#include <Wire.h>
#include "thingProperties.h"

#include <Arduino_MKRIoTCarrier.h>
#include <Arduino_OplaUI.h>



// Constant for dry sensor
const int DryValue = 4095;
 
// Constant for wet sensor
const int WetValue = 3100;
 
// Variables for soil moisture
int soilMoistureValue;
int soilMoisturePercent;
 
// Analog input port
#define SENSOR_IN A6
const int moistPin = A6;

#define SENSOR_IN A5
const int humidityPin = A5;

unsigned long startedWatering;

MKRIoTCarrier opla;
CycleWidgetsApp app;
Gauge2_Widget moistureWidget;
Bool_Widget wateringToggleWidget;
Gauge2_Widget temperatureWidget;
Gauge2_Widget humidityWidget;

void setup() {
 
  // Setup Serial Monitor
  Serial.begin(9600);
 delay(1500);

  // Make sure the pump is not running
  stopWatering();

  // Connect to Arduino IoT Cloud
  initProperties();
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  setDebugMessageLevel(4);
  ArduinoCloud.printDebugInfo();

  // Configure widgets
  moistureWidget.attachValue(moisture);
  moistureWidget.setTitle("MOISTURE");
  moistureWidget.setRange(0, 100);
  moistureWidget.setDigits(0);
  moistureWidget.setSuffix(" %");
  moistureWidget.setReadOnly(true);
  
  temperatureWidget.attachValue(temperature);
  temperatureWidget.setTitle("TEMPERATURE");
  temperatureWidget.setRange(0, 50);
  temperatureWidget.setDigits(0);
  temperatureWidget.setSuffix("°C");
  temperatureWidget.setReadOnly(true);
  
  humidityWidget.attachValue(humidity);
  humidityWidget.setTitle("HUMIDITY");
  humidityWidget.setRange(0, 100);
  humidityWidget.setDigits(0);
  humidityWidget.setSuffix("%");
  humidityWidget.setReadOnly(true);

  wateringToggleWidget.attachValue(watering);
  wateringToggleWidget.setTitle("PUMP");
  wateringToggleWidget.onValueChange(onWateringChange);
  
  // Initialize Oplà
  CARRIER_CASE = true;
  opla.begin();

  // Initialize the widget application
  app.begin(opla);
  app.addWidget(moistureWidget);
  app.addWidget(wateringToggleWidget);
  app.addWidget(temperatureWidget);
  app.addWidget(humidityWidget);
 
 
  // Set ADC to use 12 bits
  analogReadResolution(12);
 
}


void loop() {
 ArduinoCloud.update();
  app.loop();
   
  // Read the sensor and convert its value to a percentage 
  // (0% = dry; 100% = wet)
  int raw_moisture = analogRead(moistPin);
  moisture = map(raw_moisture, 4095, 3100, 0, 100);
 

 
  // Pass temperature and humidity values to cloud variables
  
  temperature = opla.Env.readTemperature();
  humidity = opla.Env.readHumidity();

  // Set the LED color according to the moisture percentage
  if (moisture > 40) {
    opla.leds.setPixelColor(2, 0, 255 , 0);  // green
  } else if (moisture > 10) {
    opla.leds.setPixelColor(2,0,0,125); // yellow
  } else {
    opla.leds.setPixelColor(2,125,0,0);  // red
  }
  opla.leds.show();
  
  // Stop watering after the configured duration
  if (watering && (millis() - startedWatering) >= waterTime*1000) {
    stopWatering();
  }
  
  delay(100);
}

// This function is triggered whenever the server sends a change event,
// which means that someone changed a value remotely and we need to do
// something.
void onWateringChange() {
  if (watering) {
    startWatering();
  } else {
    stopWatering();
  }
}

void startWatering () {
  watering = true;
  startedWatering = millis();
  opla.Relay1.open();
}

void stopWatering () {
  watering = false;
  opla.Relay1.close();
}
void onWaterTimeChange()  {
  // Add your code here to act upon WaterTime change
}



How are the connections made? Schematics please!

relay-connection

image

And my temperature and humidity sensor are connected to pin A5

Sorry but a link to the datasheet of the pump is needed. The fear is that You overload the USB current capacity.

do you need the specifications of the pump? sorry didnt understand your request

Yes. All of it.

Hmmm that says 12V. I don't think it will run well at 5V, even if the Arduino can provide sufficient current.

Please measure the resistance between the pump terminals. This will enable us to calculate the stall-current of the pump.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.