smartknob icon indicating copy to clipboard operation
smartknob copied to clipboard

Help - Firmware flashing

Open bulior opened this issue 3 years ago • 4 comments

Can anyone help me to flash the firmware, especially the display. The documentation is still in progress. I tryed to upload with VS Code and PlatformIO but the board is in boot loop.

With my test code to check the DMS it is possible to run the system:

/*
  Name:    Smartknob_test.ino
  Created: 5/19/2022 11:51:51 PM
  Author:  bulior
*/

//  LED´s
#include <FastLED.h>
#define NUM_LEDS 8
#define PIN_LED_DATA = 7

//  Note: Allowed to use pin 7 in FastLED lib
//  #define FASTLED_UNUSABLE_PIN_MASK (0ULL | _FL_BIT(6) | _FL_BIT(8) | _FL_BIT(9) | _FL_BIT(10) | _FL_BIT(20))
CRGB leds[NUM_LEDS];

//
//using namespace std;
//#include <algorithm>
#include <HX711.h>
HX711 scale;
uint8_t dataPin = 38;
uint8_t clockPin = 2;
long press_value_unit;

float hue;

//Display
//#include "roboto_light_60.h"



// the setup function runs once when you press reset or power the board
void setup() {
  delay(250);
  Serial.begin(19200);
  Serial.println("Smart Knob BEN 2022-04-23");
  
  FastLED.addLeds<SK6812, 7, GRB>(leds, NUM_LEDS);  //  LEDs
  for (int i = 0; i < NUM_LEDS; i++) {
    leds[i] = CRGB::Blue;
  }
  FastLED.setBrightness(50);
  FastLED.show();
  
  scale.begin(dataPin, clockPin);                   //  DMS

}


// the loop function runs over and over again until power down or reset
void loop() {
  //Serial.println("LED");
  delay(50);
  hx711read();

}

void hx711read() {
  const int32_t lower = -950000;
  const int32_t upper = -360000;

  if (scale.wait_ready_timeout(50)) {
    int32_t reading = scale.read();
    Serial.println(reading);
    // Ignore readings that are way out of expected bounds
    if (reading >= lower - (upper - lower) && reading < upper + (upper - lower) * 2) {
      static uint32_t last_reading_display;
      if (millis() - last_reading_display > 1000) {
        Serial.print("HX711 reading: ");
        Serial.println(reading);
        last_reading_display = millis();
      }
      long value = constrain(reading, lower, upper);
      Serial.print("Wert: ");
      Serial.print(value);
      press_value_unit = 1. * (value - lower) / (upper - lower);
      Serial.print(" / ");
      Serial.print(press_value_unit);
      hue = (value-upper)*-1.00;
      hue = hue/586000.00;
      hue = hue*255.00;
      Serial.print(" / ");
      Serial.println(hue);
      
      for (int i = 0; i < NUM_LEDS; i++) {
        leds[i] = CHSV(hue, 255, 255);
      }
      FastLED.show();
      
    }
  }
  else {
    Serial.println("HX711 not found.");

    for (uint8_t i = 0; i < NUM_LEDS; i++) {
      leds[i] = CRGB::Green;
    }
    FastLED.show();

  }
}

bulior avatar May 20 '22 14:05 bulior

You should be able to get out of boot loop by using the boot push button on the esp32 board :

  1. press BOOT switch (maintain it)
  2. press EN switch (and release it)
  3. wait 1 sec and release the boot switch You should be able to access the MCU through the UART/USB port (seen as COM port on your windows machine) and flashing must be all right.

If it does not work : Can you share the platformio.ini ? What OS are you running VSC ? Can you confirm the hardware you are using ? (esp32 version and USB driver)

AR17HY avatar May 27 '22 12:05 AR17HY

Can you share the debug output from the boot loop when you use Upload and Monitor? That will help pin down exactly what's happening. One known issue is that you'll get a bootloop if you don't have the VEML7700 ALS sensor - the I2C initialization causes a bootloop if it's not present. So if the error message is related to I2C, I'd recommend turning off SK_ALS and try again. Otherwise, hopefully sharing the log output will help identify the issue.

scottbez1 avatar May 28 '22 01:05 scottbez1

You should be able to get out of boot loop by using the boot push button on the esp32 board :

  1. press BOOT switch (maintain it)
  2. press EN switch (and release it)
  3. wait 1 sec and release the boot switch You should be able to access the MCU through the UART/USB port (seen as COM port on your windows machine) and flashing must be all right.

What push buttons are you referring to? There are no push buttonss on the T-micro 32 image

alex934 avatar Sep 22 '22 04:09 alex934

Okay thanks i fix the boot loop by resoldering and i'm able to flash my firmware.

But if i try to flash your general firmware i will have some issues. I implemented your files as project in Visual Studio Code and compiled with [env:view] profile. All librarys has been downloaded but i will get lots of error messages.

In smartknob.pb.h the header pb.h cant be find. I added Nanopb to the librarys and it works but then the next lib is missing. Which libs have i add manually ?

It seams that this vars are not declaired:

  • SK_DISPLAY_ROTATION
  • MONITOR_SPEED

After defininging them to

  • SK_DISPLAY_ROTATION = 3
  • MONITOR_SPEED =115200 It works but whats wrong ?

bulior avatar Feb 28 '23 08:02 bulior