Recent Posts

Pages: [1] 2 3 ... 10
1
Software / Node mcu, android y mqtt (duda...
Last post by Jorgeturi - Today at 01:39 am
Buenas a todos, es mi primer publicación, gracias a todos los que pasen a leer y ayudarme de antemano. :)

La situación es así:
-Tengo un programa armado en el nodemcu v3 donde está subscripto a MQTT hacia adafruit y leo un feed creado y si lo del feed es igual igual a algo me activa o desactiva una salida

Mediante IFTT y google assistant , envío los comandos que cree en IFTT y me mandan la información al feed, toda esa parte funciona, el problema es que quiero enviar esa información a MQTT sin google assistant, con una aplicación creada desde 0 o teniendo una plantilla.

Quería hacer una aplicación con appinventor (creo que es lo más fácil) o androidstudio (me cuesta más) conectando con MQTT. Por lo poco que entiendo dice que se puede hacer mediante HTML o MQTT, lo que busco es enviar un valor a un feed pulsando un botón de la app y visualizar el estado de las cosas leyendo lo que hay en el feed o leyendo salidas del Node directamente


Aquí dejo el link de adafruit hablando de diversas formas de conectar con MQTT https://learn.adafruit.com/adafruit-io/mqtt-api
2
Project Guidance / Re: Controling the temperature...
Last post by Slumpert - Today at 01:38 am
veey well though out plan.

Put expected "load" in the over, stick temperature probe near load, turn on one heater circuit and time how long it takes to change one degree and how long to get to 200.  Unplug the power to heater as it hits 200 and log how far past 200 it goes as well as how long the temperature takes to max out.

With those data points you can start to make some rough estimates.

I love the idea of a constantly updating PID setting loop inside a loop inside a loop..
3
I'm using a Mega to be an LED Strip controller and I'm trying to use the switch case to cycle through various visual outputs for the LED Strip. The problem I'm running into is that the variable used to count the number of button presses, 'visual', updates fine when the 'Visualize()' isn't included in the loop and only the 'CycleVisual();' is included. Once I add the 'Visualize()' the 'visual' only registers one increment and then doesn't update in the Serial Monitor of any more button presses. I want to assume the logic used in 'CycleVisual();' is ill-suited for 'Visualize();', but I'm lost after a couple of days of trying to figure out the problem. A schematic of the board is included above the code. Please disregard the pot and sound module since I want to include the usage of those after I figure out how to cycle through visuals that don't require sound input for now. Thank you for your time!



Code: [Select]
#include <Adafruit_NeoPixel.h> 
#ifdef __AVR__
#include <avr/power.h>   
#endif                   

#define LED_PIN   A5  //Pin for the pixel strand. Can be analog or digital.
#define LED_TOTAL 300  //Change this to the number of LEDs in your strand.
#define LED_HALF  LED_TOTAL/2
#define VISUALS   2   //Change this accordingly if you add/remove a visual in the switch-case in Visualize()
#define BUTTON_1  6 

Adafruit_NeoPixel strand = Adafruit_NeoPixel(LED_TOTAL, LED_PIN, NEO_GRB + NEO_KHZ800);  //LED strand objetcs

uint8_t visual = 0; 

void setup() {
  Serial.begin(9600);
  pinMode(BUTTON_1, INPUT);
  digitalWrite(BUTTON_1, HIGH);
  strand.begin();
  strand.show();
 }

void loop() {
  Serial.println(visual);
  CycleVisual();
  delay(10);
}

void CycleVisual() {
   if (digitalRead( BUTTON_1 ) == LOW ) {
    visual++;
    if (visual > VISUALS) visual = 0;
    delay(350);
  }
}

void Visualize(){
  switch (visual) {
    case 0: return Sparkle(0xff, 0xff, 0xff, 50);
    break;
    case 1: return BouncingBalls(0xff, 0xff, 0xff, 5);
    break;
    case 2: return RunningLights(23, 43, 0, 50);
    break;
    default: Sparkle(0xff, 0xff, 0xff, 50);

  }
}

void showstrand() {
 #ifdef ADAFRUIT_NEOPIXEL_H
   // NeoPixel
   strand.show();
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   FastLED.show();
 #endif
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
 #ifdef ADAFRUIT_NEOPIXEL_H
   // NeoPixel
   strand.setPixelColor(Pixel, strand.Color(red, green, blue));
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   leds[Pixel].r = red;
   leds[Pixel].g = green;
   leds[Pixel].b = blue;
 #endif
}

void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < LED_TOTAL; i++ ) {
    setPixel(i, red, green, blue);
  }
  strand.show();
}

void Sparkle(byte red, byte green, byte blue, int SpeedDelay) {
  int Pixel = random(LED_TOTAL);
  setPixel(Pixel,red,green,blue);
  strand.show();
  delay(SpeedDelay);
  setPixel(Pixel,0,0,0);
  digitalWrite(BUTTON_1, HIGH);
}

void RunningLights(byte red, byte green, byte blue, int WaveDelay) {
  int Position=0;
 
  for(int j=0; j<LED_TOTAL*2; j++)
  {
      Position++; // = 0; //Position + Rate;
      for(int i=0; i<LED_TOTAL; i++) {
        // sine wave, 3 offset waves make a rainbow!
        //float level = sin(i+Position) * 127 + 128;
        //setPixel(i,level,0,0);
        //float level = sin(i+Position) * 127 + 128;
        setPixel(i,((sin(i+Position) * 127 + 128)/255)*red,
                   ((sin(i+Position) * 127 + 128)/255)*green,
                   ((sin(i+Position) * 127 + 128)/255)*blue);
      }
     
      strand.show();
      delay(WaveDelay);
  }
}

