Coder Social home page Coder Social logo

tinypico-arduino's People

Contributors

defragster avatar joey232 avatar mcauser avatar unexpectedmaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinypico-arduino's Issues

boards.txt may define the wrong pins_arduino.h file for TinyPICO

I think I have found a problem in the TinyPICO setup. This may not be the correct place to report it but it seems better than nothing.

I'm using:

  • macOS 10.14.6
  • Arduino 1.8.12
  • esp32 1.0.4
  • TinyPicoHelperLibrary 1.3.0

The Arduino IDE is set to:

  • Tools » Board » ESP32 Arduino » TinyPICO

Consider this sketch:

#include <Arduino.h>
#include <TinyPICO.h>

void check (const char * tag, uint8_t value, uint8_t expectedValue) {

    if (value != expectedValue) {

        Serial.printf(
        	"Symbol %s has value %d, expectedValue \n",
        	tag,
        	value,
        	expectedValue
        );
        
    }
    
}

void setup() {
    
    Serial.begin(115200); while (!Serial); Serial.println();
    
    /* these symbols should be available from pins_arduino.h */
//    check("APA_POWER",APA_POWER,13);
//    check("APA_DATA",APA_DATA,2);
//    check("APA_CLK",APA_CLK,12);

    /* these symbols should be available from TinyPICO.h */
    check("DOTSTAR_PWR",DOTSTAR_PWR,13);
    check("DOTSTAR_DATA",DOTSTAR_DATA,2);
    check("DOTSTAR_CLK",DOTSTAR_CLK,12);

    Serial.println("Complete");

}

void loop() { }

That compiles OK. But if I uncomment any of these three lines:

//    check("APA_POWER",APA_POWER,13);
//    check("APA_DATA",APA_DATA,2);
//    check("APA_CLK",APA_CLK,12);

then the sketch won't compile, giving errors like:

sketch_tinyPicoPins:66:21: error: 'APA_CLK' was not declared in this scope
     check("APA_CLK",APA_CLK,12);
                     ^

The path:

~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/variants/tinypico/pins_arduino.h

contains these lines:

static const uint8_t APA_POWER = 13;
static const uint8_t APA_DATA = 2;
static const uint8_t APA_CLK = 12;

so, all other things being equal, those symbols should be defined and available to the sketch.

Backtracking to:

~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/boards.txt

finds this line:

tinypico.build.variant=pico32

and I think that means that, instead of the path to pins_arduino.h given above, the compiler is being directed to:

~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/variants/pico32/pins_arduino.h

Comparing the two pins_arduino.h files produces:

$ diff ~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/variants/pico32/pins_arduino.h ~/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/variants/tinypico/pins_arduino.h 
55a56,59
> static const uint8_t APA_POWER = 13;
> static const uint8_t APA_DATA = 2;
> static const uint8_t APA_CLK = 12;
> 

which explains the observed behaviour.

Slow Boot times

Hi,

I have an off situation here with your board running the sketch below.

Your board:
image
image

DevKit ESP32
image

Sketch

void setup() {
  Serial.begin(115200);
  Serial.print("I've been alive for ");
  Serial.print(millis());
  Serial.println("ms");
  
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

I'm building a project which deep-sleeps, counts pulses with the ULP, wakes up after a set amount, logs on to wifi, publishes the counter with mqtt and goes back to sleep.
The normal runtime on the devkit is around 300ms including wifi.

[33 ] ULP wakeup, saving pulse count
[33 ] Pulse count from ULP:4
[33 ] Wifi Setup - Starting
[68 ] Wifi Setup - Setting up WiFi Manager.....
[69 ] Wifi Setup - Setting up WiFi Manager.....done
[69 ] Got stored Credentials. Timeout 60s
[70 ] Wifi Setup - Done
[72 ] Wifi Setup - Connecting
[75 ] Connecting to CrappyIoTconnected! Local IP: 337512970
[259 ] Setting up MQTT Starting
[259 ] Attempting MQTT connection...
[292 ] MQTT connected!
[292 ] Leaving MQTT connect
[292 ] Setting up MQTT Complete
[296 ] Disconnecting from MQTT.
[297 ] MQTT disconnected.
[297 ] Finished. Going to sleep
[297 ] Entering deep sleep

You can see that being alive and "useless" for 1500ms is a battery killer in this way :)

Why would it be taking this long before it actually hit the setup?

C

Couple tweaks to RGB LED

According to datasheet, RGB LED has 32 levels of brightness unrelated to RGB value, so i've modified the code:

