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
Marc-Olivier ChaubetM

Marc-Olivier Chaubet

@Marc-Olivier Chaubet
About
Posts
3
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • LCD Clock and Text sensor node with new V_TEXT
    Marc-Olivier ChaubetM Marc-Olivier Chaubet

    Hi,
    I've change this line with "!=" and it work. but i dont undestand why....?

    
    void incomingMessage(const MyMessage &message) {
        if (message.type!=V_TEXT) {                         // Text messages only
    
    My Project

  • LCD Clock and Text sensor node with new V_TEXT
    Marc-Olivier ChaubetM Marc-Olivier Chaubet

    Hi AWI,
    Yes my display is working, i can see the date and "Line 1 - First....."

    I think what i send is not correct....0_o
    This is from the serial monitor

    read: 0-20-49 s=9,c=1,t=16,pt=0,l=4,sg=0:test
    

    Should it be something like this

    read: 0-20-49 s=9,c=1,t=16,pt=0,l=4,sg=0:Line1=test
    

    this is the sketch.

    
    /*
     PROJECT: MySensors / LCD display for text from controller
     PROGRAMMER: AWI
     DATE: september 8, 2015/ last update: september 8, 2015
     FILE: AWI_LCD_49.ino
     LICENSE: Public domain
    
     Hardware: tbd ..MYS Ceech - ATmega328p board w/ NRF24l01
        and MySensors 1.5 ()
            
    Special:
        MySensors - Development (as of sept 2015)
        
    SUMMARY:
        display time & 2 lines of text from Controller Text sensors
    */
    
    #include <MyMessage.h>
    #include <MySensor.h>                       // Mysensor network
    #include <SPI.h>
    #include <LiquidCrystal_I2C.h>
    #include <Time.h>                           //http://playground.arduino.cc/Code/Time
    #include <Wire.h>                           
    
    // uncomment if you are using the DEVELOPMENT version with V_TEXT & V_INFO defined (better to use development MyMessage.h)
    const byte V_TEXT = 47 ;                  // values taken from development edition MyMessage.h
    const byte S_INFO = 36 ;
    
    const byte nodeId = 49 ;                    // MySensors fixed node id
    const byte LCD1_CHILD = 8 ;                 // LCD line 1
    const byte LCD2_CHILD = 9 ;                 // LCD line 2
    
    char lastLCD1[21] = "Line1 - first   ";     // define & init before first receive
    char lastLCD2[21] = "Line2 - second  ";
    
    boolean timeReceived = false ;
    // timers for loop delays
    unsigned long lastUpdate=0, lastRequest=0, lastDisplay=0;
    int display_no = 0 ;                        // current display
    
    // *** Definition and initialisation
    // define the MySensor network
    MyTransportNRF24 transport(9,10);           // Sensoduino (8,7) Ceech board, 3.3v (7,8)  (pin default 9,10)
    MySensor gw(transport);  
    
    // Initialize messages for sensor network
    MyMessage textMsg(0, V_TEXT);
    //                    addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
    
    // OPTIONAL: Custom characters for display - Units)
    byte heart[8] = { B00000, B01010, B11111, B11111, B01110, B00100, B00000, B00000};
    
    void setup(void){
        //Serial in Sensor network = 115200
        gw.begin(incomingMessage, nodeId);                  // this node is 49 fixed 
        //Send the sensor node sketch version information to the gateway
        gw.sendSketchInfo("AWI_LCD text 49", "1.1");
        gw.present(LCD1_CHILD, S_INFO, "LCD_line1");        // new S_type 20150905 (not know by domoticz)
        gw.present(LCD2_CHILD, S_INFO, "LCD_line2");
        gw.send(textMsg.setSensor(LCD1_CHILD).set("-"));    // initialize the V_TEXT at controller for sensor to none (trick for Domoticz)
        gw.send(textMsg.setSensor(LCD2_CHILD).set("-"));        
    
        // Initializations
        gw.requestTime(receiveTime);                        // get the time from controller (handled by receiveTime)
        
        // ** LCD display **
        Wire.begin();                                       // I2C
        lcd.begin(16, 2);                                   // LCD 2 lines * 16 char.
        lcd.setBacklight(HIGH);
        lcd.setCursor(0, 0);
        lcd.createChar(1, heart);
    
        // lcd.write(byte(0)); // write units
    }
    
    void loop(void){
        // timer for loop delays
        unsigned long now = millis();
        gw.process() ;
        // If no time has been received yet, request it every 10 second from controller
        // When time has been received, request update every hour
        if ((!timeReceived && (now-lastRequest > 10*1000)) ||   
            (now-lastRequest > 3600000UL)){                 // request update every hour to keep in sync
           // Request time from controller. 
           Serial.println("requesting time");
           timeReceived = false;
           gw.requestTime(receiveTime);  
           lastRequest = now;
            }
        // Change display and update sensors every 5 seconds (default = 5000)
        if (now-lastDisplay > 5000){
            lastDisplay = now;
            gw.request(LCD1_CHILD, V_TEXT, 0);                  // request new values from controller
            gw.request(LCD2_CHILD, V_TEXT, 0);                ;// request new values from controller
            // change display 
            display_no++;
                if (display_no >= 2){ // wrap for number of different displays for second line
                display_no = 0;
                }
            }
        // Update display every second
        if (now-lastUpdate > 1000) {
            LCD_local_display();
            lastUpdate = now;
            }
        }
    
    // This is called when a new time value was received
    void receiveTime(unsigned long controllerTime) {
        Serial.print("Time value received: ");
        Serial.println(controllerTime);
        setTime(controllerTime);                            // time from controller
        timeReceived = true;
        }
    
    // This is called when a message is received 
    void incomingMessage(const MyMessage &message) {
        if (message.type==V_TEXT) {                         // Text messages only
         // Write some debug info
         Serial.print("Message: "); Serial.print(message.sensor); Serial.print(", Message: "); Serial.println(message.getString());
        if (message.sensor == LCD1_CHILD ) {
            snprintf(lastLCD1, sizeof(lastLCD1), "%16s", message.getString());  // load text into LCD string
            }
        else if (message.sensor == LCD2_CHILD){
            snprintf(lastLCD2, sizeof(lastLCD2), "%16s", message.getString());
            }
        } 
    }
    
    void LCD_local_display(void){
    // take car of LCD display information
        char buf[17]; // temp buffer for max 16 char display
        // start with location & time on first line
        snprintf(buf, sizeof buf, "%02d:%02d:%02d %02d-%02d", hour(), minute(), second(), day(), month());
        lcd.setCursor(0, 0);
        lcd.print(buf);
        lcd.setCursor(0, 1);
        if (display_no == 0){
          lcd.print(lastLCD1);                          // second line is text value from controller
        } else {                                        // display == 2
          lcd.print(lastLCD2);
        }
    }
    
    

    Thxs

    My Project

  • LCD Clock and Text sensor node with new V_TEXT
    Marc-Olivier ChaubetM Marc-Olivier Chaubet

    Hi,
    i try to send message but nothing change on LcdDisplay.

    I d'ont undestant what is wrong.

    Can you help me pls.

    send: 49-49-20-0 s=8,c=2,t=47,pt=0,l=0,sg=0,st=ok:
    send: 49-49-20-0 s=9,c=2,t=47,pt=0,l=0,sg=0,st=ok:
    read: 0-20-49 s=9,c=1,t=16,pt=0,l=4,sg=0:test
    send: 49-49-20-0 s=9,c=1,t=16,pt=0,l=4,sg=0,st=ok:test
    send: 49-49-20-0 s=8,c=2,t=47,pt=0,l=0,sg=0,st=ok:
    
    My Project
  • Login

  • Don't have an account? Register

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