close-circle
Close
0%
0%

Home Smart Mesh

Ultra low cost DIY IoT Framework. Wireless sensors and RF repeaters for Raspberry Pi. Open Source, plugs with MQTT and OpenHAB2.

Similar projects worth following
close
The Internet Of Things needs open standards and cheap Hardware. Home Smart Mesh tries to solve IoT problems we have at home (cost, types of sensors, number of nodes, range,...). This is a hobby project, in which I learn a lot back from the community.
Focus is on the custom RF mesh protocol, the front end focus is on the latest network technologies 'websockets', 'd3js',... And server focus is on a the Raspberry Pi Software, developed in C++ and connects with an MQTT client to Mosquitto. OpenHAB2 is configured with MQTT in both directions to Mosquitto.
As new HW, we get two boards. The CR2032 battery powered wireless node for Temperature, Humidity, Pressure, Ambient Light and Magnetic Switches (window open detection) the power consumption is quite good more than a year of 30 sec update. The second is a fixed node (RF but needs power) that can be both an RF repeater in stand alone or an RF dongle for a Raspberry Pi. The fixed node can also control an RGB LED WS2812B

Introduction to the project

Moved to the end of section, more important stuff first, bla bla next.

Impressions and Inspirations

Also moved to the end of section. for those really curious how all this started.

Links to project Logs

The Logs consist of specific use cases based on this IoT_Framework going into some details of firmware and software :

IoT Framework, what do we have here ?

Below we see both boards contributed by this project the STM8L_RF_Sensors Node, and the STM8S_RF_Dongle that have two use cases, RPi dongle and stand alone repeater. Note that this setup is running field tests now for many months already. The mesh network is a very simple flood concept with a time to live. The rest of the HW is standard from the market, Raspberry pi, smart sockets, smart light,...

Hardware Overview

Software Overview

For the software, Standards are used where possible. A user can modify the node's firmware and use ready Raspberry pi software or vice versa, depending on every one's focus. As every thing is as open as possible, it should be easy to plug in any ready interface tool such as MQTT clients.

Is this a mesh ? Yes Madam

We can see two use cases here, a broadcast and a Peer to peer message that is made reliable with Acknowledge and retries. All the details in the nrf24l01 Flood Mesh Protocol log entry.

The STM8S_RF_Dongle PCB

pinout

Ready Node to be used as dongle or as repeater

Below, the repeater in standalone mode can be directly plugged into a wall charger and act independently, it even has an RGB LED that can turn into a smart status indicator such as in the log entry about the bathroom use case.

The Raspberry Pi has dongle has an RF24L01p module with PA LNA for a wider reach but also a better sensitivity of other normal RF Nodes (note the importance of the metal case or at least aluminium foil).

STM8L_RF_sensors node

Here we can see how a completed STM8L_RF_sensors node looks like, note that soldering the STM8L is the most critical step in this process which might be a blocker, actually it is not hard, it is a matter of process and practice, see details in build logs.


IoT Dashboard

Once every thing set up and configured, the dashboard could look like this, room for improvement right but also for customization !!!

Introduction to the Project

  • Challenge
    • Internet access creates a social gap, now that things get connected, we see another gap because such devices are expensive and their development environment are expensive and complex. We also have the problem of users not owning their products due to registrations and fees.
    • Although we face many problems on what an IoT device can do, the challenge here is not only to create one more IoT device that can do something but also how to make it as much accessible as possible.
  • Solve the Problem
    • This project solves the cost problem by bringing the world's cheapest development environment for an IoT device. The STM8 components, the STM8 as breakout modules and the ST-Link_v2 programmer are all you need to have debug included for less than what your first coffee can cost.
  • Change the World
    • Even if a one time investment...
Read more »

PCBs_Design_gerbers_bom.zip

Eagle design sources, cam and bom with Hacker's license, own this design.

x-zip-compressed - 149.28 kB - 04/27/2017 at 18:42

