Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
C

Carl Durr

@Carl Durr
About
Posts
3
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • nRF24L01+ will not start
    C Carl Durr

    maybe try removing "IRQ" connection? as its not needed.

    also i had the some issues, but i had my wires mixed up..

    Follow this Tut:
    https://www.mysensors.org/build/connect_radio

    Troubleshooting

  • Arduino disconnects from LAN Network?
    C Carl Durr

    Hi mfalkvidd,

    Thank you for the quick reply, appreciated the help.

    Arduino Uno3 with a generic ethernet shield on it, which i picked up at local computer store. I have the Arduino powered via a 5V 2A (2000mA) switching power supply which connects directly to wall outlet.

    I dont have the serial connected. As you know, i wanted the device to power via wall outlet. So I dont need to connect the USB Serial. But you are right, this would be a good step to troubleshoot issues. However i didnt want my computer plugged in for long time, as i have other projects im working on :-)

    But i can connect Serial and watch output. The only issues it i think it takes few hours before Arduino becomes unresponsive.

    Development

  • Arduino disconnects from LAN Network?
    C Carl Durr

    Hello all,

    Im having some issues with my code. It works great, but only for a few hours. Then device disconnects/unresponsive. Hope someone can give me some advice on my code. I created this device to control my TV. Thank you in advanced and appreciated any advice.

    #include <IRremote.h>
    #include <IRremoteInt.h>
    #include <SPI.h>
    #include <UIPEthernet.h>
    #include <PubSubClient.h>
    
    IRsend irsend;
    
    int irledPin = 3;
    int ledPin = 5;
    
    // Current input
    int currentimput = 1;
    
    // mgmt number
    int currentmgmtping = 0;
    
    // Settings for "Status of Device"
    byte bytebuffer[30];
    
    
    // Update these with values suitable for your network.
    byte mac[]    = {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
    IPAddress ip(192, 168, 1, 201);
    IPAddress server(192, 168, 1, 200);
    
    //
    // Callback function header
    //
    void callback(char* topic, byte* payload, unsigned int length);
    
    //
    // toString function header
    //
    String toString(byte* payload, unsigned int length);
    
    EthernetClient ethClient;
    PubSubClient client(ethClient);
    
    void reconnect() {
      // Loop until we're reconnected
      while (!client.connected()) {
        Serial.print("Attempting MQTT connection...");
             // Attempt to connect
        if (client.connect("arduinoClient")) {
               Serial.println("connected");
               // Once connected, publish an announcement...
                       client.publish("/home/master/tv","Connected");
                // ... and resubscribe
                        client.subscribe("/home/master/tv");         
        } else {
                 Serial.print("failed, rc=");
                 Serial.print(client.state());
                 Serial.println(" try again in 5 seconds");
          // Wait 5 seconds before retrying
               delay(5000);
        }
      }
    }
    
    void lightled(){
                 digitalWrite(5, HIGH);
                 delay(1000);
                 digitalWrite(5, LOW);
      
    }
    
    // Setup Stuff ~~~~~~~~~~
    void setup(){
      Serial.begin(9600);
      delay(500);//Delay to let system boot
      Serial.println("Master rooms TV remote\n\n");
      delay(1000);//Wait before accessing Sensor
    
    //MQTT Connect
      client.setServer(server, 1883);
      client.setCallback(callback);
       Ethernet.begin(mac, ip);
       // Allow the hardware to sort itself out
      delay(1500);
    
      // initialize the pushbutton pin as an input:
      pinMode(irledPin, OUTPUT);
      pinMode(ledPin, OUTPUT);
    
    
    } //END Setup
    
    
    //Loop Stuff ~~~~~~~
    void loop() {
      
      if (!client.connected()) {
                 reconnect();
        } 
      
       client.loop();
    
    } //END Loop
    
    //
    // MQTT Callback function
    //
    
    void callback(char* topic, byte* payload, unsigned int length) {
              
              if (strcmp(topic, "/home/master/tv") == 0) {
                  String msg = toString(payload, length);
                  
                  //
                  // Send TV IR code
                  //
                  Serial.println("Received Message MSG sending Code");
                     if (msg=="POWER"){
                          irsend.sendNEC(0x20DF10EF, 32); //  TV power code
                  
                          lightled();   
                     } else{
                        // Do nothing
                        
                     }
          }
    }
    
    //
    // toString function
    //
    String toString(byte* payload, unsigned int length) {
      int i = 0;
      char buff[length + 1];
      for (i = 0; i < length; i++) {
        buff[i] = payload[i];
      }
      buff[i] = '\0';
      String msg = String(buff);
      return msg;
    }
    
    Development
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular