Close

Hello Mesh - RGB Colors Broadcast

A project log for Home Smart Mesh

Mesh of sensors, zigbee, custom RF, BT, wifi, all to MQTT Gateways on Raspberry Pi with database, dashboard and webapps.

WassimWassim 03/22/2017 at 19:217 Comments

Demo

This was the very first step in this project that shows how machines talk to each other in a way humans could perceive :

Firmware

WS2812B bitbanging

void rgb_SendArray()
{
    BYTE int_state = __get_interrupt_state();
    __disable_interrupt();
  asm(
        "lb_intiLoop:                          \n"
        "LDW      X,             #0xFFFF       \n"// set -1 in X, so that first inc gets 0, as inc has to be in the beginning of the loop
        "LDW      Y,             L:nbLedsBytes \n"//2
        "lb_begin_loop:                        \n"
//---------------------------------------------------------------
//--------------- bit 0 -----------------------------------------
        "INCW    X                           \n"// L t+2
        "lb_start_bit0:                      \n"//
        "LD      A,           (L:LedsArray,X)\n"//
        RGBLedPin_Set
        "AND     A,             #0x80        \n"// H t2
        "JREQ    L:lb_bit0_Send_0            \n"// H0 t3 t4 : 2 jump to Zero, 1 Stay in One + next nop
        "lb_bit0_Send_1:                     \n"//------Send 1 : 800ns High, 450ns Low (12,8) 750ns,500ns
        "nop                                 \n"// H1 t5
        "nop                                 \n"// H1 t6
        "nop                                 \n"// H1 t7
        "nop                                 \n"// H1 t8
        "nop                                 \n"// H1 t9
        "nop                                 \n"// H1 t10
        "nop                                 \n"// H1 t11
        "nop                                 \n"// H1 t12
        RGBLedPin_ReSet                         // L1 t1
        "nop                                 \n"// L1 t2
        "JRA     L:lb_start_bit1             \n"// L1 JRA:2 t4 
                                                // L1 NextBitTest:4  t8
        "lb_bit0_Send_0:                     \n"//------Send 0 : 400ns High, 850ns Low (7,13) 375ns,875ns
                                                // H0 t4
        RGBLedPin_ReSet                         // L0 t1
        "nop                                 \n"// L0 t1
        "nop                                 \n"// L0 t2

Full source code part of the STM8S driver : github IoT_Frameworks WS2812B.c

Color Flashing

void rgb_FlashColors(BYTE delay, RGBColor_t Color)
{
  for(int iCount=0;iCount<255;iCount++)//0-10
  {
    RGBColor_t Ci = rgb_ColorScale(iCount,255,BLACK,Color);
    rgb_SendColors(Ci);
    delay_ms(delay);
  }
  for(int iCount=0;iCount<255;iCount++)//0-10
  {
    RGBColor_t Ci = rgb_ColorScale(iCount,255,Color,BLACK);
    rgb_SendColors(Ci);
    delay_ms(delay);
  }
  rgb_SwitchOff();
}

RF Broadcast

Voltage levels

Discussions

avtop2k wrote 02/26/2019 at 16:23 point

please share circuit diagram of STM8S rf node and STM8L mobile Node

thx

  Are you sure? yes | no

Wassim wrote 02/26/2019 at 18:45 point

The PCB design in eagle are already shared in this github repo : https://github.com/HomeSmartMesh/STM8_IoT_Boards/tree/master/IoT_Node_Mobile_v2

  Are you sure? yes | no

Wassim wrote 02/26/2019 at 18:47 point

Here is the latest generation that I recommend more powerful than the STM8 https://github.com/nRFMesh/nRF52_Mesh

  Are you sure? yes | no

avtop2k wrote 02/26/2019 at 16:16 point

https://github.com/HomeSmartMesh/IoT_STM8  Is rdb_leds project using  mash network mode ? I am not able understand  how its work like how 1st receive code for 2nd node that client of 1 st node 

thx

Avtar 

  Are you sure? yes | no

Wassim wrote 02/26/2019 at 18:08 point

Hi, see the protocol in https://www.homesmartmesh.com/mesh/
byte2 is source id, the node that sent the packet, and byte3 is dest, the node that shall use the packet, other nodes that receive the same message but have different id shall ignore the packet.

Please note that the IoT_STM8 is no longer maintained, the currently supported platform is the the nRF52840.

Let me know if you have more questions.

  Are you sure? yes | no

avtop2k wrote 07/04/2018 at 18:08 point

Hi

I trying to compile rgb_leds but in libs error rfi_header_size,rf_pid_0xDF_retransmit and rfi_payload_offset is undefined ,How to compile

  Are you sure? yes | no

Wassim wrote 07/04/2018 at 18:50 point

Hi, I spotted some duplications of the same comment :)

Hi, yes, thank you for your finding, I fixed these compilation errors in the commit I made today just for maintenance

541ae723d424edbea4a077d8590023a95d9712cb

make sure you're using the repo https://github.com/HomeSmartMesh/IoT_STM8

But actually, the STM8 was the very first version of the mesh HW and I stopped working with it, that is why they are deprecated, and at the time, I did not had a good project share with submodules to prevent update of shared libs without breaking other projects.

Since then, I moved to the STM32 for bridges and continuously powered devices, I implemented also a driver for the WS2812B there. https://github.com/HomeSmartMesh/IoT_Frameworks/tree/master/stm32_rf_dongle/rf_bridge

And after the STM32, I switched to the nRF52 for which I found nice small USB dongles that I reflash with nRF firmware. I see you also followed my project #nRF52 Sensors Mesh Network , thank you for your interest, that is the project I am currently actively working on, so if you have questions or require support for that project I will be able to help much easier.

  Are you sure? yes | no