download-circle
Download

  • 1 × STM8S103F3 breadboard Microprocessors, Microcontrollers, DSPs / Microcontrollers (MCUs)
  • 1 × nRF24L01+ Nordic's 2.4GHz Radio Transceiver
  • 1 × STM8L151F3 Low Power 8bit Microcontrollers in TSSOP20 Package
  • 1 × BME280 Sensor for Temperature, Humidity, Pressure
  • 1 × MAX44009 Ambient Light Sensor

View all 12 components

  • nRF24L01 Flood Mesh Protocol

    Wassim05/14/2017 at 12:20 0 comments

    Mesh use cases

    before talking too much about mesh concepts, let's see end results what useful things can we get of this ?

    Flood versus Routing

    This is a Flood mesh type opposed to routing mesh types.

    • With a Flood mesh, Zero configuration is required, just throw nodes in, every node has its id.
    • A Peer to peer message just need to know the destination id, the stack handles an end to end acknowledge with retries if necessary.
    • This type of mesh is router less, which means it get advantages such as
      • the nodes do not need routing tables to define the shortest path
      • which is also hard to configure if the nodes move or would have to be identified on startup.
      • A routing mesh would also require a central server or duplication of management in every node acting as a server.
    • But there's no magic in here, a Flood Mesh have some compromises to do which might be completely irrelevant in some scenarios.
      • The mesh Range is as wide as you have nodes and capacity to live through jumps, yes but then why don't we use a huge time to live for an endless range ?
      • Well the problem is the echo, as the nodes have no routing info, they will keep repeating messages to each other, even back to those they got the messages from !!!
      • This Echo is born from the flood concept itself, it reaches all the nodes around who keep singing along for one single message until that message dies.
      • During a time to live group repetition, all the impacted network is busy with that single message. which highly increases collision chances and messages loss.
      • In the scenario of a home, this compromise is not of much relevance as you barely need a single repetition jump, one Time To Live can get you through a villa, and two through a huge building, this is not fit for a city network as its name says this is a #Home Smart Mesh.
    • As two nodes listen to an RF message at exactly the same time, they are likely to react with a repetition at exactly the same time as well. To avoid that, every node uses a per id delay configuration to repeat the message with a shift in time.

    Leaf versus Repeater Nodes

    Leaf Nodes are acting like beacons. They are wireless low power sensors that cannot keep listening, thus the frequent Broadcast for them is strategically a better compromise than a Message to a server. The unpredictable time listening waiting for the acknowledge can allow to re transmit much more frequently with the same power budget. Additionally, these nodes do not need to be configured to know the server Id.

    The Mesh Protocol

    • This Mesh protocol was custom designed to take advantages of the hardware it was designed with. The reason it is different than others is simply that the RF transceiver nRF24L01+ is much cheaper. With up to x10 times cheaper, well you get some side effects such as packet size limitation. With 32 bytes, if your protocol header is big, well then you have no more room for a payload.
    • The protocol above uses only 8 Bytes at max while fulfilling all conditions of end to end addressing, redundancy checks, acknowledgment and repetitions.
    • By design, messages do not have time stamps nor sequence ids, which let the multiple repetitions reception be filtered at the destination side. That means that yes, filtering time has to be slightly higher than the Flood echo time, and the sensors broadcast frequency must be slightly lower than the listeners filtering time.
    • The only complexity we get here is in the Pid that has been compacted to handle both the message type (e.g. Temperature, rgb color request,...) and the message status, if it is a broadcast or in case of peer to peer Request or response.
    • The source and destination being part of the user software protocol solves the problem of all radio transceivers that have hardware pipes with addresses. Those addresses have to be configured depending on the network and the number of pipes is limited for the nRF24L01 to 5. Well, it is nicer to have more than 5 nodes in your mesh !!!
    • The HW acknowledge of the shock-burst...
    Read more »

  • Smart LED Panel - MQTT to x216 WS2812B

    Wassim04/29/2017 at 13:32 0 comments

    Demo

    • This demo is just a picture where the RGB Panel is switched on next to its STM8S_RF_Dongle which is here an RF to WS2812B converter.

    How is this working ?

    • The STM8 firmware to control the WS2812B has already been presented in this Log and the LED series up to 60 here
    • Here we push the number of LEDs up to x216, it could go up to x220 but then it would not be aligned any more. The panel offer up to x256 LEDs but the STM8S memory of 1KB reaches its limit here. For a single color I could simply rework the function to lightup an unlimited number of WS2812B, but we would then loose the option of displaying figures or messages.
    • Every WS2812B consumes up to 60 mA, so for 256 LEDs that's no kidding 15 Amps !!!! Thus the transformer next to it can go up to 20 Amps !! note that this might be dangerous if you use less powerful transformers !! From safety perspective, I'm currently using a manual switch in addition, I would not recommend such an installation without a relay that fully cuts out the current when not in use!!!!
    • The radio protocol is very simple and provided in the libraries through the WS2812B.c it looks like this :
    PID - NodeID - R - G - B - CRC

    MQTT Control

    For convenience here, I used a ready Android application MQTT Dash which worked out of the box once I used the topic payload format for colors which is the #RRGGBB (e.g #FFFFFF for white). It is enough to program the right topic address (e.g. Nodes/10/RGB), this app is cool as it even provides colors pickers.

    By the way, we can see here a TVSet Power as well which is an off the shelf Wemo switch connected through OpenHAB2 and MQTT.

    Conclusion

    If you need just brighter light for your room, do not use this Panel which is more valuable than that, I plan to shit it to a central messaging notifiers and use it to display text and symbols.

  • Completely Hackable IoT dashboard

    Wassim04/26/2017 at 19:09 0 comments

    Demo

    • We can see here how the dashboard looks like, definitely not impressive but the good news is that it is completely hackable !!!

    So we can see there bullets going up with the temperature changing color accordingly, note that the color matches the gradient position of the rectangle it's in. The curves show the last 24 h, still planning to add dynamic real time animations, the technology allows but not the time. This page shows an ugly text debug window at the bottom helping me to check all received notifications.

    What's behind this ?

    • first of all, this is web, only web, html5 is helping, javascript is improving and the tools coming with it as well to make it a descent programming language.
    • I struggled looking for ready javascript libraries to show graphs such as highcharts or amcharts they look nice, but not only you get stuck with licence stuff but you cannot edit it to very customized display, the right choice ended on d3js

    D3js

    • d3js is a wrapper library around the svg standard which just makes selections easier and have a lot of helper functions and examples
    • The learning curve is long, but I highly recommend it to those who want to understand the web technology and not simply use it.

    Websockets

    • Another major improvement in the web, after struggling for server side events with comets or other alien like mechanisms, the websocket restart from scratch and provide an efficient tool already known and proved, the hack behind it is to start as an http request, and then upgrade to a websocket

    Poco

    • I know javascript is fancy, I know python is cool, sorry to say this but c++ is easier, here I'm not talking about personal preference. Not about writing code only which is obviously faster if you omit declarations, but I'm talking about the effort you spend from when you start writing your code till you get it running as you expect.
    • That is why I opted for a C++ application for netwroking where Poco marvelously does the trick. I hesitated between boost io and poco, then opted for poco as it is more than a library as it provides even application class, log and other helpers.

    Security

    • Some of you might wonder how would I secure this, with all polemics we read about every mentioning IoT devices being hacked, and I do yes access this remotely.
    • VPN : yes, the answer is simple, let us not re-invent the wheel, plus I have no time to spending updating every new patch of my authentication web interface. I admit here the solution was expensive, a VPN enabled router, but it's a single time payment for a multipurpose router and the result is independent from any 3rd party (other than simple domain name redirection).
    • It is important to note here how users can and must own their IoT devices by using tools that do not require third parties services that only work with registrations or even worse requiring active internet connections, here latency and confidentiality have to be taken into account.

    Some Javascript

    I learned how to split my javascript in more than one file (not trivial, yes, I'm serious), so I isolated the usage of the d3js graphic elements from a simple interface:

    var StatusParams = 
    {
    	svgID : "#StatusDisp",
    	data  :
    	[
    		{ x: 100, y: 100, r: 20, color: "Blue", 
    			Temperature : 26, Light : 500,
    			Name : "LivingRoom"
    		},
    		{ x: 300, y: 100, r: 20, color: "Blue", 
    			Temperature : 26, Light : 500,
    			Name : "BathRoom"
    		},
    		{ x: 500, y: 100, r: 20, color: "Blue", 
    			Temperature : 26, Light : 500,
    			Name : "Balcony"
    		}
    	]
    };
    
    var nmap = {6 : 0,
    			7 : 1,
    			16 : 2};
    
    //---------------------------------------------------------------------------
    //					Time Chart
    //---------------------------------------------------------------------------
    var now = Date.now();
    var start_disp = now - 24*60*60*1000;//1 day
    var ChartsParamsList = 
    [
    	{
    		svgID : "#ChartLivTemp",
    		scale_x_domain : [start_disp,now],
    		scale_y_domain : [10,25],
    		NodeId : 6,
    		SensorName : "Temperature",
    		Label : "Livingroom Temperature °C"
    	},
    	{
    		svgID : "#ChartLivHum"...
    Read more »

  • Open the bathroom window, Close the bathroom window

    Wassim04/26/2017 at 17:52 0 comments

    Demo

    • On the down right side of the video is the RGB Led status indicator that turns blue when the bathroom is humid (Humidity = Water = Blue) and green again when it is time to close it not to use much eating energy for example.
    • In this video, I closed the door to raise the humidity level, then opened the door and the window to evacuate it.

    Installation

    • STM8L wireless sensor node with its BME280 as a humidity sensor
    • An RF Repeater node that is visible on the down right side of the video which has an WS2812B as an RG led status indicator
    • A raspberry pi with an RF dongle as depicted in the Gallery HW + SW design

    Software : MQTT Ruler

    • The relevant software to fulfill this action in addition to the already installed HW+SW, is simply one small MQTT client, I wrote it in C++ but it could be in python as well, this client is nothing more than a ruler, it subscribes to an MQTT message (humidity level of the bathroom sensor id), and then produces a color depending on the level and send it again through another MQTT channel where the RF dongle is subscribed to send an RF signal to the right node id with the color to set.
    void mqtt_c::on_message(const struct mosquitto_message *message)
    {
        std::string msg(static_cast<const char*>(message->payload) );
        std::string topic(message->topic);
        if(topic.find("Nodes/") == 0)
        {
    		std::string Text = topic;
    		//the topic is "Node/6/Humidity"
    		utl::TakeParseTo(Text,'/');//remove first section 
    		std::string Id = utl::TakeParseTo(Text,'/');//take the second element
    		int NodeId = std::stoi(Id);
    		float humidity_val = std::stof(msg);
    		publish_humidity_status(NodeId,humidity_val);
    • This code extracts the node id from the Topic, converts the message payload from text to float and sends them together to the "publish_humidity_status()" function which is testing the node id, applying the rule and publishing the message.
    • The function applying the rule which converts the humidity float into a color can be seen below
    void from_50_Green_to_Blue(float humidity,unsigned char &red,
    									unsigned char &green,
    									unsigned char &blue)
    {
    	red = 0, green = 5, blue = 0;
    	if(humidity > 60)//60 -> 100
    	{
    		red = 0, green = 50, blue = 0;
    		float factor = (humidity - 60)/40;//0->1
    		float blue_f = 255 * factor;// 0 -> 255
    		blue = f2c_sat(blue_f);
    		float green_f = 50 - 50 * factor;// 50 -> 0
    		green = f2c_sat(green_f);
    	}
    	else if (humidity > 50)//50 -> 60
    	{
    		float factor = (humidity - 50)/10;//0 ->1
    		green = f2c_sat(5 + factor * 45);//5 -> 50
    	}
    }

    The complete MQTT humidity to color ruler can be found with the rest of the IoT_Frameworks repo here in github.


  • 60 RGB LEDs shading with that tiny STM8

    Wassim04/02/2017 at 10:03 0 comments

    Demo

    Yes, the STM8 less than $1 board can do it

    • shading colors of 60 LEDs by addressing every of them with the full 24 bits resolution.

    Firmware

    • The WS2812B bitbanging was detailed on the Hello Mesh Log
    • The 60 x 3 BYTEs info for RGB of every LED are first updated in the STM8 memory, then sent out.

    Shading colors

    What might look sophisticated for an LED application is a basic operation for a graphics application background

    //inputs: the leds section to use defined by which led to start with and which one to end before
    //inputs: The color of the first led to use and the color of the last led to use
    //action: updates the leds memory with the first and last led colors and all intermediate leds are interpolated
    //comment: This function does not send the led data bits on the bus, so that multiple operations can 
    //         be applied before sending the whole result together with SendLedsArray();
    void rgb_Shade(BYTE LedStart, BYTE LedEnd, RGBColor_t ColorStart, RGBColor_t ColorEnd)
    {
      int nbLeds = LedEnd - LedStart;
      BYTE LedId = LedStart;
      for(int iCount=0;iCount<nbLeds;iCount++)//0-10
      {
        RGBColor_t Ci = rgb_ColorScale(iCount,nbLeds,ColorStart,ColorEnd);
        rgb_SetColors(LedId,Ci);
        LedId++;
      }
    }
    • The rgb_Shade() function interpolates a range of LED colors

    //input : two colors, and ratio integers
    //output : the interpolaetd color
    //Sets the interpolated color between Colors Start and End, to the ratio of iCount/nbCount
    RGBColor_t rgb_ColorScale(int iCount,int nbCount,RGBColor_t ColorStart,RGBColor_t ColorEnd)
    {
        RGBColor_t resColor;
        
        int Red = (ColorEnd.R - ColorStart.R);//255
        Red = Red * iCount;//0 - 2550
        Red = ColorStart.R + (Red / (nbCount - 1));//0 - 255
        resColor.R = Red;
    
        int Green = (ColorEnd.G - ColorStart.G);//255
        Green = Green * iCount;//0 - 2550
        Green = ColorStart.G + (Green / (nbCount - 1));//0 - 255
        resColor.G = Green;
    
        int Blue = (ColorEnd.B - ColorStart.B);//255
        Blue = Blue * iCount;//0 - 2550
        Blue = ColorStart.B + (Blue / (nbCount - 1));//0 - 255
        resColor.B = Blue;
    
        return resColor;
    }
    • The rgb_ColorScale() interpolates one color to assign to every intermediate LED, which is interpolated between the start and the end color

    Animation

    • Although we address 60 Leds here, every with a different color, the information needed is parametric so very small and packed in few bytes to be sent in a small rf packet.
    • That could display smart information such as the Traffic conditions on the every day drive through path, or a heat map,...
    • The animation in the video has another loop on top, that interpolates the end color from Blue to RED, which is then fed as ColorEnd to the rgb_shade() function

    Source code

    • Just to mention that the complete project ready to flash on an STM8 with the IAR studio is part of the IoT_Frameworks github, namely in the rgb_led_bar folder

  • Hello Mesh - RGB Colors Broadcast

    Wassim03/22/2017 at 19:21 0 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 :

    • Broadcast use case

    Firmware

    WS2812B bitbanging

    • The challenge here was to make an 16MHz 8bit microcontroller namely the 1$ STM8S bread board talk to a WS2812B where the full fledged ones have to be using tricks and DMAs and timers and complex stuff.
    • As you might know there Smart RGB Leds are controlled with pulses that generate the 24bits of reg green blue, the problem is that every bit a pulse short or long for 0 or 1, and the Time for the high pulse of a zero as an example is 400 ns, well at 16MHz, every intruction is 62,5 nano second, that leave us with 6 instruction for looping and deciding which bit to bang the next.
    • The hack here was to jump down to assambler, yes in this world of javascript, if you really want to hack stuff that's the ultimate way.
    • Let's first have a look at a piece of the code

    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
    
    • rgb_sendArray is a C function, that starts by disabling the interrupts after saving the interrupts state to restitute them later on.
    • of course any interrupt here would corrupt the bit banging, so expect a latency on your interrupts handling.
    • The trick to have a multi line assembler that looks nice was to add the end line inside the asembler text.
    • This function can bag as many LEDs as you have RAM, unfortunately with the STM8S I could not compile more than ~ 220 bytes of continuous memory, which is more than enough for series of Leds.
    • The trick is to start by setting a PIO, which is a macro, as the pin is configurable, I did not manage to have text confurable variable inside the assembler, so that was the trick.
    • You always have to set a PIO high either it is a zero or a one, then as they have different timings, if it is not a zero then keep some more nops to make the one pulse longer, otherwise jump directly to the reset instruction to make the pulse shorter.
    • Now the problem was that looping instructions were not fast enough to cover all cases of second half of bit timings, that means that if we have to send the first bit, then loop, test and start sending the second bit, the loop would be so slow that it is not possible to set the new pulse soon enough. The only way to solve this was to unroll the complete 8 bits, yes unroll which means writing the same code 8 times, for bit one, bit two, bit three. I admit that sounds completely stupid from advanced programming perspective, but if anyone else could hold the challenge of banging WS2812B with the STM8S differently, I'd be very interested.
    • Any way, it's working, it's not very much code consuming, and it is very memory friendly as every bit to send take only one bit out of the memory, so that we save the RGB values in memory first as three consecutive bytes.

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

    Color Flashing

    • Not much is left to flash colors,...
    Read more »

View all 6 project logs

  • 1
    Step 1

    PCB Boards

    • The design files are available in the github STM8_IoI_Boards, and also attached as zip to this project files.
    • These files can be edited and produced with Eagle, the ready to order gerbers cam are also included in the zip file.
    • The STM8 Fixed Node v2 is easy as it uses the STM8S breadboard.
    • The STM8L Wireless Node (Mobile_v2) is hard as it uses the STM8L151F3 in TSSOP20 format.
      • To solder the TSSOP20 manually I use a flat edge iron.
      • I bought a lot of very cheap TSSOP20 components and board adapters to practice with.
      • The usage of Flux is a must.
      • Very important to glue the component first and wait that it holds.
    • I ordered the PCBs from an online PCB supplier, which costs about $15 for 10.
    • It is important that you combine multiple boards together to drop costs down, so don't hesitate to share the production with friends or community.
  • 2
    Step 2

    BOM and components sourcing

    I'm trying a new experience with online BOM that could facilitate the production and purchase, otherwise the BOM is also available in the zip file, though to facilitate the DIY production, these boards are based on modules.

    • STM8S_RF_Dongle_v2 findchip BOM
      • Here you need 4x res of 1K in 1206 format
      • The STM8S103F3P6 is the small blue pill module (very easy to find online, but not available on raw electronics parts suppliers)
      • The nRF24L01+, same is the ready module.
    • STM8L_RF_Sensors_v2 findchip BOM
      • The BME280 based module is referenced as GY-BMEP
      • The MAX44009 module is referenced as GY-49 (both modules are also very easy to find online and not from raw components suppliers)
      • MRMS211H, STM8L151F3P6 and resistances are raw components.
  • 3
    Step 3

    STM8 Firmware

    • The firmware is located in every corresponding directory close to the Rpi SW in the main IoT_Frameworks repo.
    • This repo contains a main libs folder in the root that contains the drivers that are shared by all applications.
    • It is possible to use free compilers, but I opted for a fully integrated solution including debug capabilities with the IAR for STM8. It is free for non commercial and requires registration but fully worth it.
    • You need an ST-Link_v2 which is available online for very cheap.
    • I use the ST Visual Develop to configure the option bits, verification and EEPROM programming (that where the nodeds are)
    • You need to install any driver for your USB to serial adapter (e.g. CP2102)
    • I use putty as a terminal.
    • I use Visual Studio Code for firmware as well
      • Note that you can add the include of the IAR compiler to have automatic completion

View all 4 instructions

Enjoy this project?

Share

Discussions

liveej wrote 08/19/2017 at 03:28 point

What are the shortcomings of this Protocol ?How many nodes can be accessed at most?

  Are you sure? yes | no

electrobob wrote 04/27/2017 at 20:43 point

Have you considered RFM69 instead of the NRF24 ? It should have no problem covering a house without any repeaters. 

I have started my own home automation with the NRF (actually another clone, RFM75) but dumped it. I always thought mesh is very sensitive (seen it nice in research under the assumption that the whole place is littered with always on repeater nodes).  

  Are you sure? yes | no

Wassim wrote 04/27/2017 at 21:29 point

Well actually yes, but it's a complex decision. (+) Technically, a lower freq has better walls penetration for sure. (-) modules are kind of more expensive, (-) sub 1 ghz regulations are kind of more complex. (-) more power comes with more consumptions up to 130 mA, the nrf24l01p has also the pa lna version with 100mA up to 1000m, so that's not for the low power battery nodes. (+) the RFM69 has even encription.

I 'liked' your Stockie project. Have you considered using the stm32? stm32+RFM69 might be something.

Actually custom mesh network is very easy, even trivial if you stick with a depth (time to live) of one or two. An always on repeater within reach in a house is a reasonable assumption. Low power batteries repeaters is on my list but that's indeed a whole different story.

  Are you sure? yes | no

electrobob wrote 04/28/2017 at 07:01 point

The RFM is indeed slightly less efficient (comparing both at 0dB output power). Honestly, I find too few places where AAA are too big to use. 

In 'Stockie' i found the NRF to not be a problem - these modules can actually cover a pretty big area (with the central node being a PA/LNA). BUT: with tens of WiFis around, it sometimes takes a lot of attempts to send a packet - when they find a gap. This is fine for the application, not fine for others. 

I have at some point earlier decided to switch to ARM and did consider the STM32, among others. Coming from AVR/Xmega atmel familiarity did play a role, but in the end 2 things mattered most: 1. Atmel studio is way more convenient for a hobbyist to us (ST has no interest to provide a free compiler when they are collaborating with the expensive companies like IAR). 2. The low power STM32L are quite expensive. 

So I went with the SAMD21. Since the arduino zero now uses it, i am hoping that soon we'll get arduino clones for cheap (I don't care about the arduino part, just the cheap hardware). 

  Are you sure? yes | no

electrobob wrote 04/28/2017 at 07:02 point

My home automation project starts here http://www.electrobob.com/1000-1000/ 

  Are you sure? yes | no

Wassim wrote 04/28/2017 at 18:53 point

The interference is really a low power killer, I prefer to resend the measures more frequently rather than to waist energy on listening, ack waiting and re transmitting.

The micro controller choice is something I re consider from time to time. I started my hobby career with dozens of PICs from Microchip, technically now owning Atmel as well. It's weird to see how ARM is gaining field, so either you use an Atmel or an ST, it is the arm-gcc compiler or the armcc after all. When it comes to IDEs, I lost faith in them as they take part of the fun away, and I believe that if everyone does a good job of providing standard interfaces (compiler, gdb,...), you could keep using your favorite IDE independent of which CPU you chose, PlatformIO is going in that direction.

Thanks for the link, I'll have a scan of it, it is always good to have a Hackaday entry point to help people find such projects.

  Are you sure? yes | no

electrobob wrote 04/29/2017 at 20:10 point

There are different trade-offs between the 2 modules. I think that the lowest power can be achieved with the NRF, provided the communication distance is small. In my tests, modules close to gateway could have 90% chance of sending a packet, while those far off in my apartment were dropping to even less than 10%. With the nrf all of them stay at more than 90% success rate. 
I was saying in my blog post that the ideal module would be a NRF with higher power (>10dB) and RSSI, so one can turn the transmission power down when not necessary. 

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates