Go Down

Topic: Vidor hangs after uploading a big sketch (Read 386 times) previous topic - next topic

Guntas

Hello everyone
I just wrote this code for a gardening monitor with the Vidor 4000. This code uploads to the Vidor 4000 but when I check the Serial Monitor after upload, nothing appears. Could someone explain to me why this is happening?

Code: [Select]
#include "VidorGraphics.h"
#include "Vidor_GFX.h"

Vidor_GFX  vdgfx;

#include <Wire.h>
//#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <Adafruit_seesaw.h>

#define BME_SCK 13
#define BME_MISO 12
#define BME_MOSI 11
#define BME_CS 10

#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI

Adafruit_seesaw ss;

#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>
BlynkTimer timer;

#define BLYNK_PRINT Serial

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "Entered the Auth token";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "SSID";
char pass[] = "PASS";

void setup()
{
  // Debug console
  Serial.begin(9600);

  if (!FPGA.begin()) {
    Serial.println("Initialization failed!");
    while (1) {}
  }
  int version = FPGA.version();
  Serial.print("Vidor bitstream version: ");
  Serial.println(version, HEX);
  FPGA.printConfig();

  bool status;
  // default settings
  // (you can also pass in a Wire library object like &Wire2)
  status = bme.begin();
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
while(1);
  }

  Blynk.begin(auth, ssid, pass);
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);

  timer.setInterval(1000L, update_);
  //FPGA.end(); //don't strop FPGA, or HDMI out will not work
}

void loop()
{
  Blynk.run();
  timer.run();

}
void update_() {
  // change this mapping data after you cliberate your soil moisture sensor
  float t = bme.readTemperature();
  float h = bme.readHumidity();
  float p = bme.readPressure() / 100.0f;
  float tempC = ss.getTemp();
  uint16_t capread = ss.touchRead(0);

  Blynk.virtualWrite(V2, tempC);
  Blynk.virtualWrite(V3, capread);
  Blynk.virtualWrite(V5, t);
  Blynk.virtualWrite(V6, h);
  Blynk.virtualWrite(V7, p);

  Serial.println("printing data: ");
  Serial.println("temp: ");
  Serial.println(t);
  Serial.println("C ; Humidity: ");
  Serial.println(h);
  Serial.println("% ; Pressure: ");
  Serial.println(p);
  Serial.println("soil Moisture: ");
  Serial.println(capread);
  Serial.println("Updating Screen");

  tv(t, h, p, capread); //calling update screen method
}
void tv(float temp, float h, float ap, uint16_t sm) {
  //FPGA.begin();

  vdgfx.fillRect(0, 0, 640, 480, vdgfx.Yellow ());

  vdgfx.text.setColor(vdgfx.Green());
  vdgfx.text.setAlpha(187);
  vdgfx.text.setSize(2);
  vdgfx.text.setCursor(15, 40);
  vdgfx.print("Smart Agriculture");

  vdgfx.text.setCursor(15, 80);
  vdgfx.print("Stats");

  vdgfx.text.setColor(vdgfx.Blue());
  vdgfx.text.setAlpha(255);
  vdgfx.text.setSize(1);
  vdgfx.text.setCursor(15, 140);
  vdgfx.print("Temperature: ");
  vdgfx.print(temp); vdgfx.print(" C");

  vdgfx.text.setCursor(15, 200);
  vdgfx.print("Humidity: ");
  vdgfx.print(h); vdgfx.print("%");

  vdgfx.text.setCursor(15, 260);
  vdgfx.print("Air Pressure: ");
  vdgfx.print(ap); vdgfx.print(" hPa");

  vdgfx.text.setCursor(15, 320);
  vdgfx.print("Soil Moisture: ");
  vdgfx.print(sm);

  vdgfx.text.setColor(vdgfx.Blue());
  vdgfx.text.setAlpha(120);
  vdgfx.text.setSize(1);
  vdgfx.text.setCursor(15, 400);
  vdgfx.print("Original design developed by Guntas");
}

purisame

Does the serial monitor work standalone with a trivialized example?

Like

void setup() { Serial.begin(9600); }

void loop() { Serial.println("test"); }

?

Guntas

#2
Aug 10, 2020, 10:46 am Last Edit: Aug 10, 2020, 10:47 am by Guntas
Sorry, the problem was that the baud rate wasn't set to 115200, and the while(1) function meant that the code wouldn't proceed unless a BME280 sensor was detected. That was a failure on my part. But after commenting out the while(1), it printed properly
Regards and thanks for the response
Guntas

Go Up