TinyPICO::TinyPICO()
{
    ...
    brightness = 15;
    ...
}

void TinyPICO::DotStar_SetBrightness(uint8_t b)
{
    if(b>31) b = 31;
    brightness = b;
}

void TinyPICO::DotStar_Show(void)
{
    if ( !isInit )
    {
        isInit = true;
        swspi_init();
        delay(10);
    }
    
    // Start-frame marker
    for( int i=0; i<4; i++) swspi_out(0x00);    
    
    // Pixel start + brightness
    swspi_out(0xE0 | brightness);     
    
    for( int i=0; i<3; i++) swspi_out(pixel[i]); // R,G,B @Full brightness (no scaling) 

    // // End frame marker
    swspi_out(0xFF);  
}

It works fine and RGB values aren't loosing precision. I don't know your original intention for manual brightness, so didn't want to make a pull request.

Another tweak i think is useful is to remove delay(1) from the end of swspi_out. LED works fine without delay but presence of it may be crucial for time sensitive tasks in main loop (like in my case).

Does deep sleep work on Arduino?

Tried the DeepSleep example from the Arduino examples, stays at 20mA, with no decrease, sleep or not. I can do this on the ESP32 DOIT, without issue, sleep goes down to a couple mA.

Arduino WiFi and Upload, Reset for new code

Hoping update to Arduino tree from x.2 to x.3 resolves this:

The Play Shield example 'TinyPICO-Play-Shield-Features' shows this well:

With WiFi running a new Upload may take a RESET/repower/2nd upload to get the code uploaded to actually run
When running this sketch some alternate presses of button 4 will not show WiFi connect but long lines of '...' with no connect until another Button 4 press.

Battery voltage incorrect

If the TinyPICO helper is created and used immediately, the battery voltage reported is incorrect.
Rationale:

  • lastMeasuredVoltage isn't initialized in the constructor. Fix: in the constructor: lastMeasuredVoltage = 0.0f;

  • nextVoltage is set the current time, so if immediately after GetBatteryVoltage is called 'nextVoltage - millis() > 0' is false and the (currently uninitialized) lastMeasuredVoltage is returned without a new ADC read. Fix: in the constructor, change the nextVoltage initialization to: nextVoltage = millis() - 1; //do a '-1' to ensure I can get the battery voltage this msec.

Note that isToneInit isn't initialized in the constructor as well, even not related to this issue, I guess that initializing to false might be wise.

Using GetBatteryVoltage() function causes my adc1 based ULP process to stop working

float TinyPICO::GetBatteryVoltage()
{
uint32_t raw, mv;
esp_adc_cal_characteristics_t chars;
// only check voltage every 1 second
if ( nextVoltage - millis() > 0 )
{
nextVoltage = millis() + 1000;
// grab latest voltage
analogRead(BAT_VOLTAGE); // Just to get the ADC setup
raw = adc1_get_raw(BATT_CHANNEL); // Read of raw ADC value
// Get ADC calibration values
esp_adc_cal_characterize(ADC_UNIT_1,ADC_ATTEN_11db ,ADC_WIDTH_BIT_12,DEFAULT_VREF,&chars);
// Convert to calibrated mv then volts
mv = esp_adc_cal_raw_to_voltage(raw, &chars) * (LOWER_DIVIDER+UPPER_DIVIDER) / LOWER_DIVIDER;
lastMeasuredVoltage = (float)mv / 1000.0;
}
return ( lastMeasuredVoltage );
}

I'm not familiar enough yet with how the adc is configured and used and reused, but in debugging my program I've found that if I call the GetBatteryVoltage() function anywhere in my code... the ULP program I have that uses adc1 to wake on hall sensor readings fails to execute. I'm guessing because of the way this function uses the ADC that perhaps there needs to be some kind of release or reset on the adc? The ULP loading code looks like this:

esp_err_t err = ulp_load_binary(0, ulp_main_bin_start,
                                  (ulp_main_bin_end - ulp_main_bin_start) /
                                      sizeof(uint32_t));
ESP_ERROR_CHECK(err);
adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_0);
adc1_config_channel_atten(ADC1_CHANNEL_3, ADC_ATTEN_DB_0);
adc1_config_width(ADC_WIDTH_BIT_12);
adc1_ulp_enable();
esp_err_t ulp_run_err =
    ulp_run((&ulp_entry - RTC_SLOW_MEM) / sizeof(uint32_t));
if (ulp_run_err != ESP_OK)
  log_e("Failed to run ULP program.");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.