void BouncingBalls(byte red, byte green, byte blue, int BallCount) {
  float Gravity = -9.81;
  int StartHeight = 1;
 
  float Height[BallCount];
  float ImpactVelocityStart = sqrt( -2 * Gravity * StartHeight );
  float ImpactVelocity[BallCount];
  float TimeSinceLastBounce[BallCount];
  int   Position[BallCount];
  long  ClockTimeSinceLastBounce[BallCount];
  float Dampening[BallCount];
 
  for (int i = 0 ; i < BallCount ; i++) {   
    ClockTimeSinceLastBounce[i] = millis();
    Height[i] = StartHeight;
    Position[i] = 0;
    ImpactVelocity[i] = ImpactVelocityStart;
    TimeSinceLastBounce[i] = 0;
    Dampening[i] = 0.90 - float(i)/pow(BallCount,2);
  }

  while (true) {
    for (int i = 0 ; i < BallCount ; i++) {
      TimeSinceLastBounce[i] =  millis() - ClockTimeSinceLastBounce[i];
      Height[i] = 0.5 * Gravity * pow( TimeSinceLastBounce[i]/1000 , 2.0 ) + ImpactVelocity[i] * TimeSinceLastBounce[i]/1000;
 
      if ( Height[i] < 0 ) {                     
        Height[i] = 0;
        ImpactVelocity[i] = Dampening[i] * ImpactVelocity[i];
        ClockTimeSinceLastBounce[i] = millis();
 
        if ( ImpactVelocity[i] < 0.01 ) {
          ImpactVelocity[i] = ImpactVelocityStart;
        }
      }
      Position[i] = round( Height[i] * (LED_TOTAL - 1) / StartHeight);
    }
 
    for (int i = 0 ; i < BallCount ; i++) {
      setPixel(Position[i],red,green,blue);
    }
    digitalWrite(BUTTON_1, HIGH);
    strand.show();
    setAll(0,0,0);
  }
}
4
General Electronics / Re: ADC and a zener
Last post by LandonW - Today at 01:37 am
I calculate 1/32 watt for a 10Megohm resistor with 600volt across.
600*600/10000000= 0.036watt. Not a problem for a single resistor.

Common resistors shouldn't have more than 100-200volt across.
Use at least four in series, and more if you're expecting high spikes.
Leo..
that is true but I scaled it to work up to 1200 vdc...

I attached the schematic and parts list.

5
Motors, Mechanics, and Power / Re: Output of L293D
Last post by Wawa - Today at 01:36 am
An L293D needs two supply voltages.
A 5volt logic supply, and a higher than 5volt motor supply (e.g. 15volt for a 12volt motor).

Read the "how to post" sticky if you want proper help.
Leo..
6
Storage / Re: Looking for an external SP...
Last post by Lucario448 - Today at 01:34 am
If you google "external SPI flash memory module", you will find some options. By getting their IC names, you can search them in the store of your choice.
Sorry, I have no suggestions; but googling and investigating a little doesn't hurt anybody.


By the way...
at least 100 Mbits/s
So you need an SPI port capable of clocking at 100 MHz... yikes! None of the most popular Arduino boards are capable of such speed :o

Excluding SBCs, very few microcontrollers can clock its SPI port that fast. The only examples (or possible candidates) I know are the ESP-32 (an overclocked 8266 is still too slow), the fastest Teensy and a very few STM32 microcontrollers.
7
Hi all,
I am a newbie to arduino and have been trying to write code for a plane sim controller.

I have 3 encoders, several switches and buttons which I need to perform functions within the simulator. I have been reading and learning what I can but I have run in to a problem.

When I operate the master/alternator/avionis switches they seem to lock out the operation of any of the other switches? If I operate the other switches there is no problem?

I am guessing that there are many mistakes in my code and I would be grateful to anyone who might be able to help me correct it.

Thank you for your time in reading,

Andy


8
Software / Re: Control via puerto Serie
Last post by Jorgeturi - Today at 01:27 am
Hola, no se si pueda ayudarte ni si es válido, pero tal vez puedas probar o alguno corregirme.

Si definis una variable int y pones que lo que recibe el monitor serial lo guarde en esa variable y comparas lo de esa variable si es igual a 111 o 000 y que haga lo que debe, sea prender o apagar o nada en caso de no poner nada u otra cosa


Otra opción (tampoco se si se puede) , si lo ingresado en monitor serial es igual a 111 o 000 directamente que haga lo que quieras

Saludos, también apenas arranco y no sé bien pero estaré atento a como puede hacerse
9
The documentation for Serial.read() says that it returns an int that contains -1 if there is no character available, or returns the ASCII character.  This is all you will need from Serial.read().

A trick that may work in your case is

byte number = Serial.read() - '0' :

Of course, this only works correctly if Serial.read() returns a character from 0 through 9 so you better check that number is legitimate.

By the way, the numbers that you are seeing are the ASCII encoding for those characters.  '0' is represented by 48, '1' is represented by 49, etc.



10
bitRead() works with 64-bit values, but bitSet(), bitClear() and bitWrite() are limited to 32 bits because of that 1UL in the macros:

Code: [Select]
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
Pages: [1] 2 3 ... 10