Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. alowhum
    3. Best
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Best posts made by alowhum

    • GUIDE - NRF5 / NRF51 / NRF52 for beginners

      So you're curious about the NRF5 series boards huh? Let's dive in!

      // updates can be found below.

      WHAT IS THE NRF5
      It's a tiny Arm processor based board that can work like an Arduino. There are a few flavours.
      NRF51 $3
      NRF52 $3
      NRF52840 $20 (new, has built in usb support)

      Advantages:

      • Arduino with built in NRF24 for just $3.
      • The size of a postage stamp.
      • Powerful enough to use the simple encryption functionality easily.
      • Antenna socket: just plug in antenna for more range.
      • Ultra low power use.
      • You get to decide which pins do what. For example, you can decide through software which pins should be hardware serial pins. There's a small pin router built in.
      • Built in support for NFC (swiping smart cards and tags).

      Neutral:

      • Has 3.3v internal logic. Most new sensors use 3.3v for logic too.

      Negative:

      • Relatively new, so there might still be some bugs in MySensors.
      • The pins cannot handle as much current (5ma) as the Arduino's could (40ma).
      • Smaller pin spacing (1.27mm instead of 2.54mm), so harder to solder. Fewer expansion boards available.
      • Unlike the Arduino Nano, the programmer doesn't also function as a serial monitor. To get serial output you have to set some pins as the serial output, and then connect to those pins with a separate usb serial port adapter. It's a bit like the Arduino Pro Mini in that sense.
      • The EByte module has no onboard LED, which makes it difficult to know it's on, or to test things with a simple blink sketch.

      INSTALLATION
      Open the Arduino software and install these two boards in the Arduino IDE:
      https://github.com/sandeepmistry/arduino-nRF5
      https://github.com/mysensors/ArduinoBoards
      (click on the links to get installation instructions).

      Carefully soldered some wires to your board, and connected it a programming tool. The cheapest simplest option is to get an ST-Link v2 ($3).

      Connect:
      gnd ->gnd (in the corner)
      3.3v -> vcc (in the same corner)
      SWDIO -> SWDIO
      SWDCLK -> SWDCLK

      alt text

      Software
      In the Arduino IDE open an example (file -> examples -> myboardNRF5 -> myboardNRF5). You will now have three files:

      • Main file <- your main code goes here.
      • MyBoardNRF5.h <- here you can set which goodies you want, on which pins.
      • MyBoardNRF5.cpp <- probably no reason to change anything here.

      In the main file make sure it has these lines:
      #define MY_RADIO_NRF5_ESB
      #include <MySensors.h>

      Upload settings
      In the Arduino IDe click on the tools dropdown and start set things up like this:

      • Board: "MyBoardNRF5 NRF52832"
      • Reset: "don't enable"
      • Bootloader/SD: "none"
      • Low frequency clock: "Crystal Oscilator" (RC Oscillator might work too).
      • Port: none
      • Programmer: ST-Link V2

      First the chip you are using must be 'wiped'. This removes the bluetooth functionality. Wipe the chip by clicking "tools -> burn bootloader". You'll get an error but that's normal.

      Next, when your sketch is complete, choose "sketch -> upload via programmer".

      POWER HUNGRY SENSORS
      If you were using an Arduino Nano before, then you might have powered your sensors directly from the Arduino's 5v pin. With these boards you can't run the power through the NRF5 board first. Make the 5V go 'around it'. Only use these boards to collect and send signals. To get a steady power supply, depending on how much you need, you could try:

      • An AMS1117 regulator. It can generate a max of 800ma at 3.3v. Here's a small version.
      • Special power supply boards such as this one.

      TROUBLESHOOTING

      • Timed out while waiting for target halted: are your pins connected ok?
      • Unable to reset target: are your pins connected ok?

      ADVANCED KNOWLEDGE

      • Some things, like turning on a pin when you press a button, can be handled by (programmed into) the 'periphery' of the chip. Not having to wake up the main chip saves some power. An example of this can be found here.

      POPULAR BOARDS

      Ebyte N73 - Manual

      • Cheap: $3
      • Is missing some parts that allows for super low power usage. Those can be added manually though.
      • Forum users have created some nice pre-made prototyping boards, like this small one or this big one.
      • Uses 91 milli amps max (while transmitting).

      Fanstel BT832X

      • Can't find the price
      • Better range than the EByte
      • Has the required 'DCDC' parts built in, allowing for super low battery usage.
      • Uses 250ma max

      Holyiot TinyBLE

      • About $5
      • Tiny! This also means it has less ports.

      UPDATE

      The easiest way to get started with NRF5 might actually be the BCC Microbit.

      posted in Development
      alowhum
      alowhum
    • Candle - the privacy friendly smart home

      At the upcoming Dutch Design Week from 19 till the 26th of October me and my team will be launching a project called "Candle". It's a privacy friendly smart home demonstrator that is built on, amongst other things, MySensors.

      Candle's goal is to accelerate the development of more privacy friendly smart devices by showing examples of what this future could look like. It proves you don't have to choose between privacy and easy of use. With good privacy design you can have both.

      We have asked artists and designers to create prototypes based on the code and electronics I developed. For example, juweler Dinie Besems created devices with a luxury appeal.

      CO2 sensor by Dinie Besems
      CO2 sensor

      Fine dust sensor by Dinie Besems
      Fine dust sensor

      More on her creations here.

      Engineer Paola Rodrigues also created two devices. This is her version of the Signal hub:

      Signal hub by Paola Rodrigues
      The signal hub can copy and/or learn to recognise 433Mhz devices

      And her version of the temperature, humidity and barometer device (using the BME280):
      Weather station by Paola Rodrigues
      Paola added extra LED's to make the sensor levels readable from far away.

      At the moment designer Jesse Howard, an expert on Open Design, is finishing work on his creations.

      NARRATIVES

      Using MySensors allowed us to really push a number of narratives that are juxtaposed to current IoT design practices:

      • Smart devices often use wifi to connect to the home network and the internet. To us, both of these things were unacceptable. If devices can access the internet themseles, who knows what they are sending. If they can connect to the home network, they form an attractive entrypoint for hackers looking to access other devices on the home network. MySensors, Zigbee/Z-wave and even Bluetooth were more acceptable to us, since since they form their own local network which can be kept separate.
      • Smart devices are often overpowered. Big arm chips, together with the wifi connection, make them an attractive target for hackers, who can use them as beach heads for further invasion of the home network. Candle uses 'minimal viable hardware', in this case the RF Nano. This decreases the attack surface.
      • The power of open source allows users to inspect the code, and thus gain/rebuild trust. In some cases the hardware reflects this call for transparency by being literally transparent. No hidden microphones here.
      • The power of open source allows users to learn more about their technology, and even modify it. It's empowering.

      EDUCATION AND DIY

      A secondary goal was to allow users to relatively easily create the devices themselves. Besides creating the MySensors add-on for the Mozilla WebThings Gatway we also created the Candle Manager add-on. This makes it easy to upload MySensors code to an Arduino. Just connect it through USB to the central controller, and follow the steps in an easy to use interface. Arduino code is then compiled and uploaded to the board, thanks to the new Arduino CLI.

      Candle Manager
      The Candle manager

      To aid in education, all Candle devices can be made without needing to solder. Dupont wires are all you need.

      INNOVATIONS

      MySensors allowed us to quickly prototype and test new privacy enhancing designs and ideas. Some examples are:

      • All Jesse's devices can be disconnected from the MySensors network with a physical hardware switch. While the devices gain functionality when networked together, all of them will also work fine as stand alone devices. For example, all sensors have their own screens to display their current values. Ideally, all smart devices should have a switch with three settings: (1) do not talk (2) data may be shared within the local (MySensors) network (3) Data may shared locally and with the internet.
      • The CO2 sensor has the option to generate 'fake data' by toggling a hardware switch. If you turn this on, it will generate more data that is similar to the last few real measurements. Why it is important to have this feature is explained in depth on the website.

      SOURCE CODE
      Most of the source code can already be found on Github, including the MySensors sketches. More of the code being will be uploaded as the launch exhibit draws closer.

      THANKS

      This project has been made possible with support from the Creative Industries Fund NL. The creation of the machine learning aspects of the project were supported by the SHERPA project, which is a Horizon 2020 research project by the European Union.

      I want to give a special thanks to @Anticimex for creating the user friendly security options. Thank you!

      LOOKING FOR MAKERS

      I am still looking for volunteers that would like to create one or more of the Candle devices and have their creation exhibited alongside the other works. We will pay for your hardware and materials costs. If you're interested, send me a message.

      If you're in the Netherlands at the end of October, please come and say hi at the exhibit.

      posted in My Project
      alowhum
      alowhum
    • Candle won a Dutch National Privacy Award

      I'm proud to say that Candle, the privacy friendly smart home project that's based on MySensors, has won a Dutch National Privacy Award.

      I just wanted to say it literally wasn't possible without all your help, patience, and of course the large amount of open source code that Candle could build upon.

      Thanks everyone!

      privacy_award_mini_exhibit.jpg

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • Candle - signal Hub - A universal 433Mhz signal detector and cloner

      It took three weeks to build, but here it is: a device that will easily connect almost any 433Mhz device to your smart home.

      The 433 Hub can do two things:

      • You can teach it a signal, and from then on it will be able to detect it.
      • You can teach it a signal, and from then on it will be able to replay it.

      Both of these features come in 'single signal' and 'on+off" versions. So for example:

      • You could copy the ON and OFF button from a remote for your 433Mhz sockets, and from then on switch the socket from your smart home controller.
      • You could teach it to detect window sensors that have both on and off states.
      • You could teach it to detect the alarm signal from a wireless smoke detector.

      For each signal that you teach it to recognise, a door sensor will be presented to your controller.
      For each signal that you teach it to replay, an on/off switch will be presented to your controller.

      Signals take between 8 and 28 bytes to store, depending on complexity and if they are simple or on+off signals. This means an Arduino Nano can store between 20 and 60 signals in just half of it's eeprom (512 bytes).

      HARDWARE

      • Arduino

      • 433Mhz receiver & transmitter

      • Touch screen (optional, recommended)
        or

      • OLED screen (optional)

      • Keypad (optional)

      Here's the version that uses a touch screen.
      0_1551117671838_20190218_220842_resized.jpg
      0_1551117742127_20190218_220924_resized.jpg

      Here's a version that uses a keypad.
      0_1547905513000_433hub-lowres.jpg
      With a 12 button keypad you can easily replay 10 signals. The last two buttons are used to navigate and make selections in the menu system.

      You can also trigger the learning sequences from 4 virtual buttons that the device creates on your controller (detect simple, detect on+off, replay simple, replay on+off).

      It works best if you use the touch screen. Using the menu you can delete the last recorded signal, or delete all recorded signals.

      It's designed to work with the upcoming Candle privacy friendly smart home, and the Candle Manager. More on that later this year.

      CODE
      https://github.com/createcandle/Devices/blob/master/Signal-hub/Signal-hub.ino

      posted in My Project
      alowhum
      alowhum
    • Mozilla Webthings MySensors add-on / adapter

      This is an add-on for the excellent Mozilla WebThings Gateway that will allow MySensors devices to work with it.

      .

      THE MOZILLA WEBTHINGS GATEWAY

      This smart home software, made by the people behind Firefox, focuses on being very user friendly. Here are my MySensors devices in the things overview:

      0_1556012649800_mysensors-things.png

      You can also log data with it:

      0_1556012681000_mysensors-log.png

      .

      INSTALLATION

      Just select the add-on via the gateway interface. You're done!

      .

      Q.
      My things are not showing up?

      When the add-on is installed, you will need to restart your nodes so that they present themselves. Once you've restarted all your nodes, click on the (+) button on the things page to add them to your list of things.

      .

      Q.
      Not all my children have been turned into properties?

      Because of the way that things are currently developed, a new child/property will only be added to the device if a 'set' message for it is received. That's because only then does it become clear with which V_TYPE the S_INFO type is populated.

      For example, let's say you send a presentation message for a button:

      present(RELAY_1, S_BINARY, F("Relay 1"));
      

      This child won't show up as a property until you tell the WebThings Gateway if that button should be in the on of off position. So in your setup function you should also do something like:

      send(relaymsg.set(0));
      

      .

      Q.
      Is type X or Y supported?

      The controller page on this website can give you an indication. You can also check how your preferred sensor type is supported by looking at the actual code at the bottom of this file.

      .

      Q.
      Can I make changes to the code?

      Yes you can, and help is always welcome. The code can be found here:

      https://github.com/createcandle/Webthings-mysensors-adapter

      It's based on the excellent work on pyMySensors by Theo Lind, as well as the example add-on created by Michael Stegeman, who works for Mozilla. Thanks to both!

      If you want to use the code manually, perhaps to co-develop it, here's how:

      • Enable SSH (under settings -> developer) and log into the device as normal.
      • Download the code via Github:
      cd ~/.mozilla-iot/addons/
      git clone https://github.com/createcandle/Webthings-mysensors-adapter.git
      

      Now delete the .tgz file and restart the gateway so it no longer loads the .tgz file.

      sudo systemctl restart mozilla-iot-gateway.service
      

      Now you can run the code manually to test it.

      python3 main.py
      

      You will see a lot of messages scroll by.

      The three most important files are in the pkg folder.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      Great news: the add-on has been accepted. You can now just select the add-on through the interface of the Mozilla Webthings Gateway.

      Here is it is after installation:
      0_1556265796800_adapter-overview.png

      Once installed you will see the option to change settings:
      0_1556265827400_adapter-settings.png

      Currently these settings don't do anything yet. That will be handled in the next release. First in line will be the ethernet gateway option. In theory the MQTT option should also be possible.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Next generation dust sensor for MySensors

      Here's MySensors Arduino code for the PMS-7003. Many thanks to scapeler.com for the core of the code.

      /*
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       *  DESCRIPTION
       *
       *  Plantower PMS-7003 fine dust sensor
       *  
       *  This sensor uses a frickin' laser to measure lots of different fine dust levels, between 0.3 and 10 microns.
       *  
       *  It communicates with your board over serial at 9600 speed.
       *  
       *  
       *  This code makes use of kindly shared code by Scapeler:
       *  
       *  - - -
       *  Copyright 2017 Scapeler
       * 
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
      
          http://www.apache.org/licenses/LICENSE-2.0
      
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       * - - -
      */
      
      //------------------------------------------------------------------------------
      
      // if you uncomment this, you can get test and debug updates about the sensor' wireless connection by using the serial monitor tool.
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24                              // A 2.4Ghz transmitter and receiver, often used with MySensors.
      #define MY_RF24_PA_LEVEL RF24_PA_MIN                // This sets a low-power mode for the radio. Useful if you use the verison with the bigger antenna, but don't want to power that from a separate power source. It can also fix problems with fake Chinese versions of the radio.
      // #define MY_RADIO_RFM69                           // 433Mhz transmitter and reveiver.
      
      // Choose if you want this sensor to also be a repeater.
      // #define MY_REPEATER_FEATURE                      // Just remove the two slashes at the beginning of this line to also enable this sensor to act as a repeater for other sensors. If this node is on battery power, you probably shouldn't enable this.
      
      // Are you using this sensor on battery power?
      // #define BATTERY_POWERED                          // Just remove the two slashes at the beginning of this line if your node is battery powered. It will then go into deep sleep as much as possible. While it's sleeping it can't work as a repeater!
      
      #include <SPI.h>
      #include <MySensors.h>
      #include <SoftwareSerial.h>
      
      #define CHILD_ID_DUST_PM10 0
      #define CHILD_ID_DUST_PM25 1
      #define CHILD_ID_DUST_PM100 2
      
      
      // Mysensors settings.
      MyMessage msgDust10(CHILD_ID_DUST_PM10, V_LEVEL);   // Sets up the message format that we'l be sending to the MySensors gateway later.
      MyMessage msgDust10b(CHILD_ID_DUST_PM10, V_UNIT_PREFIX);
      MyMessage msgDust25(CHILD_ID_DUST_PM25, V_LEVEL);   // Sets up the message format that we'l be sending to the MySensors gateway later.
      MyMessage msgDust25b(CHILD_ID_DUST_PM25, V_UNIT_PREFIX);
      MyMessage msgDust100(CHILD_ID_DUST_PM100, V_LEVEL); // Sets up the message format that we'l be sending to the MySensors gateway later.
      MyMessage msgDust100b(CHILD_ID_DUST_PM100, V_UNIT_PREFIX);
      
      
      
      // These defines and variables can be changed:
      int dustSlowDown = 20;                              // The dust sensor is internally checked approximately every 700 or 800 milliseconds. Once in how many loops should it send the data?
      unsigned long dustMeasurementInterval = 700;        // This is a fickle thing. Changing it can give more time-outs.
      SoftwareSerial mySerial(10, 11);                    // RX, TX . You can choose other pins if you prefer.
      
      
      // PROBABLY BEST NOT TO CHANGE THESE VARIABLES
      int inputHigh = 0;
      int inputLow = 0;
      uint16_t inputChecksum = 0;                         // variable to caclulate checksum input variables
      uint16_t concPM1_0_CF1;                             // Lots of sensor variables
      uint16_t concPM2_5_CF1;
      uint16_t concPM10_0_CF1;
      uint16_t concPM1_0_amb;
      uint16_t concPM2_5_amb;
      uint16_t concPM10_0_amb;
      uint16_t rawGt0_3um;
      uint16_t rawGt0_5um;
      uint16_t rawGt1_0um;
      uint16_t rawGt2_5um;
      uint16_t rawGt5_0um;
      uint16_t rawGt10_0um;
      uint8_t  version;
      uint8_t  errorCode;
      uint16_t checksum;
      int dustSlowDownCounter = 0;
      
      
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Air Quality Sensor PMS-7003", "1.1");
      
        // Register all sensors to gateway (they will be created as child devices): 
        present(CHILD_ID_DUST_PM10, S_DUST);
        send(msgDust10b.set("um/m3"));  
        present(CHILD_ID_DUST_PM25, S_DUST);
        send(msgDust25b.set("um/m3"));
        present(CHILD_ID_DUST_PM100, S_DUST);
        send(msgDust100b.set("um/m3"));  
      }
      
      
      void setup() {
        Serial.begin(115200);
        delay(1000);
        mySerial.begin(9600);
        delay(1000);
        Serial.println("hello world, I am a sensor.");
      }
      
      
      void loop() {
      
        // The dust sensor sends its data continuously, so let's  catch that data.
        int dustSensorOutput = pms7003ReadData();
        
      }
      
      
      // MAIN FUNCTION FOR THE DUST SENSOR, Thanks to Scapeler.nl
      int pms7003ReadData() {
          
        // while (mySerial.read()!=-1) {};  //clear buffer
      
        if (mySerial.available() < 32) {
          if (mySerial.available() == 0) {
            delay(150);
            return -1;
          };
          if (mySerial.available() > 16) {
            delay(10);
            return -1;
          };
          if (mySerial.available() > 0) {
            delay(30);
            return -1;
          };
          delay(100);
          return -1;
        }
        if (mySerial.read() != 0x42) return -1;
        if (mySerial.read() != 0x4D) return -1;
      
        inputChecksum = 0x42 + 0x4D;
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        if (inputHigh != 0x00) return -1; 
        if (inputLow != 0x1c) return -1;    
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        concPM1_0_CF1 = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        concPM2_5_CF1 = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        concPM10_0_CF1 = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        concPM1_0_amb = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        concPM2_5_amb = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        concPM10_0_amb = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        rawGt0_3um = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        rawGt0_5um = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        rawGt1_0um = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        rawGt2_5um = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        rawGt5_0um = inputLow+(inputHigh<<8);
      
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        inputChecksum += inputHigh + inputLow;
        rawGt10_0um = inputLow+(inputHigh<<8);
      
        inputLow = mySerial.read();
        inputChecksum += inputLow;
        version = inputLow;
      
        inputLow = mySerial.read();
        inputChecksum += inputLow;
        errorCode = inputLow;
      
        Serial.print("PMS7003;"); 
      
        // The measurement recalculated to micrograms per cubic meter, a common standard.
        Serial.print(concPM1_0_CF1);
        Serial.print(';'); 
        Serial.print(concPM2_5_CF1);
        Serial.print(';'); 
        Serial.print(concPM10_0_CF1);
        Serial.print(';'); 
      
        // The measurement recalculated to micrograms per cubic meter, a common standard. Not quite sure what the difference is..
        Serial.print(concPM1_0_amb);
        Serial.print(';'); 
        Serial.print(concPM2_5_amb);
        Serial.print(';');     
        Serial.print(concPM10_0_amb);
        Serial.print(';');     
      
        // this is the 'raw' data that the sensor gathers internally, before it calculates the above values.
        Serial.print(rawGt0_3um); // This indicates total number or particles in 0.1 liter of air that have a diameter above 0.3um. This will be the biggest number, as it measures the most particles. But it's very imprecise: 50% accuracy..
        Serial.print(';');
        Serial.print(rawGt0_5um); // This indicates the total number or particles in 0.1 liter of air that have a diameter above 0.5um (so it will be a smaller count than the line above)
        Serial.print(';'); 
        Serial.print(rawGt1_0um); // This indicates the total number or particles in 0.1 liter of air that have a diameter above 1 micron. And so on..
        Serial.print(';'); 
        Serial.print(rawGt2_5um);
        Serial.print(';'); 
        Serial.print(rawGt5_0um); // Acording to the datashet, at this point the accuracy has reached at 98%.
        Serial.print(';'); 
        Serial.print(rawGt10_0um);
        Serial.print(';'); 
        Serial.print(version);
        Serial.print(';'); 
        Serial.print(errorCode);
        Serial.println("---");
        
        inputHigh = mySerial.read();
        inputLow = mySerial.read();
        checksum = inputLow+(inputHigh<<8);
        if (checksum != inputChecksum) {
          Serial.print(';'); 
          Serial.print(checksum); 
          Serial.print(';'); 
          Serial.print(inputChecksum); 
        }
      
        // Time to send the results to the gateway.
        dustSlowDownCounter = dustSlowDownCounter + 1;
        if(dustSlowDownCounter > dustSlowDown){
          
          /*  MEASUREMENT  */
          if(rawGt1_0um > 0){
            Serial.println(" Dust1_0 = " + String(concPM1_0_CF1));
            send(msgDust10.set(concPM1_0_CF1,1));
          }         
          if(rawGt2_5um > 0){
            Serial.println(" Dust1_0 = " + String(concPM2_5_CF1));
            send(msgDust25.set(concPM2_5_CF1,1));
          }     
          if(rawGt10_0um > 0){
            Serial.println(" Dust1_0 = " + String(concPM10_0_CF1));
            send(msgDust100.set(concPM10_0_CF1,1));
          }     
      
          /*  RAW DATA  */            
          /*
          if(rawGt0_3um > 0){
            Serial.println(" Dust03 = " + String(rawGt0_3um));
            send(msgDust03.set(rawGt0_3um,1));
          }
          if(rawGt0_5um > 0){
            Serial.println(" Dust05 = " + String(rawGt0_5um));
            send(msgDust05.set(rawGt0_5um,1));
          }
          if(rawGt1_0um > 0){
            Serial.println(" Dust10 = " + String(rawGt1_0um));
            send(msgDust10.set(rawGt1_0um,1));
          }
          if(rawGt2_5um > 0){
            Serial.println(" Dust25 = " + String(rawGt2_5um));
            send(msgDust25.set(rawGt2_5um,1));
          }
          if(rawGt5_0um > 0){
            Serial.println(" Dust50 = " + String(rawGt5_0um));
            send(msgDust50.set(rawGt5_0um,1));
          }      
          if(rawGt10_0um > 0){
            Serial.println(" Dust100 = " + String(rawGt10_0um));
            send(msgDust100.set(rawGt10_0um,1));
          }   
          */
      
          dustSlowDownCounter = 0;
        } // End of sensing message.
        
        delay(700);  // Data will come between 200 and 800 miliseconds. If you set this be be higher than 700 you will get checksum errors.
          
        return concPM2_5_CF1; // this data doesn't really go anywhere..
      }
      
      
      
      
      posted in General Discussion
      alowhum
      alowhum
    • RE: New non-blocking temperature sensor code

      I've added your suggestions, cleaned the code to conform to standards better, and tested the new version in various configurations.

      I've created a pull request on Github for this to become the new code. And a few days ago I created a page on OpenHardware.io that could be the start of a new page about the sensor, if need be.

      Once my BME280 sensor arrives, I will create a new seperate version based on that. My suggestion is that the MySensors homepage should somehow point to two temperature sensors:

      • One for mass sensor network deployment (this one, based on the cheap Dallas).
      • One for home automation (the more expensive but awesome BME280).
      posted in Development
      alowhum
      alowhum
    • MySensors Smart Watch

      After a bit of discussion in the nRF5 thread, it might be useful to create a thread specifically focussed on the subject of re-purposing cheap nRF5 smart watches to use as MySensors nodes.

      Why would I want a MySensors smart watch?

      • If you want a power sipping node with an oled screen and a few sensors.. well you just described a smart watch.
      • From a privacy perspective, most smart watches are horribly designed. A MySensors smart watch could offer the advantages of a smart watch without all the cloud connections and bluetooth tracking risks.
      • It's cool.

      What has been done?
      Surprisingly, quite a bit. Have a look here:
      https://github.com/micooke/arduino-nRF5-smartwatches/
      https://github.com/curtpw/nRF5x-device-reverse-engineering
      https://github.com/goran-mahovlic/nRF51_ID107_libs
      https://github.com/goran-mahovlic/openwatch

      What should I look out for?

      • The holy grail would be a smart watch that can be updated via DFU over the air. That way you don't have to open it, which often destroys any waterproofing. Of course this only matters if you want to actually use it as a watch and not, say, as a small tabletop display.
      • In some of these cheap devices the heart rate and/or blood pressure devices are very poor quality, meaning you will get eratic results.
      • Currently you may need a JLink or Black Magic Probe debugger to gain control over these devices.

      Discussion
      There is a chat here

      Popular devices

      • ID107HR - It's an older NRF51, but the advantage is that the screen has been mapped, the pads are clear, and it can be opened with a small screwdriver. It's your best bet.
      • ID107HR Plus - NRF52 version. The screen doesn't seem to be mapped yet. It's glued shut, and incredibly difficult to open.

      Getting started

      • Get or make a Black Magic probe.
      • Buy an ID107HR (€15 at Gearbest)
      1. Install sandeep's git from https://github.com/sandeepmistry/arduino-nRF5. Do refer to instructions at the bottom of the git to install as a development core (supports Black Magic Probe), i.e. clone/copy repo into 'Arduino/hardware/sandeepmistry/nRF5' folder.
      2. Install ARM Cortex support by installing SAMD boards via Arduino Board Manager interface.
      3. Overwrite the variants files located in your 'Arduino/hardware/sandeepmistry/nRF5/variants/Generic' folder' using the files from https://github.com/rogerclarkmelbourne/arduino-nRF5-customised/tree/master/variants/ID107HR_smartwatch.
      4. Install Goran's git from https://github.com/goran-mahovlic/nRF51_ID107_libs and load up the example sketch of 'SmartyV2ClockOledAcc.ino'.
      5. Select the Board 'Generic nRF51' from the 'Nordic Semiconductor nRF5 Boards' menu. Select the 'Black Magic Probe (GDB)' from the programmer menu. Compile/upload.
      posted in General Discussion
      alowhum
      alowhum
    • RE: Where did everyone go?

      I used MySensors to create a privacy friendly smart home demonstrator called Candle. Quite a few people are building it, but they may not even realise they are using MySensors.

      In this project my own attention certainly has shifted a bit. Cheap Zigbee dongles and devices aid my goal of moving Candle in a more consumer friendly direction, so that people could just buy most of the parts ready-to-go, and still keep everything local. Some devices will still be MySensors devices, simply because there aren't any privacy friendly alternatives that I know of. But a temperature and humidity sensor, those use Zigbee for me now. And I'm moving the privacy features from the arduino code into the central controller instead.

      Speculation about other factors:

      • Practical Arduino hardware education isn't happening right now because of covid. And even there, there are so many hardware options now. Microbits, ESP32, etc.
      • I've also noticed people asking about standardisation, and caring about interoperability.
      • There are many more products available now. Edge cases are being catered to, e.g. gardening.

      Things that might help for me:

      • I really wish there was a cheap, widely available Arduino akin to the RF-Nano, but with RFM69 433Mhz. MySensors has always had range issues for me on 2.4ghz.
      • The MySensors implementation doesn't make it easy for devices to describe the UI they would like. E.g. if a device is read-only or toggle-able is currently dependent on the type, instead of being a factor that can be set for each sensor type independently.

      A new website with a strong focus on new users, USP's (cheap privacy & friendly, or just fun, educational and artisanal) and up-to-date examples might help.

      This all may sound critical, but that's not the intention. I really dig MySensors. It's definitely in my toolbelt.

      posted in General Discussion
      alowhum
      alowhum
    • RE: Candle - the privacy friendly smart home

      Today the project was featured on Hackaday 🙂

      https://hackaday.com/2019/11/06/the-open-source-smart-home/

      posted in My Project
      alowhum
      alowhum
    • New non-blocking temperature sensor code

      I rewrote the temperature sensor code.

      • It no longer uses Sleep, so it can be used as a repeater.
      • It's now cleaner and documented.
      • It now has serial debugging features.

      Could someone place this code on the website?

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Example sketch showing how to send in DS1820B OneWire temperature readings back to the controller
       * http://www.mysensors.org/build/temp
       * 
       * The cool thing about this temperature sensor (pun intended) is thay you can attach multiple Dallas temperature sensors outputs to the same arduino pin. They will all automatically be recognised as separate sensors.
       * 
       * At the moment of writing (februari 2017) you need older versions of the Dallas and OneWire libraries. Please check the website or forum to see if this is still the case.
       * 
       * Modifications by anonymous user so that it can now simultaneously function as a MySensors repeater. 
       */
      
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG 
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RF24_PA_LEVEL RF24_PA_MIN              // This sets a low-power mode for the radio. Useful if you use the version with the bigger antenna, but don' want to power that from a separate source. It can also fix problems with fake Chinese versions of the radio.
      //#define MY_RADIO_RFM69
      
      // Choose if you want this sensor to also be a repeater.
      // #define MY_REPEATER_FEATURE                    // Just remove the two slashes at the beginning of this line to also enable this sensor to act as a repeater for other sensors.
      
      #include <SPI.h>
      #include <MySensors.h>  
      #include <DallasTemperature.h>                  
      #include <OneWire.h>                              
      
      // These variables can be changed:
      #define COMPARE_TEMP 1                            // Send temperature only if changed? 1 = Yes 0 = No
      #define ONE_WIRE_BUS 3                            // Pin where dallase sensor is connected 
      #define MAX_ATTACHED_DS18B20 16                   // Maximum amount of teperature sensors you can connect to this arduino (16).
      unsigned long MEASUREMENT_INTERVAL = 30000;       // Time to wait between reads (in milliseconds).
      
      // You shouldn't change these:
      OneWire oneWire(ONE_WIRE_BUS);                    // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
      DallasTemperature sensors(&oneWire);              // Pass the oneWire reference to Dallas Temperature. 
      float lastTemperature[MAX_ATTACHED_DS18B20];      // creates an array to hold the previous temperature measurements for each possible sensor.
      int numSensors=0;                                 // variable to contain the number of found attached sensors.
      boolean receivedConfig = false;                   // I have no idea what this does.
      boolean metric = true;                            // Probably used by the Dallas library as an indication if the temperature should be calculated in Celsius (metric) or Fahrenheit.
      boolean CURRENTLY_MEASURING = true;               // Used to indicate when the time is right for a new measurement to be made.
      boolean CURRENTLY_CALCULATING = false;            // Used to bridge the time that is needed to calculate the temperature values by the Dallas library.
      unsigned long CURRENT_MILLIS = 0;                 // The millisecond clock in the main loop.
      unsigned long PREVIOUS_MEASUREMENT_MILLIS = 0;    // Used to remember the time of the last temperature measurement.
      int16_t CONVERSION_TIME = 0;                      // Used to store the time needed to calculate the temperature from measurements.
      
      // Mysensors settings
      MyMessage msg(0,V_TEMP);
      
      void before()
      {
        sensors.begin();                                // Startup up the OneWire library
      }
      
      void setup()  
      { 
        for(int i=0;i<MAX_ATTACHED_DS18B20;i++){lastTemperature[i] = 0;} //Pre-filling array with 0's.
        sensors.setWaitForConversion(false);            // requestTemperatures() will not block current thread
        Serial.begin(115200);                           // for serial debugging.
        Serial.print("Hello world, I am a sensor. \n ");
      
      }
      
      void presentation() {
        sendSketchInfo("Temperature Sensor", "1.2");    // Send the sketch version information to the gateway and Controller
        numSensors = sensors.getDeviceCount();          // Fetch the number of attached temperature sensors  
      
        
        for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {   
           present(i, S_TEMP);                          // Present all sensors to controller (16 maximum).
        }
      }
      
      void loop(){     
      
        CURRENT_MILLIS = millis(); // The time since the sensor started, counted in milliseconds. This script tries to avoid using the Sleep function, so that it could at the same time be a MySensors repeater.
      
      
        // Let's measure the temperature
        if(CURRENTLY_MEASURING == true && CURRENT_MILLIS - PREVIOUS_MEASUREMENT_MILLIS >= MEASUREMENT_INTERVAL){ // If we'e not calculating, and enough time has passed, we'll start again.
          CURRENTLY_MEASURING == false; // We're measuring, so let's take it off our to-do list.
          Serial.print("Starting new measurement(s)\n");
          PREVIOUS_MEASUREMENT_MILLIS = CURRENT_MILLIS; // Mark the time of the initialiation of this measurement.
         
          // Fetch temperatures from Dallas sensors
          sensors.requestTemperatures();
          
          // query conversion time. Apparently it takes a while to calculate?
          CONVERSION_TIME = sensors.millisToWaitForConversion(sensors.getResolution());
      
          CURRENTLY_CALCULATING = true; //Next step is to re-calculate the temperature again.
        }
      
      
        // Let's calculate and send the temperature
        if(CURRENTLY_CALCULATING == true && CURRENT_MILLIS > PREVIOUS_MEASUREMENT_MILLIS + CONVERSION_TIME ){
          CURRENTLY_CALCULATING = false; // check calculating off the to-do list too.
          for (int i=0; i<numSensors && i<MAX_ATTACHED_DS18B20; i++) {    // Loop through all the attached temperatur sensors.
          
            float temperature = static_cast<float>(static_cast<int>((getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i)) * 10.)) / 10.;   // Fetch and round temperature to one decimal
            
            Serial.print("Sensor #");
            Serial.print(i);
            Serial.print(" says it is ");
            Serial.print(temperature);
            Serial.print(" degrees\n");
            
            if(temperature != -127.00 && temperature != 85.00){ // avoid working with measurement errors.
              if (COMPARE_TEMP == 1 && lastTemperature[i] == temperature){
                Serial.print("Not sending it though, because it's the same temperature as before.\n");
              }
              else
              {
                Serial.print("Sending the temperature to the gateway.\n");
                send(msg.setSensor(i).set(temperature,1));
                lastTemperature[i] = temperature; // Save new temperatures to be able to compare in the next round.
              }
            }  
          }
          CURRENTLY_MEASURING = true; // Both tasks are done. Now we'll just wait for the measurement interval to be over.
          Serial.print("zzzzZZZZzzzzZZZZzzzz\n");
        }
      
      }
      
      posted in Development
      alowhum
      alowhum
    • RE: The examples on the website need love

      Im sorry, but you are misrepresenting my position.

      • I started this post to contribute, and point out an area where I wanted to do some good: to help this project live up to its promise of 'ready to use code examples'.
      • I never said I wanted plug-and-play, that was just to offset the narrative that plug-and-play is not a valuable thing. What it's about is creating a gentle slope to get new people involved in the community. Beginners need working code to help them stay interested in the promise of the project. If the hill is too steep, people will stop climbing. Because of survivorship bias you don't see all the people who tried and quit using MySensors.
      • I have contributed to multiple open source projects, including this one, so I know exactly what you mean about the effort. It also means that when I talk about wasted time, I know what I'm talking about. If two of the sensors I try need me to jump through a lot of hoops, and not the fun kind, then that's something we need to fix. I mean, with the WaveShare device the code for the dust sensor would give twice the level of actual dust! And that code has been on the website for half a year!

      I may have misinterpreted, but it seemed to me that MySensors project understood that the onboarding of new people is vital. The friendly design of the website with the cute drawings, the light-hearted writing, that seemed like a conscious strategy. One I can totally agree with. But if that's the strategy, then the examples need some love. That's all I was trying to say.

      What doesn't help is to paint things, and me, black-and-white. Pointing out that the examples don't work does not make me someone who is demanding 'plug and play'. And I don't think it's honest to then paint broken examples as a 'feature' to aid learning. I believe I was just trying to point to a valid concern about keeping it fun for new people to get involved. I thought this community understood that value given the light-hearted design choices.

      So when I post "steer clear of this one for now" at the Dust sensor page, it's not to disrespect you, but to help new people understand that the sensor is currently not ok, while I was trying to fix it. And yes, there is frustration that I've spent $20 on an old sensor that can be bought for $3 now. A lot of people may have had the same feeling these past months. But in all that time nobody left a warning.

      Sometimes it feels like people are just solving their own problems, and when they've fixed it for themselves, they don't care enough about the people that come after them. That's not an attack on the core developers by the way, that's a statement about us all.

      Anyway, onwards.

      I've contacted environmental agencies about which cheap laser-based sensor they recommend, and I've researched them in detail. I believe it may be a good idea to create a new 'default' dust sensor sketch around the PMS7003.

      I've also updated the temperature sensor code (I've been testing it today). I'll make an account on OpenHardware and post new versions there. Hek tells me those can then be integrated into the website.

      posted in General Discussion
      alowhum
      alowhum
    • Next generation CO2 sensor

      Well, that name is getting pompous, but hey.

      Here's code for the MH-Z19 CO2 sensor. It's concidered to be the best value for money CO2 sensor currently.

      The code is non-blocking, so it can also act as a repeater.

      A pull request for the code has also been made on Github, so it can become part of the examples.

      /*
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       *  DESCRIPTION
       *
       *  MH-Z19 CO2 sensor
       *  
       *  This sensor uses a frickin' laser to measure lots of different fine dust levels, between 0.3 and 10 microns.
       *  
       *  It communicates with your board over serial at 9600 speed.
       *  
       *  
       *
       */
      
      
      //------------------------------------------------------------------------------
      
      // if you uncomment this, you can get test and debug updates about the sensor' wireless connection by using the serial monitor tool.
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24                            // A 2.4Ghz transmitter and receiver, often used with MySensors.
      // #define MY_RF24_PA_LEVEL RF24_PA_MIN           // This sets a low-power mode for the radio. Useful if you use the verison with the bigger antenna, but don't want to power that from a separate power source. It can also fix problems with fake Chinese versions of the radio.
      // #define MY_RADIO_RFM69                         // 433Mhz transmitter and reveiver.
      
      // Choose if you want this sensor to also be a repeater.
      // #define MY_REPEATER_FEATURE                    // Just remove the two slashes at the beginning of this line to also enable this sensor to act as a repeater for other sensors. If this node is on battery power, you probably shouldn't enable this.
      
      
      // Libraries
      #include <MySensors.h>
      #include <SoftwareSerial.h>
      
      
      // This can be changed:
      unsigned long co2MeasurementInterval = 30000;     // Time to wait between reads (in milliseconds).
      SoftwareSerial mySerial(10, 11);                  // RX, TX . You can choose other pins if you prefer.
      
      
      // Mysensors settings
      #define CHILD_ID_CO2 0                            // The Co2 sensor' ID on this node.
      MyMessage msgCo2(CHILD_ID_CO2, V_LEVEL);
      MyMessage msgCo2b(CHILD_ID_CO2, V_UNIT_PREFIX);
      
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("AIQ Sensor CO2 MH-Z19", "1.1");
      
        // Register attached sensor(s) to gateway
        present(CHILD_ID_CO2, S_AIR_QUALITY);
        send(msgCo2b.set("ppm"));
      }
      
      
      void setup() 
      {
        delay(1000);
        Serial.begin(115200);
        delay(1000);
      
        mySerial.begin(9600);
        delay(2000);
        while (mySerial.read()!=-1) {};  //clear Co2 buffer.
        Serial.println("hello world, I am a sensor.");
      }
      
      
      void loop() 
      {
      
         // You should not change these variables:
         static unsigned long previousCo2Millis = 0;       // Used to remember the time of the last temperature measurement.
      
         unsigned long currentMillis = millis(); // The time since the sensor started, counted in milliseconds. This script tries to avoid using the Sleep function, so that it could at the same time be a MySensors repeater.
      
        if (currentMillis - previousCo2Millis >= co2MeasurementInterval) { // this only gets triggered when enough time has passed.
          Serial.println("CO2 - Sending data request to sensor.");
          previousCo2Millis = currentMillis;
          
          long co2ppm = readCO2();    
          Serial.println("Co2 - PPM = " + String(co2ppm));
          send(msgCo2.set((long)ceil(co2ppm))); 
          Serial.print("Co2 - zzzzZZZZzzzzZZZZzzzz\n");
        }
      
      }
      
      
      // Main function that gets the Co2 data
      int readCO2()
      {
        while (mySerial.read()!=-1) {};  //clear serial buffer  
      
        char response[9]; // for answer
        byte cmd[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};
        
        // command to ask for data
        mySerial.write(cmd, 9); //request PPM CO2 
      
        mySerial.readBytes(response, 9);
      
          Serial.print(response[0], HEX);   
          Serial.print(" - ");   
          Serial.print(response[1], HEX);   
          Serial.print(" - ");    
          Serial.print(response[2], HEX);   
          Serial.print(" - ");          
          Serial.print(response[3], HEX);   
          Serial.print(" - ");          
          Serial.print(response[4], HEX);   
          Serial.print(" - ");          
          Serial.print(response[5], HEX);   
          Serial.print(" - ");        
          Serial.print(response[6], HEX);   
          Serial.print(" - ");   
          Serial.print(response[7], HEX);   
          Serial.print(" - ");      
          Serial.print(response[8], HEX); 
          Serial.println(" - END");  
      
        if (response[0] != 0xFF)
        {
          Serial.println("Wrong starting byte from co2 sensor! (should be FF)");
          return -1;
        }
      
        if (response[1] != 0x86)
        {
          Serial.println("Wrong command from co2 sensor! (should be 86)");
          return -1;
        }
      
        int responseHigh = (int) response[2];
        int responseLow = (int) response[3];
        int ppm = (256 * responseHigh) + responseLow;
        
        return ppm;
      }
      
      
      posted in General Discussion
      alowhum
      alowhum
    • RE: What did you build today (Pictures) ?

      I didn't build this myself, but I did create the code. It's a MySensors CO2 sensor that is part of a 'privacy friendly smart home of the future' which will be launched later this year.

      0_1566575881300_Candle-CO2-sensor-by-Dinie-Besems.jpg

      It was made by artist and jeweler Dinie Besems. All her creations feature small 'skirts' that you can lift to see the data, or cover up the screen if you have visitors and don't want them to immediately see your data.

      posted in General Discussion
      alowhum
      alowhum
    • RE: API first controller with OTA support, also exposes WebOfThings APIs for sensors

      Good news: sounds like we can add a new controller to the list soon!

      Through the help and hard work of @Sathishkumar-Thangavel I got my first MySensors device to show up in the Mozilla Gateway yesterday.

      This is great news, as the software is really user friendly and has the force of Mozilla behind it.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • Candle Manager - user-friendly web-based tool to program Arduino's

      For a project I'm working on I've created a small tool that could be useful to everyone in the community. I'm sharing an early version for Christmas 🙂

      The tool is meant to be used with the Raspberry Pi. Through this web interface you can generate and upload code to a plugged in Arduino with the click of a few buttons.

      0_1545992240907_dashboard.png

      0_1545992251013_create_new.png

      It takes code templates (which are just normal Arduino files), and transforms them into an easy to use interface so that users can change some settings.

      0_1545991833537_code_ux_generation.png

      From the user's preferences new code is generated. This can then be uploaded with the upload wizard:

      0_1545992281342_upload_wizard2.png

      0_1545992295714_upload_wizard3.png

      The user never has to see any code if they don't want to. But if they do it has a built in code editor too.

      HOW DOES IT WORK?
      It builds on the new Arduino Command Line Interface (CLI).
      HTML5 <-> PHP <-> Arduino CLI

      What's is good for?

      • Giving workshops. People no longer have to install the Arduino IDE on their laptops, but can instead connect to Raspberry Pi wifi hotspot.
      • I'm developing it to be part of a privacy friendly smart home demonstrator that I've been working on for a while. I'm building it on top of MySensors, MySController-rs, Mozilla Gateway and the Arduino CLI.

      MORE DETAILS
      The code and more screenshots and details can be found here:
      https://github.com/createcandle/Candle-manager

      posted in My Project
      alowhum
      alowhum
    • RE: Lots of Repeater nodes? (new info December 2017 requested)

      So, what's the answer? For those finding the thread:

      • If you are not using battery sensors, then it's fine to make all of them repeaters.
      • After 20 failures to send, nodes will try looking for other pathways. In that case having multiple repeaters is useful if a node fails.

      It might be that it takes some more space/memory on your arduino?

      posted in Development
      alowhum
      alowhum
    • RE: The examples on the website need love

      Well this blew up 😄 Sorry if I offended!

      @Awi No worries, you haven't offended me. And I was a bit harsh, sorry about that.

      @slalz I understand an open source project will not be perfect and will need you to dive into it at some level. The question is: what level.

      "We provide easy to follow build instructions, ready to use code examples".

      I also understand we all have day jobs. My whole point was that I wanted to try and help. In fact, that's what I have been doing; writing code, researching better temperature and dust sensors. If you give me a (temporary) account on the website I will gladly update the build instructions. I was already adding examples to Github through the web interface as we speak 🙂

      posted in General Discussion
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      You can now just clone the Github repository and it should automatically become available in your add-ons list.

      What's more, I've created a request to add the adapter to the official list. If it is accepted, then in the future you will be able to just select the add-on from the list in the interface. No need to open a terminal window anymore.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Candle - the privacy friendly smart home

      And here are some initial photos of Jesse's creations:
      0_1570569514800_jesse_candle_devices_family_photo.jpg

      0_1570569534700_jesse_smart_lock.jpg
      Smart lock

      posted in My Project
      alowhum
      alowhum
    • RE: MySensors Smart Watch

      My ID107 has arrived. To open the ID107 you will need a tiny star-shaped 6-corner screwdriver. I've successfully opened it and closed it again, no problems there.

      My first goal will be to create an image of the old firmware. But unfortunately I don't have any spare time to work on it right now.

      posted in General Discussion
      alowhum
      alowhum
    • Voco - Voice control for your MySensors network

      Over the past few weeks I've been working on Voco, an add-on for the WebThings Gateway that enables privacy friendly voice control. It's built on Snips, so it requires no internet connection.

      https://github.com/createcandle/voco

      Since I mostly use the WebThings Gateway to manage a collection of experimental privacy friendly smart home devices that are based on MySensors, it has been fine-tuned to work well with any MySensors network.

      Furthermore, the MySensors add-on has a new features that will separate devices with a lot of toggles into multiple separate things. This allows you to name them separately, and thus target them perfectly using just your voice.

      It also has a lot of time-based functionality. E.g. you can say "Turn on the heater until 5pm", or "Turn on the relay between 3 and 5 o'clock".

      You can also ask the classics, like ask for the time, and set timers, reminders and alarms.

      For a full list of all its capabilities check out the Github page.

      COLOFON

      Voco is a vital part of Candle, the privacy friendly smart home.

      Work on Voco was supported by the Creative Industries Fund NL and the Sherpa project. Sherpa, and by extension this project, has received funding from the European Union’s Horizon 2020 research and innovation programme, under grant agreement No 786641.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • CDEBYTE's new NRF24 modules are great! (and cheap)

      I bought and tested one of these new small modules:

      https://www.aliexpress.com/item/E01-ML01D-small-size-SPI-nRF24L01P-2-4Ghz-1mW-PCB-antenna-IOT-uhf-wireless-transceiver-transmitter/32803704874.html

      • Smaller
      • Thinner
      • Works at full power
      • Claim to use real imported NRF chips
      • $1,25

      I've also ordered a shielded version that I'm still waiting for.

      Perhaps the website can reflect some of the newer options?

      • These small parts (but perhaps the shielded alternative will be even better)
      • Shielded NRF24 PA high power version. Very nice too. No need to wrap aluminium foil around them 🙂
      posted in General Discussion
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      Version 1.0.0 has been submitted to Mozilla.

      • Support for time-outs. After a user-defined period of not receiving any sign of life (data/heartbeat), a node will be set to disconnected.
      • Support for the new WebThings thermostat capability.
      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: MySensors Smart Watch

      The ID107HR can also be updated over the air apparently.

      https://github.com/najnesnaj/ota-dfu-smartband

      posted in General Discussion
      alowhum
      alowhum
    • HMI Intelligent TFT screen - control via serial, $4

      I bought these 'HMI intelligent' displays which can be controlled via software serial. The reason is I wanted to use the I2C pins for analog sensors.

      alt text

      They're really interesting.

      • $4 for the 1.77" 1.8" 128*160 version.
      • $7 for the 2.4" 320*240 version.
      • Full color
      • 4 wires
      • Software serial, so you can connect it to any pins you have left.
      • Has built in memory that you can upload images to. Built in fonts too.
      • Built in shape drawing function. Very cool for dataviz.
      • Nice mounting holes.
      • Screen can be rotated, brightness can be adjusted, etc.
      • Does not need external power supply.

      Downsides:

      • Viewing angles are mediocre: you can still read it from an angle, but colors do shift.
      • When you create shapes and text using the commands, you can only use the 15 built in colors.
      • The smallest font size is still relatively big if you're used to the pixel fonts on the tiny OLED screens.

      Because all the functionality is already built into the screen, you don't need any libraries to drive it. Just serial commands. That saves a lot of memory.

      In theory there are touch screen versions too.

      The 2.4" version is impressive. It's twice the size, practically twice the resolution, and the screen fills the entire PCB.

      alt text

      GETTING STARTED

      This page has lots of details:
      http://www.spotpear.com/index.php/uart-lcd/uart-lcd-22

      It also has a link to a word document that has a walkthrough.

      Here's some example code:

      #include <SoftwareSerial.h>
      
      SoftwareSerial mySerial(6,7); // RX, TX
      
      void setup() {
        mySerial.begin(115200);
        delay(1000);
        mySerial.print("CLR(1);"); // set the background color to red
        mySerial.print("VER;"); // built in function to display the firmware version of the screen.
        mySerial.println("DCV16(3,32 ,hello world, 2);"); // displays 'hello world' in green (color 2) letters, 32 pixels from the top of the screen, and 3 pixels from the left. The new line tells the screen to execute all the commands it has received. This takes one or two milliseconds.
        delay(100);
      }
      
      posted in Hardware
      alowhum
      alowhum
    • RE: head's up: LGT8F328P is allegedly a chinese clone of the atmega328p

      Doesn't look interesting!

      posted in Hardware
      alowhum
      alowhum
    • RE: New non-blocking temperature sensor code

      Wow, great stuff! Thanks everyone! I'll try and make a new version with your suggestions.

      posted in Development
      alowhum
      alowhum
    • RE: Candle - signal Hub - A universal 433Mhz signal detector and cloner

      Here is the new version which should work just fine without a touchscreen attached.

      https://github.com/createcandle/Devices/blob/master/Signal-hub/Signal-hub.ino

      I also added a new playlist feature. If multiple replay requests are received in quick succession (perhaps from a home automation rule that wants to trigger multiple sockets), it can remember these requests and replay them one after the other.

      posted in My Project
      alowhum
      alowhum
    • RE: Next generation temperature sensor for MySensors

      Hey Andrea, just to be sure: the sensors listed here are electronic components that can be used to create a DIY sensor network. This will involve some programming and perhaps soldering. It's quite a different proposition to commercial offerings.

      The MySensors network supports two types of transmitters. You can research how much output they provide.
      I don't know how to answer your question about 'reduced tip', or what you this temperature range you refer to is even about. You probably won't get many suggestions without being more precise.

      I would recommend starting a new thread on this forum where you explain your situation in some more detail.

      posted in General Discussion
      alowhum
      alowhum
    • RE: MH-Z19 CO2 sensor

      If you mean the MG811 on that list: it's pretty bad.

      • Long warmup times (24 hours..)
      • Needs 6v
      • Doesn't really measure CO2, but responds to all kinds of other gasses too.
      • Loses callibration. It's mostly a chemical proces.

      The cool thing about the MH-Z14 and the even better MH-Z19 is that they use light spectrum analysis. They send infrared light, and measure how much of that light is absorbed in the spectrum that CO2 absorbs in.

      While not very accurate, they are very precise.
      precise vs accurate

      So they are not very good in giving absolute values, but they are very good in measuring relative changes.

      These sensors have a function where you can set the baseline by sending them a specific command. For example, you could take the sensor outside, and then set the outside value as the zero mark. Or you could just use the value they put in at the factory.

      posted in Hardware
      alowhum
      alowhum
    • Safe heating with MySensors - how I use it as a smart thermostat

      After reading the thread about the lovely PiHome thermostat I thought I'd share how I am heating my home.

      I'm currently using Domoticz with the Smart Virtual Thermostat plugin. This is a pure software PID controller designed to heat homes with on-off devices like electric heaters.

      My safe heater switch node

      Using MySensors I created a special 'secure heating switch' with a temperature sensor, gas sensor, and a relay. It has all kinds of internal safety checks:

      • is the room not too hot?
      • has the heater not been on too long?
      • is the temperature sensor still giving sane data?
      • is the controller still connected?
      • is there a gas leak?

      It also has an analog 'backup': if the room temperature gets above 25 degrees celcius a simple bi-metal cuts power to the heater.

      Other features

      • You can set the minimum time that the switch must stay in a certain position. This protects mechanical valves in some heaters from wear and other problems.
      • Non-blocking. So it can act as a repeater too.
      • LED indicates if there is a problem.

      HARDWARE

      The node is designed to be as plug and play as possible, and doesn't really require any soldering. I just connect a Dallas sensor and a relay switch to the 'base node':

      alt text

      CODE

      
      /**
       * 
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * DESCRIPTION
       * 
       * SAFE HEATER SWITCH WITH TEMPERATURE SENSOR
       *
       * A 'safe' switch for heaters that can be controlled via an external controller. The heater is switched off..
       * - At boot
       * - When connection to the controller has been lost (it creates a text-child which it then keeps requesting back)
       * - When the built-in temperature sensor detects that the room is too warm.
       * - When the temperature sensor seems broken
       * - When the heater has been on for too long (this starts a cooldown period).
       * 
       * Other features
       * - You can set the minimum time that the switch must stay in a certain position. This protects mechanical valves in some heaters from wear and other problems.
       * - Non-blocking. So it can act as a relay too.
       * - LED indicates if there is a problem.
       * 
       *
       * IMPORTANT: 
       * - I use this in combination with an analog bi-metal safety shutoff (which turns of power to the heater if temperature gets too high).
       * - My heater is a gas-model that will automatically turn off when electricity fails. MAke sure your heater fails gracefully when power is turned off!
       * 
       * Possible improvements:
       * - Add more temperature sensors to better check if the current temprature is accurate.
       * - Add a display.
       * - This could be expanded into being a thermostat/PID itself.
       */
      
      
      // if you uncomment this, you can get test and debug updates about everything the sensor is doing by using the serial monitor tool.
      #define MY_DEBUG
      
      // advanced options
      //#define MY_NODE_ID 13                             
      //#define MY_PARENT_NODE_ID 0
      //#define MY_PARENT_NODE_IS_STATIC
      #define MY_TRANSPORT_WAIT_READY_MS 10000            // try connecting for 10 seconds. Otherwise just continue.
      #define MY_SPLASH_SCREEN_DISABLED                   // saves a little memory.
      //#define MY_DISABLE_RAM_ROUTING_TABLE_FEATURE      // saves a little memory.
      //#define MY_RF24_CHANNEL 100                       // in EU the default channel 76 overlaps with wifi, so you may want to make it higher. But this wil then need to be done everywhere, including on your gateway.
      //#define MY_RF24_DATARATE RF24_1MBPS               // a slower datarate could make the network more stable?
      
      // Easy to use security, yay!
      //#define MY_SIGNING_SIMPLE_PASSWD   "putyourpasswordhere"
      //#define MY_SIGNING_SOFT_RANDOMSEED_PIN A7         // setting a pin to pickup noise makes encryption more secure.
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      // Set LOW transmit power level as default, if you have an amplified NRF-module and
      // power your radio separately with a good regulator you can turn up PA level. Choose one:
      //#define MY_RF24_PA_LEVEL RF24_PA_MIN
      #define MY_RF24_PA_LEVEL RF24_PA_LOW
      //#define MY_RF24_PA_LEVEL RF24_PA_HIGH
      //#define MY_RF24_PA_LEVEL RF24_PA_MAX
      
      // Enable repeater functionality for this node. It is designed to be "non-blocking".
      #define MY_REPEATER_FEATURE
      
      // LIBRARIES (in the Arduino IDE go to Sketch -> Include Library -> Manage Libraries to add these if you don't have them installed yet.)
      #include <MySensors.h>
      #include <DallasTemperature.h>
      #include <OneWire.h>
      
      
      // VARIABLES YOU CAN CHANGE
      #define SAFEGUARD_TEMP 24                         // Maximum temperature (currently in celcius) that the sensor may detect before the relay is shutdown.
      #define RETURNTONORMAL_TEMP 22                    // After a safeguard shutdown, at what cooled down temperature (currently in celcius) should the system go back to normal state?
      #define COMPARE_TEMP 0                            // Send temperature only if changed? 1 = Yes 0 = No.
      #define ONE_WIRE_BUS 3                            // Digital pin where Dallas sensor(s) is/are connected.
      #define MAXATTACHEDDS18B20 1                      // Maximum amount of teperature sensors you can connect to this arduino (can be 16).
      #define REDLED 8                                  // Red LED, useful as alarm colour.
      #define MEASUREMENTINTERVAL 60000                 // Time to wait between reads (in milliseconds). (60 seconds)
      #define CONNECTIONCHECKINTERVAL 60000             // Time to wait between checking the connection to the gateway (in milliseconds). (60 seconds)
      #define MANIMUMCONNECTIONLOSSDURATION 181000      // Maximum time that the server can be disconnected (in milliseconds). (181 seconds)
      #define TEMPTHRESHOLD 0.1                         // How big a temperature difference has to be before an update is sent. Makes the sensor less precise, but also less jittery, and can save battery.
      #define MAXIMUMHEATERONDURATION 3600000           // If the heater has been on non-stop for an hour..
      #define HEATERCOORLDOWNDURATION 1200000           // ..cool down for 20 minutes
      #define MIMIMUMDELAYBETWEENSWITCHING 10000        // At most switch the heater state once every X seconds. This protects wear on fireplaces with mechanical switches. (10000 = 10 seconds)
      #define GASDETECTORPIN A0                         // analog pin of gas detector
      #define GASTHRESHOLD 100                          // threshold for LPG detection to cause auto-shutdown, in case of gas leak.
      
      //VARIABLES YOU PROBABLY SHOULDN'T CHANGE
      #define TEMP_CHILD_ID 0                           // for MySensors. Within this node each sensortype should have its own ID number.
      #define RELAY_CHILD_ID 1                          // for MySensors. Within this node each attached thing should have its own ID number.
      #define TEXT_CHILD_ID 2                           // for MySensors. Within this node each sensortype should have its own ID number.
      #define GAS_CHILD_ID 3                           // for MySensors. Within this node each sensortype should have its own ID number.
      
      OneWire oneWire(ONE_WIRE_BUS);                    // Setup a oneWire instance to communicate with any OneWire devices (like Maxim/Dallas temperature ICs)
      DallasTemperature sensors(&oneWire);              // Pass the oneWire reference to Dallas Temperature.
      float lastTemperature[MAXATTACHEDDS18B20];        // creates an array to hold the previous temperature measurements for each possible sensor.
      int numSensors = 0;                               // variable to contain the number of found attached sensors.
      unsigned long measurementSleepTime = 0;           // variable to store the calculated Sleep time if the node is battery powered.
      
      // GAS DETECTOR VARIABLES
      int gasValue = 200;                               // start with a high value, to be safe.
      //#define BUZZERPIN 6                             // digital pin of alarm buzzer
      
      //RELAY VARIABLES
      #define RELAY_1 4  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // Total number of attached relays
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      float lastMainTemperature = 18; // The temperature when the relay starts. 
      
      
      // Security variables
      int errorCount = 0;                                 // May indicate system stability later.
      unsigned long lastTimeConnected = 0;         // When was the last time the system communicated with the control server?
      unsigned long lastTimeRelaySwitched = 0;     // When was the last time that the relay switched? Used to avoid having the heater on for too long _or_ too short.
      unsigned long heaterOnTooLongTime = 0;       // The moment when the heater had been on for too long. Used to force a cooldown period afterwards.
      boolean safetyShutdown = true;                     // Set to true if something is wrong with the system. This then turns off the relay.
      boolean requestedHeaterStatus = RELAY_OFF;          // At boot, assume the server wants the heater turned off, just to be safe.
      boolean actualHeaterStatus = RELAY_OFF;             // At boot, assume the heater is on, just to be safe.
      boolean gasDetected = false;                        // Does the gas detector smell something?
      boolean heaterOnTooLong = false;                    // If the heater has been on for 60 minutes, it will be shut down for a while.
      boolean roomTooHot = false;                         // If the room is hotter than 24 degrees, disable the heater. (could be runaway heater.. or summertime)
      boolean temperatureSensorError = false;             // Are we getting useful measurements from the temperature sensor?
      boolean serverDisconnected = true;                  // Is the Domoticz server connected? (implying that the gayeway is also working)
      //long timeStamp = 0;                               // current unix time, as received from server. Domoticz doesn't seem to support this currently.
      
      
      // Mysensors settings
      MyMessage tempmsg(TEMP_CHILD_ID,V_TEMP);            // Sets up the message format that we'll be sending to the MySensors gateway later. The first part is the ID of the specific sensor module on this node. The second part tells the gateway what kind of data to expect.
      MyMessage txtmsg(TEXT_CHILD_ID,V_TEXT);             // Sets up the message format that we'll be sending to the MySensors gateway later. The first part is the ID of the specific sensor module on this node. The second part tells the gateway what kind of data to expect.
      MyMessage gasmsg(GAS_CHILD_ID, V_LEVEL);            // Sets up the message format that we'll be sending to the MySensors gateway later. The first part is the ID of the specific sensor module on this node. The second part tells the gateway what kind of data to expect.
      
      void before()
      {
        pinMode(RELAY_1, OUTPUT);
        digitalWrite(RELAY_1, RELAY_OFF);                 // Shut down relay, just to be safe.
        sensors.begin();                                  // Startup up the OneWire library. It allows multiple sensors to talk over one wire (one pin).
      }
      
      
      void setup()
      {
        digitalWrite(RELAY_1, RELAY_OFF);                 // start with the relay off
        pinMode(REDLED, OUTPUT);                          // set LED pin as output pin.
        for(int i=0; i<MAXATTACHEDDS18B20; i++) 
        {
          lastTemperature[i] = 0;  //Pre-filling array with 0's.
        }
        sensors.setWaitForConversion(false); // requestTemperatures() will not block current thread
      
        Serial.begin(115200); // for serial debugging.
        delay(1000);  
        Serial.println(F("Hello world, I am a heater node."));
        request(RELAY_CHILD_ID,V_STATUS);
      }
      
      
      void presentation()
      {
        sendSketchInfo("Secure fireplace relay", "1.1");    // Send the sketch version information to the gateway and Controller
        present(TEMP_CHILD_ID, S_TEMP,"Secure heater temperature");    // Present all sensors modules to the gateway (16 maximum).
        present(RELAY_CHILD_ID, S_BINARY,"Secure heater switch");
        present(TEXT_CHILD_ID, S_INFO,"Secure heater status");
        present(GAS_CHILD_ID, S_AIR_QUALITY, "MQ2 gas sensor");
        send(txtmsg.setSensor(TEXT_CHILD_ID).set( F("Heater switch says hello") ));
      }
      
      
      void loop()
      {
      
        // You should not change these variables:
        static boolean dallasIsMeasuring = true;                  // Used to indicate when the time is right for a new measurement to be made.
        static boolean dallasIsCalculating = false;               // Used to bridge the time that is needed to calculate the temperature values by the Dallas library.
        unsigned long currentMillis = 0;                          // The millisecond clock in the main loop.
        static unsigned long lastSecurityCheck = 0;               // Used to remember the time of the last temperature measurement.
        static unsigned long previousMeasurementMillis = 0;       // Used to remember the time of the last temperature measurement.
        static unsigned long lastPlausibleTemperatureTime = 0;    // Used to remember the time of the last succesful temperature measurement.
        static unsigned long previousMinute = 0;                  // Used to loop once a minute.
        static int16_t conversionTime = 0;                        // Used to store the time needed to calculate the temperature from measurements.
        
        currentMillis = millis(); // The time since the sensor started, counted in milliseconds. This script tries to avoid using the Sleep function, so that it could at the same time be a MySensors repeater.
      
        // Every 10 seconds do a security check.
        if(currentMillis - lastSecurityCheck >= 10000) {
          lastSecurityCheck = currentMillis;
      
          // starts the very short led blink
          digitalWrite(REDLED,HIGH); // alarm led.
      
          // A.
          // CHECKING - Is everything ok?
      
      
          // Is there a gas leak?
          gasValue = analogRead(GASDETECTORPIN);
          Serial.print(F("gas:"));Serial.println(gasValue);
          
          if (gasValue > GASTHRESHOLD) {
            gasDetected = true;
            send(txtmsg.setSensor(TEXT_CHILD_ID).set( F("GAS LEAK!?!") ));
            //tone(BUZZERPIN, 1000, 200);
          }else{
            gasDetected = false;  
          }
      
      
          // Heater on too long?
          if( actualHeaterStatus == RELAY_ON){
            if(currentMillis - lastTimeRelaySwitched >= MAXIMUMHEATERONDURATION){
              heaterOnTooLongTime = currentMillis;
              heaterOnTooLong = true;      
              Serial.println(F("HEATER ON TOO LONG"));
            }
          }
      
          // Is the controller up?
          if(currentMillis - lastTimeConnected >= MANIMUMCONNECTIONLOSSDURATION){
            serverDisconnected = true;
            Serial.println(F("LOST CONNECTION TO CONTROLLER"));
          }else{
            serverDisconnected = false;
          }
      
          // Not too hot in the room?
          if(lastMainTemperature > SAFEGUARD_TEMP){
            roomTooHot = true;
            Serial.println(F("ROOM TOO HOT")); 
          }
          
          // How long has it been since the temperature sensor gave a good measurement?
          if(currentMillis - lastPlausibleTemperatureTime >= MANIMUMCONNECTIONLOSSDURATION){  // Uses same duration as connection loss.
            temperatureSensorError = true;
            Serial.println(F("SHUTDOWN: TEMPERATURE SENSOR ERROR"));
          } else{
            temperatureSensorError = false;
          }
      
          
      
          // B.
          // HEALING - Some functions might return, and then the system could return to normal.
      
          // Heater was too hot, but has had time to cool down.
          if(currentMillis - heaterOnTooLongTime >= HEATERCOORLDOWNDURATION && heaterOnTooLong == true){
            heaterOnTooLong = false;
          }
      
          // Room has cooled down.
          if(roomTooHot == true && lastMainTemperature > RETURNTONORMAL_TEMP){ // For safety, the "return to normal" temperature is lower than the maximum room temperature. This avoids flip-flopping.
            Serial.println(F("THE ROOM HAS NOT COOLED DOWN TO SAFE LEVELS"));
          }else if(roomTooHot == true && lastMainTemperature <= RETURNTONORMAL_TEMP){
            roomTooHot = false;
          }
      
          /*
          // useful debug data:
          Serial.print(F("GasDetected:  "));
          Serial.println(gasDetected);
          Serial.print(F("SensorError:  "));
          Serial.println(temperatureSensorError);
          Serial.print(F("onTooLong:    "));
          Serial.println(heaterOnTooLong);
          Serial.print(F("disconnected: "));
          Serial.println(serverDisconnected);
          Serial.print(F("roomTooHot:   "));
          Serial.println(roomTooHot);
          */
      
          // C.
          // DECIDE IF OPERATION IS SAFE
          if(temperatureSensorError == true || heaterOnTooLong == true || serverDisconnected == true || roomTooHot == true || gasDetected == true){
            Serial.println(F("! ERROR DETECTED"));
            // Decision: something is wrong, so SHUTDOWN the relay.
            if(safetyShutdown == false){
              errorCount++;
              send(txtmsg.setSensor(TEXT_CHILD_ID).set( F("SAFETY SHUTDOWN!") ));
              }
            safetyShutdown = true;
            digitalWrite(RELAY_1, RELAY_OFF); // Turn off heater.
            digitalWrite(REDLED,HIGH); // alarm led.
            Serial.println(F("CURRENTLY IN SAFETY SHUTDOWN MODE"));
          }else{
      
            // Decision: everything looks OK.
            Serial.println(F("NO ERROR DETECTED"));
            if(safetyShutdown == true){
              send(txtmsg.setSensor(TEXT_CHILD_ID).set( F("Heater is OK again!") ));
              digitalWrite(REDLED,LOW); // turn of alarm led.
            }
            safetyShutdown = false;
            Serial.println(F("NORMAL OPERATION"));
            Serial.print(F("act status")); Serial.println(actualHeaterStatus);
            Serial.print(F("req status")); Serial.println(requestedHeaterStatus);
            
            if(requestedHeaterStatus != actualHeaterStatus){
              //One more check to protect the relay from switching too often.
              if(currentMillis - lastTimeRelaySwitched > MIMIMUMDELAYBETWEENSWITCHING){
                
                Serial.print(F("Current switch position: "));
                Serial.println(actualHeaterStatus);
                Serial.print(F("Requested switch position: "));
                Serial.println(requestedHeaterStatus);
                Serial.println(F("NOW SWITCHING THE RELAY"));
                digitalWrite(RELAY_1, requestedHeaterStatus); 
                actualHeaterStatus = requestedHeaterStatus;
                lastTimeRelaySwitched = currentMillis;
                send(txtmsg.setSensor(TEXT_CHILD_ID).set( F("Switching relay") ));
              }else{
                Serial.println(F("Delaying switching the relay"));
                send(txtmsg.setSensor(TEXT_CHILD_ID).set( F("Delaying switching relay") ));
              }
            }
          }
      
      
          // if everything is on, turn off the LED again (making it blink very shortly during the check)
          if(safetyShutdown == false){
            digitalWrite(REDLED,LOW); // alarm led.
          }
        
        }
      
        // Every minute..
        if(currentMillis - previousMinute >= CONNECTIONCHECKINTERVAL) {
          previousMinute = currentMillis;
      
          // check if the network connection is ok by asking the relay state from the controller.
          Serial.println(F("Checking if controller is up and running"));
          request(RELAY_CHILD_ID,V_STATUS);
          //void requestTime(); // Unfortunately Domoticz doesn't seem to support this yet. 
        
          // send the gas value while you're at it.
          send(gasmsg.set(gasValue));
        }
        
      
       // Let's measure the temperature
       if(dallasIsMeasuring == true && currentMillis - previousMeasurementMillis >= MEASUREMENTINTERVAL) { // If we're not calculating, and enough time has passed, we'll start again.
          previousMeasurementMillis = currentMillis; // Mark the time of the initialiation of this measurement.
          dallasIsMeasuring = false; // We're measuring, so let's take it off our to-do list.      
          Serial.println(F("Starting new measurement(s)"));
      
          // Fetch temperatures from Dallas sensors
          sensors.requestTemperatures();
      
          // query conversion time. Apparently it takes a while to calculate.
          //ConversionTime = sensors.millisToWaitForConversion(sensors.getResolution());
          conversionTime = millisToWaitForConversion(sensors.getResolution()); // This is a modified version of the line above, to deal with the problem in the current Dallas library.
          dallasIsCalculating = true; //Next step is to re-calculate the temperature again.
       }
      
      
       // Next, let's calculate the temperature and send the temperature to the gateway if it has changed.
       if(dallasIsCalculating == true && currentMillis - conversionTime > previousMeasurementMillis) {
          dallasIsCalculating = false; // We're doing this now, so check calculating off the to-do list too.
          for (int i=0; i<1 && i<MAXATTACHEDDS18B20; i++){  // Loop through all the attached temperature sensors.   
            float temperature = getControllerConfig().isMetric?sensors.getTempCByIndex(i):sensors.getTempFByIndex(i); // Fetch the temperature form the current sensor
             Serial.print(F("Sensor #"));
             Serial.print(i);
             Serial.print(F(" says it is "));
             Serial.print(temperature);
             Serial.println(F(" degrees"));
      
            if(temperature != -127.00 && temperature != 85.00) { // Avoids working with measurement errors.
              lastPlausibleTemperatureTime = currentMillis;
              lastMainTemperature = temperature;
              
              if (COMPARE_TEMP == 1 && abs(temperature - lastTemperature[i]) < TEMPTHRESHOLD) { // is the temperature difference bigger than the threshold?
                 Serial.print(temperature - lastTemperature[i]);
                 Serial.println(F("Temperature difference too small"));
              } else {
                 Serial.print(temperature - lastTemperature[i]);
                 Serial.println(F("Sending the new temperature to the gateway."));
                 send(tempmsg.setSensor(i).set(temperature,1));
                 lastTemperature[i] = temperature; // Save new temperatures to be able to compare in the next round.
              }
            }
          }
      
          // Both tasks are done. Time to wait until we should measure again.
          Serial.println(F("zzzzZZZZzzzzZZZZzzzz"));
      
          dallasIsMeasuring = true;
        }
        
      }
      
      
      // This function helps to avoid a problem with the latest Dallas temperature library.
      int16_t millisToWaitForConversion(uint8_t bitResolution)
      {
         switch (bitResolution) 
         {
           case 9:
              return 94;
           case 10:
              return 188;
           case 11:
              return 375;
           default:
              return 750;
         }
      }
      
      
      
      void receive(const MyMessage &message)
      {
        Serial.println(F("+++receiving message+++"));
        lastTimeConnected = millis(); // Seems like we are connected to the server, so let's update this variable. Wait, does this work like this?
      
        if (message.type == V_TEXT) {
          Serial.print(F("Received text data: "));
          Serial.println(message.data);
          serverDisconnected = false;
          // Not doing anything with this yet.
        }
      
        
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_STATUS) {
          // Change relay state
      
          requestedHeaterStatus = message.getBool()?RELAY_ON:RELAY_OFF;
          
          // Write some debug info
          Serial.print(F("Incoming change for sensor:"));
          Serial.println(message.sensor);
          Serial.print(F(", New value from controller: "));
          Serial.println(message.getBool());
          Serial.print(F(", New requested Heater Status: "));
          Serial.println(requestedHeaterStatus);
          
        }
      }
      
      
      
      /*
      // currently unused: Domoticz doesn't support it yet.
      void receiveTime(unsigned long timeStamp){
        Serial.print("Time value received: ");
        Serial.println(timeStamp);
        lastTimeConnected = millis();
        //connectionErrorCount = 0;
        };
      */
      
      
      

      QUESTION
      If anyone has a suggestion for an even simpler temperature sensor (with an even smaller library) I'd love to hear it.

      I haven't integrated a boiler, although there are Domoticz plugins for that too.

      posted in Development
      alowhum
      alowhum
    • RE: Why I quit using MySensors for actuators

      @nca78 Thanks for the explananation! Do you perhaps know of an example sketch that has good example code for this? I haven't come accross it.

      posted in General Discussion
      alowhum
      alowhum
    • RE: MH-Z19 CO2 sensor

      The code:

      /*
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       *  DESCRIPTION
       *
       *  MH-Z19 CO2 sensor
       *  
       *  It communicates with your board over serial at 9600 speed.
       *  
       *  
       *
       */
      
      
      //------------------------------------------------------------------------------
      
      // if you uncomment this, you can get test and debug updates about the sensor' wireless connection by using the serial monitor tool.
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24                            // A 2.4Ghz transmitter and receiver, often used with MySensors.
      // #define MY_RF24_PA_LEVEL RF24_PA_MIN           // This sets a low-power mode for the radio. Useful if you use the verison with the bigger antenna, but don't want to power that from a separate power source. It can also fix problems with fake Chinese versions of the radio.
      // #define MY_RADIO_RFM69                         // 433Mhz transmitter and reveiver.
      
      // Choose if you want this sensor to also be a repeater.
      // #define MY_REPEATER_FEATURE                    // Just remove the two slashes at the beginning of this line to also enable this sensor to act as a repeater for other sensors. If this node is on battery power, you probably shouldn't enable this.
      
      
      // Libraries
      #include <MySensors.h>
      #include <SoftwareSerial.h>
      
      
      // This can be changed:
      unsigned long co2MeasurementInterval = 30000;     // Time to wait between reads (in milliseconds).
      SoftwareSerial mySerial(10, 11);                  // RX, TX . You can choose other pins if you prefer.
      
      
      // Mysensors settings
      #define CHILD_ID_CO2 0                            // The Co2 sensor' ID on this node.
      MyMessage msgCo2(CHILD_ID_CO2, V_LEVEL);
      MyMessage msgCo2b(CHILD_ID_CO2, V_UNIT_PREFIX);
      
      
      void presentation()
      {
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("AIQ Sensor CO2 MH-Z19", "1.1");
      
        // Register attached sensor(s) to gateway
        present(CHILD_ID_CO2, S_AIR_QUALITY);
        send(msgCo2b.set("ppm"));
      }
      
      
      void setup() 
      {
        delay(1000);
        Serial.begin(115200);
        delay(1000);
      
        mySerial.begin(9600);
        delay(2000);
        while (mySerial.read()!=-1) {};  //clear Co2 buffer.
        Serial.println("hello world, I am a sensor.");
      }
      
      
      void loop() 
      {
      
         // You should not change these variables:
         static unsigned long previousCo2Millis = 0;       // Used to remember the time of the last temperature measurement.
      
         unsigned long currentMillis = millis(); // The time since the sensor started, counted in milliseconds. This script tries to avoid using the Sleep function, so that it could at the same time be a MySensors repeater.
      
        if (currentMillis - previousCo2Millis >= co2MeasurementInterval) { // this only gets triggered when enough time has passed.
          Serial.println("CO2 - Sending data request to sensor.");
          previousCo2Millis = currentMillis;
          
          long co2ppm = readCO2();    
          Serial.println("Co2 - PPM = " + String(co2ppm));
          send(msgCo2.set((long)ceil(co2ppm))); 
          Serial.print("Co2 - zzzzZZZZzzzzZZZZzzzz\n");
        }
      
      }
      
      
      // Main function that gets the Co2 data
      int readCO2()
      {
        while (mySerial.read()!=-1) {};  //clear serial buffer  
      
        char response[9]; // for answer
        byte cmd[9] = {0xFF, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};
        
        // command to ask for data
        mySerial.write(cmd, 9); //request PPM CO2 
      
        mySerial.readBytes(response, 9);
      
          Serial.print(response[0], HEX);   
          Serial.print(" - ");   
          Serial.print(response[1], HEX);   
          Serial.print(" - ");    
          Serial.print(response[2], HEX);   
          Serial.print(" - ");          
          Serial.print(response[3], HEX);   
          Serial.print(" - ");          
          Serial.print(response[4], HEX);   
          Serial.print(" - ");          
          Serial.print(response[5], HEX);   
          Serial.print(" - ");        
          Serial.print(response[6], HEX);   
          Serial.print(" - ");   
          Serial.print(response[7], HEX);   
          Serial.print(" - ");      
          Serial.print(response[8], HEX); 
          Serial.println(" - END");  
      
        if (response[0] != 0xFF)
        {
          Serial.println("Wrong starting byte from co2 sensor! (should be FF)");
          return -1;
        }
      
        if (response[1] != 0x86)
        {
          Serial.println("Wrong command from co2 sensor! (should be 86)");
          return -1;
        }
      
        int responseHigh = (int) response[2];
        int responseLow = (int) response[3];
        int ppm = (256 * responseHigh) + responseLow;
        
        return ppm;
      }
      
      
      posted in Hardware
      alowhum
      alowhum
    • RE: MY_GATEWAY_TINYGSM

      @alexsh1

      Here's a bit of code I use to send an SMS once in a while. Providers will disable your simcard if you don't do anything that makes them money once in a while. Perhaps you can use it to reset.

      #ifdef SEND_SMS_EVERY_49_DAYS
        // This is an optional feature.
        // Every 49,7 days (using the millis() rollover) the system sends out an SMS. This helps keep the simcard active and registered on the GSM network. 
        // Use at your own risk: if the system experiences a power loss, the timer starts at 0 again. If your experience frequent powerlosses, then the simcard might be-deregistered anyway, since the keep-alive SMS's won't get sent. 
        // A slight delay is built in: the first sms is sent a week after the smart lock becomes active. This avoid sending a lot of SMS's if you are still playing with setting up the device, and powerlosses may be frequent.
        // This smart lock also offers another option. You can let the controller trigger the sending of the sms using the 'send test sms' button. Of course, your controller could also be down when you scheduled to trigger the button.
        static bool keepAliveSMSsent = false;             // used to make sure an SMS is only sent as the milliseconds starts, and not during every loop in the millisecond.
        if(millis() < 5){
          keepAliveSMSsent  = false;                      // when the clock rolls over, set the variable back so that a new SMS can be sent.
        }
        if (millis() > 604800000 && millis() < 604800010 && keepAliveSMSsent == false){ // 604800000 = 1 week in milliseconds. Sending the first keep-alive SMS after a week avoids sending a lot of SMS-es while testing the system (which may involve a lot of reboots).
          keepAliveSMSsent  = true;
          sendStatusSMS();
        }
      #endif
      

      Alternatively, you could check out the smart alarm clock code. It will show you how to request the time from the controller, turn that into a human readable time, and then you can do your thing.

      
      uint32_t unixTime = 0;
      
      
      void receiveTime(unsigned long controllerTime) {
        Serial.print(F("Received time: ")); Serial.println(controllerTime);
        unixTime = controllerTime;
        breakUpTime(unixTime);
      }
      
      
      
      void breakUpTime(uint32_t timeInput)
      {
      // Break the given time_t into time components.
      // This is a more compact version of the C library localtime function
      // Note that year is offset from 1970!
      
        uint32_t time;
      
        time = (uint32_t)timeInput;
        uint32_t Second = time % 60;
        time /= 60; // now it is minutes
        minutes = time % 60;
        time /= 60; // now it is hours
        hours = time % 24;
        time /= 24; // now it is days
        //int Wday = ((time + 4) % 7) + 1;                  // Which day of the week is it. Sunday is day 1 
        
        Serial.print(F("Calculated time: "));
        Serial.print(hours);
        Serial.print(F(":"));
        Serial.println(minutes);
      }
      
      
      posted in Development
      alowhum
      alowhum
    • Set forum search to only look back 2 years?

      I search the MySensors forum quite a bit, and often the first hits are from 4 years ago. They are almost never useful, as the code and often the concepts are outdated.

      Would it be possible to set the default search window to just 2 years ago? Or whenever MySensors 2.0 was released?

      Advanced search could still be used by anyone that wants to find older posts. But in general I think this could be a 'sane default'.

      posted in General Discussion
      alowhum
      alowhum
    • BBC Micro:bit and MySensors - a great match!

      The BBC Micro:bit is a small NRF52 based board that is designed for use in education (similar to the Raspberry Pi).

      Micro:bit features

      It comes with a lot of onboard things:

      • NRF51 chip
      • Micro USB port. A second chip allows the Micro:bit to show up as a USB drive once you plug it into your computer. You can place a hex file on there, and it will be loaded when you reboot it. Or you can program the board directly, like a normal Arduino.
      • A 3 axis accelerometer
      • A 5x5 red LED matrix
      • Digital compass / magnet sensor
      • 2 buttons
      • A PH battery connector (but no charging circuitry). Idle it uses 5.38 mw.

      BUYING
      The cheapest Micro-bit I've found is $18 on Aliexpress.

      There are LOTS of expansion boards available. Some nice ones:

      • The $3 expansion board clips behind the Micro:bit and offers pins for 3 simple sensors/actuators.
      • The $8 sensor board has really nice break-outs for I2C, and lots of VCC and GND pins.
      • The $10 motor board.

      GETTING STARTED

      • Lady Ada has a great PDF tutorial on using it with Arduino, full of little code snippets, to help you get started with all the onboard sensors it comes with.

      USAGE
      I plan to first use it for home security, as a battery powered..

      • Motion sensor on doors.
      • Window opening detector using the magnet sensor.

      OPPORTUNITIES
      The MySensors community could create some tutorials for children. Perhaps a teacher or instructor could set-up a gateway, and then children could get long-term data on all sorts of things. Do some citizen science.. learn about privacy issues 🙂

      posted in Hardware
      alowhum
      alowhum
    • MySensors in a NERF gun - a question about capacitors

      So I have this huge NERF gatttling gun that I was trying to have some fun with. I wanted to be able to lock or unlock the trigger remotely based on face recognition, which is handled by a mobile phone at the front of the gun.

      The problem I ran into is that whenever the gun's motors spin up then cause a power loss to the arduino. Now I could add a separate power supply for the Arduino, but it would obviously be much cleaner if it looks like a normal gun from the outside.

      So I figured I needed some kind of "electrcity buffer" that would continue to provide the Arduino with stable power whenever the motors spin up.

      I realised I know very little about capacitors.

      • Which type do I need? Some are "aluminium high frequency". Are motors high frequency? Should I get those? Do they charge up faster?
      • Is there any risk that a capacitor makes the situation worse? E.g. if it's empty and it sucks up electricity that should be going to the Arduino?
      • Some go up to 400 volts. Some seem a perfect match at 5.5 volts. How do you choose what voltage rating to get? Is there a trade-off? Is it wise to go a few volts above the voltage in your system?
      • I figured I wanted as many Farads as possible? So I found these capacitors with 4F. But I realised I have no idea if that's a lot. How can I compare it to, say, batteries? How long can a 4F 5.5v capacitor run an Arduino nano + radio?
      • Is there a downside to having a lot of Farads, other than the cost?
      • How do I make sure the energy in the capacitor is "reserved" for the Arduino? After all, the motors are on the same circuit, and could perhaps suck it dry instead?
      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Confirming node connected to gateway.

      Here's an example from some of my code, specifically the SETUP function.

      void setup() {
        Serial.begin(115200); // for serial debugging over USB.
      
        if(isTransportReady()){
          Serial.println(F("Connected to gateway!"));
        }else{
          Serial.println(F("! NOT CONNECTED TO GATEWAY"));  
        }
      
      #ifdef HAS_DISPLAY
        mySerial.begin(115200);
        wait(1500);
        mySerial.print(F("CLR(0);"));
        mySerial.print(F("SBC(0);"));
        
        if(isTransportReady()){
          mySerial.print(F("DCV16(115,1,w,0);"));
        }
      
        // Labels
        mySerial.print(F("DCV16(10,155,Barometer,5);"));  // Barometer label
      
        // Wait icon
        mySerial.print(F("CIRF(120,239,35,3);"));       // Circle as a background
        //mySerial.print(F("SBC(3);"));
        //mySerial.print(F("DCV16(105,230,wait,15);"));     // Show while the forecast is not available yet.
        //mySerial.println(F("SBC(0);"));
      
        wait(400);
      #endif
      
        if(!bme280.init()){
          Serial.println(F("! Sensor error"));
      #ifdef HAS_DISPLAY
          mySerial.println(F("DCV16(10,250,Sensor error,1);"));
      #endif
        }
      
        wdt_enable(WDTO_2S);                              // Starts the watchdog timer. If it is not reset once every 2 seconds, then the entire device will automatically restart.                                
      }
      

      Personally I then display a "w" icon in the top-right of the screen if a connection has been made.

      In the loop code it requests an ACK whenever it updates the sensor values to the gateway (once a minute). There is also a simple incrementing counter byte that increases by 1 every time there is no reply. As soon as this reaches 5 (meaning no response from the server for 5 minutes in a row) it prints an " " to the corner of the screen, to indicate the loss of connection.

      If data once again arrives in the receive function, then a "w" is once again printed to the top right corner, and the incrementing byte is set back to 0.

      posted in General Discussion
      alowhum
      alowhum
    • RE: Possible readymade sensor?

      Do you mean the 433 hub I created?

      I've been testing it with random devices I've ordered of Aliexpress, and it's so cool to see that it just immediately takes each and every one.

      The 433Hub can also copy and detect IR signals by the way. You just need to change two settings.

      posted in Hardware
      alowhum
      alowhum
    • RE: WI-FI IOT modules

      @scalz @Sergio-Rius

      I get your point, but the problem is very often mothers are not able to secure their LAN too

      True. That's why I'm not against WiFi, I'm against any IP-based technology for IoT devices. Which is ironic, since I'm a big fan of the Mozilla WebThings Gateway, a project whose main goal is to connect all kinds of devices to the internet using an open standard. I totally disagree with that goal 🙂

      mysensors only works bc it's not widely used

      True. I use MySensors for prototyping, but if the Candle project would ever turn into actual commercial devices, I'd probably move the wireless technology to Zigbee/Z-Wave/Bluetooth.

      So the overall point is that I much prefer network technologies that have smart devices on a separate, dedicated IoT network by design. Because it's separated by design, it means my mom is also better protected, by design.

      Then there's another point: these wifi modules have, or are connected to, ARM chips. These powerful chips are way more attractive to malicious parties than an Arduino Nano. That's why I follow the principle of "minimal viable hardware" when I design IoT devices.

      posted in General Discussion
      alowhum
      alowhum
    • RE: new 600Mhz Teensy 4.0 blows away *everything* on performance

      Machine learning?

      posted in Hardware
      alowhum
      alowhum
    • RE: 💬 Soil Moisture Sensor

      My sketch handles 6. Feel free to use it. It uses analog capacitive sensors. They cost about 3 euro.

      I would recommend getting an Arduino Nano with an Expansion board. Then you don't need to solder anything.
      https://www.aliexpress.com/item/Free-shipping-Nano-328P-IO-wireless-sensor-expansion-board-for-XBEE-and-NRF24L01-Socket-for-arduino/32298692903.html

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * DESCRIPTION
       * 
       * This node can measure the moisture of 6 different plants. It uses the cheap 'capacitive analog 
       * moisture sensor' that you can get for about 3 dollars an Aliexpress or eBay. For example:
       * https://www.aliexpress.com/item/Analog-Capacitive-Soil-Moisture-Sensor-V1-2-Corrosion-Resistant-Z09-Drop-ship/32858273308.html
       * 
       * Each plant' moisture value can also be responded to individually, either by turning on an LED (wire that to the plan, and you can see which one is thirsty) or, if you want, per-plant automated irrigation by connecting a little solenoid..
       * 
       * Todo: Allow the controller to set the threshold values for each plant individually. Unfortunately, Domoticz doesn't support this yet :-(
       * 
       */
      
      //#define MY_SIGNING_SIMPLE_PASSWD "changeme"
      #define MY_SPLASH_SCREEN_DISABLED                       // saves a little memory.
      //#define MY_DISABLE_RAM_ROUTING_TABLE_FEATURE          // saves a little memory.
      
      #define MY_NODE_ID 60                                   // Optional. Sets fixed id with controller.
      #define MY_PARENT_NODE_ID 0                             // Optional. Sets fixed id for controller.
      #define MY_PARENT_NODE_IS_STATIC                        // Optional. Sets fixed id for controller.
      
      #define MY_TRANSPORT_WAIT_READY_MS 5000                 // try connecting for 5 seconds. Otherwise just continue.
      
      // Enable debug prints to serial monitor
      //#define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      #define MY_RF24_PA_LEVEL RF24_PA_LOW                    // Low power radio setting works better with cheap Chinese radios.
      
      #include <MySensors.h>
      
      #define NUMBEROFSENSORS 6                               // How many sensors are connected?
      
      #define DRYNESSTHRESHOLD 45                             // minimum moisture level that is still ok. A lower value will trigger LED/irrigation.
      
      uint32_t SLEEPTIME = 60;                                // Sleep time between the sending of data (in SECONDS). Maximum is 254 seconds. Change "byte" to "int" further down in the code if you want more time between sending updates.
      unsigned long lastTimeChecked = 0;
      
      MyMessage msg(0, V_LEVEL);
      
      void before()
      {
      
        for (byte i = 3; i < NUMBEROFSENSORS + 3; i++){             // Set the LED (or irrigation vales) to their initial position.
          pinMode(i, OUTPUT);
          digitalWrite(i, LOW);
        }
        
      }
      
      
      void presentation()
      {
      	// Send the sketch version information to the gateway and Controller
      	sendSketchInfo(F("Plant Sensorium"), F("1.2"));
      
        // present the sensors
        for (byte i=0; i<NUMBEROFSENSORS ; i++) {
          present(i, S_MOISTURE, i); // the last i gives the controller a name, in this case the number of the sensor.
        }
      
      }
      
      void setup()
      {
        Serial.begin(115200);
        delay(1000);
        
        Serial.println(F("Hello world. Warming up the sensors (15 seconds)."));
      
        delay(15000);
        
      }
      
      void loop()
      {
      
        static byte measurementCounter = 0;                     // Counts the measurements that are done, once per second.
        uint32_t currentMillis = millis();                      // The millisecond clock in the main loop.
      
        if (currentMillis - lastTimeChecked > 1000) {           // Internally, the moisture values are checked every second.
          lastTimeChecked = currentMillis;
          
          Serial.println(F("__________"));
          
          for (int i=0; i<NUMBEROFSENSORS; i++) {               // loop over all the sensors.
            byte shiftedDigitalPin = i + 3;
          	int16_t moistureLevel = (1023-analogRead(i))/10.23;
            Serial.print(i);
            Serial.print(F(" mosture level: "));
          	Serial.println(moistureLevel);
            Serial.print(F("- output pin: "));
            Serial.println(shiftedDigitalPin);      
            Serial.print(F("- irrigation/LED state is "));
            Serial.println(digitalRead(shiftedDigitalPin));
      
            if(digitalRead(shiftedDigitalPin) == HIGH){                         // outputs the LED/irrigation status via serial. This code can be removed.
              Serial.print(F("- currently watering until "));
              Serial.println(DRYNESSTHRESHOLD + 10);
            }
      
            if (moistureLevel < DRYNESSTHRESHOLD){              // if the plant doesn' have enough water, turn on the LED/water.
              Serial.print(F("- moisture level is below "));
              Serial.println(DRYNESSTHRESHOLD);
              digitalWrite(shiftedDigitalPin, HIGH);
            }else if (moistureLevel >= DRYNESSTHRESHOLD + 10){   // turn of the water/led if the plant is wet enough.
              digitalWrite(shiftedDigitalPin, LOW);
            }
      
            if(measurementCounter < NUMBEROFSENSORS){           // During the first 6 seconds the script will send updated data.
              if(measurementCounter == i){                      // it sends sensor 0 at second 0. Sensor 1 at second 1, etc. This keeps the radio happy.
                Serial.println(F("- sending data."));
                send(msg.setSensor(i).set(moistureLevel));
              }
            }
            if(measurementCounter > SLEEPTIME){ // If enough time has passed, the counter is reset, and new data is sent.
              measurementCounter = 0;
            }else{
              measurementCounter++;
            }
          }
          
        }
      }
      
      posted in Announcements
      alowhum
      alowhum
    • RE: API first controller with OTA support, also exposes WebOfThings APIs for sensors

      I can't believe nobody responded to this yet.

      Because this is awesome!! Thank you so much for working on this.

      If I understand correctly, your project translates MySensors into an API that follows the the Web of Things standard? And because of that the MySensors things can become visible in Mozilla's project?

      How far along are you? What do you have working?

      How can I test out your work?

      I love Mozilla's simple interface.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Enclosure for Temp + Humidity node with OLED display

      I hide my sensors in old library books. I try to get the name of the book to be a pun on the sensor inside. So for example, I have an air quality sensor that is inside a murder mystery called "poison".

      posted in Enclosures / 3D Printing
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      Version 0.1.2 has been uploaded. It has a lot of new features:

      • Automatic serial port searching. User doesn't need to add a serial port ID manually anymore (but can if they want)
      • Support for metric/imperial units. You can set your preference in the add-on settings.
      • Support for multipleOf. This should help show a sane amount of decimals on numeric variables.
      • Experimental MQTT support based on user feedback.
      • Anticipates switch to version 0.9 of the WebThings gateway by implementing title support.
      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: MySensor Things - show up 'as active' when they are unplugged

      I asked, and the add-on should handle the timeouts.

      Ideally I'd go the route where each device communicates the intended timeout. I've created a proposal on the MySensors Github to implement something like this.

      I think for now I will implement a universal timeout period, and then find a way for individual nodes to override that default if they communicate an individual period.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      Interesting. I'll see if there's an 'official' way to implement battery level.

      // Asked a question on how to implement it.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      @badmannen I'd love that feature too, but for now I think it will have to wait until Mozilla implements per-device settings.

      Meanwhile, a new version of the add-on (1.0.2) should be available soon.

      • Added MQTT topics support
      • Cloning can now be better controlled: child ID's above 100 will be cloned out into new things.
      • Better support for S_Power's V_Types.
      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: nRF5 action!

      W00t! Hurray! Nevermind. I just tried my other module, and that one worked fine!

      Open On-Chip Debugger 0.10.0-dev-gdc53227 (2016-04-09-13:45)
      Licensed under GNU GPL v2
      For bug reports, read
      	http://openocd.org/doc/doxygen/bugs.html
      debug_level: 2
      0x4000
      Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
      adapter speed: 10000 kHz
      Info : Unable to match requested speed 10000 kHz, using 4000 kHz
      Info : Unable to match requested speed 10000 kHz, using 4000 kHz
      Info : clock speed 4000 kHz
      Info : STLINK v2 JTAG v19 API v2 SWIM v4 VID 0x0483 PID 0x3748
      Info : using stlink api v2
      Info : Target voltage: 3.239128
      Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
      nrf52.cpu: target state: halted
      target halted due to debug-request, current mode: Thread 
      xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
      ** Programming Started **
      auto erase enabled
      Info : nRF51822-QFN48(build code: B00) 512kB Flash
      Warn : using fast async flash loader. This is currently supported
      Warn : only with ST-Link and CMSIS-DAP. If you have issues, add
      Warn : "set WORKAREASIZE 0" before sourcing nrf51.cfg to disable it
      nrf52.cpu: target state: halted
      target halted due to breakpoint, current mode: Thread 
      xPSR: 0x61000000 pc: 0x2000001e msp: 0xfffffffc
      wrote 4096 bytes from file /var/folders/pg/bjymtmv12dv77vh__zxyvs600000gn/T/arduino_build_362545/MyBoardNRF5.ino.hex in 0.215516s (18.560 KiB/s)
      ** Programming Finished **
      ** Verify Started **
      nrf52.cpu: target state: halted
      target halted due to breakpoint, current mode: Thread 
      xPSR: 0x61000000 pc: 0x2000002e msp: 0xfffffffc
      verified 2768 bytes in 0.065170s (41.478 KiB/s)
      ** Verified OK **
      ** Resetting Target **
      shutdown command invoked
      

      I had to do "burn bootloader" once to remove the security. And then it worked!

      Hmm "reset enable" is still turned on. What does that do exactly?

      posted in My Project
      alowhum
      alowhum
    • RE: !TSM:FPAR:NO REPLY

      I fixed it by adding:

      #define MY_NODE_ID 11
      #define MY_PARENT_NODE_ID 0
      #define MY_PARENT_NODE_IS_STATIC
      

      I had been noticing that the gateway was overwriting old nodes that hadn't connected for a while. Oddly, I can see the following ID's in Domoticz:

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      123

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Best 3d printers

      @alowhum said in Best 3d printers:

      https://www.cnx-software.com/2019/04/22/zonestar-z6-entry-level-portable-3d-printer/

      I bought the Ender 3 (non-pro). It's my first 3D printer. So far it's great. I'm going to add an Mini E3 board to decrease the high-pitched noise from the stepper motors. I also bought a $9 3D Touch, a fake BLTouch, for auto bed levelling. Although it's not really needed? The bed has remained stable. Then I'll install that following this guide.

      I've also used a Pi Zero W I had lying around to install Octoprint. No more hassle with SD cards. There's even a plugin called "Spaghetti Detective" that uses machine learning to watch webcam images of your print being made. If your print goes wrong, it automatically stops it.

      posted in Enclosures / 3D Printing
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      I've uploaded the BETA version.

      • Improved speed thanks to asynchronous handling of incoming messages.
      • Now supports most sensors
      • Now supports most actuators.

      Missing or just partially implemented are:

      • Thermostat/HVAC devices. The Gateway does not support them yet.
      • IR sender/receiver

      Please test it and let me know how it goes 🙂

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: nRF5 action!

      Note: to hack it you need a J-Link device:
      https://github.com/micooke/arduino-nRF5-smartwatches/blob/master/nrf52_disable_read_protection.txt

      posted in My Project
      alowhum
      alowhum
    • RE: Build a reliable power supply chain

      @mathea90 Out of curiosity: how do you feel about these boards?

      https://www.aliexpress.com/af/nano-wireless-expansion.html

      I love them. Just plug in the NRF24 and you're done. Lots of VCC and GND lines for all the sensors.

      They also seem to have a lot of those 1117 parts?

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Best 3d printers

      @dzjr have a look here:
      https://www.reddit.com/r/3Dprinting/comments/gdbu1o/purchase_advice_megathread_what_to_buy_who_to_buy/

      I think the 'consensus' is that these are the beginner printers to go for currently:

      Under $200
      Ender 3. It's recommended as a cheap beginners machine. This does not have any automation features though, such as automatic bed levelling, detecting if your fillament runs out, etc. Although you can add those if you want. It's also quite noisy.

      Above $200
      For a more hassle free experience I believe the Prusa i3 Mk3S is the recommended one to go for. It's more expensive of course, but you get a lot of that automation.

      It also depends on what material you want to print. Woodgrain filament cannot be used with the Ender's default extruder, for example, it will damage it. Something worth checking before purchase is it it can print flexible filament. That stuff is amazing! In general it seems ABS filament has become very unpopular.

      Don't worry too much about things like touch screens. You'll likely want to get a Raspberry Pi and install Octoprint on it. That way you can send prints to your printer and monitor its progress without having to babysit it. You don't want to be sitting next to those fumes and the noise all the time.

      Also don't worry about flexible removable magnetic printer beds. From what I can tell glass beds offer the best quality for things like PLA, which is what you'll most likely be printing in generally.

      Whatever you do, go for a printer that has a large community of users. If you go on websites like Thingiverse you'll immediately notice which printers are popular. If you look at the most popular new 3D print designs you'll currently find a lot of Ender specific creations.

      posted in Enclosures / 3D Printing
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      I've uploaded version 0.0.2, hopefully it will be accepted.

      Changes are:

      • Now supports not just serial, but also ethernet and MQTT. If anyone can test MQTT I would be very grateful.
      • Now uses persistence internally - it remembers which node ID's are available better.
      • Some minor improvements to S_ and V_ type support. I've tested most of my nodes now. They require a re-think sometimes in how things are presented.

      Currently you need to always give names to the sketch and to the children. If this is a big problem for people I might make it so that if there is no name, a generic name will be given.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: nRF24Doctor

      Very cool!

      Just thinking out loud: Would it be an idea to create a 'light' version of this that could be loaded onto a bare node, without any sensors/screens, and that would output details over serial? For beginners it might be a bit much to invest in so much hardware. But the core functionality is awesome!

      posted in My Project
      alowhum
      alowhum
    • RE: [SOLVED] Communication between Gateway & Node with or without MY_NODE_ID

      I always got those FPAR errors with cheap/bad power supplies.

      Since I've been using the Arduino Nano Wireless Expansion Boards those problems are behind me. Never have to use the capacitors anymore.

      I'd recommend getting some of those.

      posted in Troubleshooting
      alowhum
      alowhum
    • The dust sensor is now finally working

      Could someone with access to the website perhaps update the Dust page with this?

      In a way this is old already. The code below is for the WaveShare device, which I don't think should be the recommended device (currently the webpage links to it on Aliexpress). Consensus is that the other devices are all better than the Sharp sensor:

      • They are cheaper.
      • They are more precise. This sensor can only differentiate 70 levels of dust across its entire spectrum. And it won't measure small amounts of dust below 50ug/m3. Since a clean house has below 50 ug/m3, this sensor will only tell you if your house is extremely dusty.
      • They don't need an extra fan. Adding a fan manually may be a point where different sensors will get different measurements because their airflow is bound to be different.

      That being said, it now works. I started with the supplied Arduino code form the manufacturer, to look at what they recommended. I wrote the code in such a way that it is easy to add additional sensors, for example to also measure other bigger and smaller dust sizes.The new code also doesn't use sleep, so can be used as a repeater without any problem. Why aren't all sensors written like that yet?

      On the website I suggest new sensor pages should be added for the two other devices, whose code, oddly enough, is already in the examples library. Once those pages are made, this sensor's page should point people to those better alternatives really.

      FOR THE WEBSITE

      Do you need help from your home automation system to hint you when it's time to clean the house? With this sensor you could get a gentle reminder when dust levels rises over a predefined level. Or send an SMS to the cleaning company!

      This code is for an older, but widely used Sharp sensor. Specifically, it's the version sold by WaveShare, which makes it useless for the stand-alone version, sorry.

      More details about the WaveShare device can be found here:
      www.waveshare.com/wiki/Dust_Sensor

      We don't recommend using this sensor anymore, as cheaper, better alternatives exist. The code for those devices can already be found under the examples in the MySensors library.

      Unlike the alternatives, this sensor also needs you to add a small fan to make air flow through it. You can just attach the recommended one to the 5V and GND headers on your Arduino, but a variable resistor is recommended, as it will allow you to finetune the airflow.
      https://www.aliexpress.com/item/2510S-5V-Cooler-Brushless-DC-Fan-25-10mm-Mini-Cooling-Radiator-Free-Shipping/32581120442.html

      THE CODE

      /**
      * The MySensors Arduino library handles the wireless radio link and protocol
      * between your home built sensors/actuators and HA controller of choice.
      * The sensors forms a self healing radio network with optional repeaters. Each
      * repeater and gateway builds a routing tables in EEPROM which keeps track of the
      * network topology allowing messages to be routed to nodes.
      *
      * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
      * Copyright (C) 2013-2015 Sensnology AB
      * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
      *
      * Documentation: http://www.mysensors.org
      * Support Forum: http://forum.mysensors.org
      *
      * This program is free software; you can redistribute it and/or
      * modify it under the terms of the GNU General Public License
      * version 2 as published by the Free Software Foundation.
      *
      *******************************
      *
      * REVISION HISTORY
      * Version 1.2 - created by anonymous user
      * Version 1.3 - Added iled pinout in setup
      * 
      * DESCRIPTION
      * A MySensors Arduino script for the WaveShare Dust Sensor. This is a Sharp GP2Y1010AU0F
      * sensor that is built on top of some extra regulating and dasiy-chainable bit of electronics. 
      * In practice it can only detect about 70 dust levels. More details about it can be found here:
      * www.waveshare.com/wiki/Dust_Sensor
      *
      * Connect the sensor as follows:
      * 
      *   GND        to Arduino GND
      *   VCC        to Arduino 5V (The Sensor needs 5v to operate, 3.3v is not ok!)
      *   AOUT       to Arduino pin A0 (the values from the sensor arrive here)
      *   ILED       to Arduino pin 3 (this is used to control the LED that the sensor uses internally)
      *   
      * It is also HIGHLY RECOMMENDED that you connect a tiny fan that will blow air into the sensor. 
      * Search for "5v cooler" on Aliexpress to find a very cheap and small 2.5cm fan which costs about a dollar.
      * Just hook that up to your 5V and GND on your arduino, with a resistor. I've attached a variable 
      * resistor so that I could change the fan's speed (which I then keep constant and quiet).
      *
      * This script is inspired by the example file shared by the WaveShare company that explains how to use their creation.
      * The script has been written in such a way that it doesn' use the Sleep command. This allows it to easily function as a repeater in a node network.
      * It has also been written in a way to relatively easily allow for the addition of another sensor.
      * 
      * http://www.mysensors.org/build/dust
      * 
      */
      
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      #define MY_RADIO_NRF24                                // Radio device. There is a long-range radio version available. Don't power that from the Arduino pins, but connect it to a separate GND and 5V line instead.
      // #define MY_RF24_PA_LEVEL RF24_PA_LOW               // If you DO want to connect the long-range radio directly to the arduino's 5V and GND, then set it to low-power mode.
      // #define MY_RADIO_RFM69                             // An alternative radio technology.
      
      // #define MY_REPEATER_FEATURE                        // This script has been written in such a way that it can simultaneously function as a MySensors repeater. Just remove the two slashes at the beginning on this line.
      
      #include <MySensors.h>  
      #include <SPI.h>
      
      
      
      // VARIABLES
      
      
      // WaveSchare 2,5 micrometer sensor specific settings. These all use "25" in the variable name to make it easy to copy/paste it all if you want to add a second sensor.
      
      //You can change these:
      #define ILED 7                                        // Drive the sensor' led of sensor via pin 7 on the arduino. Feel free to change.
      #define VOUT A3                                       // Analog input for the Sharp sensor, in this case connectedto the A0 on the arduino. Feel free to change.
      #define SEND_FREQUENCY25                   30000      // Similar to SLEEP TIME. Time between sending measurements to MySensors. In this case every minute. Should be higher than INTERNAL_MEASUREMENT_INTERVAL25 * NUM_READS25.
      #define INTERNAL_MEASUREMENT_INTERVAL25    1280       // MILLIseconds to wait until the next internal measurement.
      #define NUM_READS25                        10         // Number of Waveshare sensor readings that will be averaged before that average value is sent to the MySensors gateway.
      
      // Only change these if you know what you're doing:
      #define SENSOR_WARMUP_MICROTIME25          280        // MICROseconds that the LED has to be on before a reading is made.
      #define CONVERSION_RATIO25                 0.2        // A quick way to go form the calculated voltage to the dust weight, expressed in ug/m3 / mv
      #define NO_DUST_VOLTAGE25                  400        // A compensation in Millivolts for leaked in light? If so, in theory you should calibrate this. 
      #define VOLTAGE_SUPPLIED_TO_SENSOR25       5000       // The maximum milli-voltage you will supply your sensor. Here 5000 means it's 5 Volts.
      
      // Don't change these:
      float   CALCULATED_VOLTAGE25 = 0;                     // Variable to hold the voltage which will be calculated from the received Waveshare sensor value.
      float   DUST_DENSITY25 = 0;                           // Variable that will hold the calculated dust weight per cubic meter in ug/m3.
      int     RAW_INPUT25 = 0;                              // Variable to hold the measurement received from the WaveShare sensor. Doesn't get much higher than 80. The WaveShave uses an internal 1/10 voltage divider, so multiply by 11 to get to the originally measures voltage. Weird design choice..
      float   SENSOR_SUM25 = 0;                             // A variable that stores the sum of all sensor values during collection run. If you divide it through the number of measurements, you get the average value.
      int     GATHERED_READINGS25 = 0;                      // A simple counter to see if we have enough readings to average and then send to the MySensors gateway.
      unsigned long PREVIOUS_MEASUREMENT_MILLIS25 = 0;      // Used for timing the internal gathering loop, in this case counting to see it a second has passed since the previous measurement.
      unsigned long PREVIOUS_SEND_MILLIS25 = 0;             // Used to remember the previous time the sensor work up to start gathering fresh data, to count if the SEND_FREQUENCY interval has passed.
      unsigned long LED_ON_MICROTIME25 = 0;                 // To keep track of the time since the Sharp's LED was turned on. Voltage should be read 280 microseconds after turning on.
      boolean CURRENTLY_SENSING25 = true;                   // Allows for sleeping. It is set to "true" every time we reach the SEND_FREQUENCY counter, and set to false when enough internal measurements have been gathered to send and average to the gateway.
      boolean CURRENTLY_MEASURING25 = false;                // Used to regulate each internal measument. Indicates if the Sharp sensor' LED is on. It needs to be on for 280 milliseconds before taking the measurement.
      
      // MySensors settings
      #define CHILD_ID_DUST_25 0                            // For MySensors. Give each attached sensor a number.
      MyMessage DUST_MSG25(CHILD_ID_DUST_25, V_LEVEL);      // Set up the value we will be updating to the MySensors gateway.
      
      
      
      // General settings
      unsigned long CURRENT_MILLIS = 0;                     // The millisecond clock in the main loop.
      unsigned long CURRENT_MICROS = 0;                     // The microsecond clock in the main loop.
      
      
      
      void setup(){
        sleep(2000);                                        // For old times sake.
        pinMode(ILED, OUTPUT);                              // Setting LED pin.
        digitalWrite(ILED, LOW);                            // ILED's default position is low (an advantage of using the WaveShare).
        Serial.begin(115200);                               // for serial debugging
        Serial.print("Sensor online \n ");
      }
      
      
      
      void presentation()
      {  
        // Send the sketch version information to the gateway and Controller
        sendSketchInfo("Dust Sensor", "1.2");
        present(CHILD_ID_DUST_25, S_DUST);
        
        //If you mix in multiple sensors, here is a suggestion:
        //present(CHILD_ID_DUST_10, S_DUST);                // Bigger particles. It's coarse and rough and irritating and it gets everywhere. Your nose filters these quite well.
        //present(CHILD_ID_DUST_25, S_DUST);                // Fine dust. Known to be detrimental to health in larger quantities, as they can get deeper into your lungs.
        //present(CHILD_ID_DUST_01, S_DUST);                // One micrometer. The biggest of the so-called 'ultra-fine' nano-particles, of which the health effects are still under investigation.
      }
      
      
      
      void loop(){
        CURRENT_MILLIS = millis();                          // This script tries to avoid using the Sleep function, so that it could at the same time be a MySensors repeater.
        CURRENT_MICROS = micros();                          // For extra precise measurements at sensors. Rolls over every 70 minutes, but it shouldn' affect measurements; subtraction will still work.
       
        if (CURRENT_MICROS - LED_ON_MICROTIME25 >= SENSOR_WARMUP_MICROTIME25) {
              
          if (CURRENTLY_MEASURING25 == true){
            
            RAW_INPUT25 = analogRead(VOUT);
            digitalWrite(ILED, LOW);
            
            Serial.print("WaveShare: read value: ");
            Serial.print(RAW_INPUT25);
            Serial.print("\n");
            
            CALCULATED_VOLTAGE25 = (VOLTAGE_SUPPLIED_TO_SENSOR25 / 1024.0) * RAW_INPUT25 * 11; // This is the conversion recommended by WaveShare.
        
            if (CALCULATED_VOLTAGE25 >= NO_DUST_VOLTAGE25) { //Filtering out leaked light apparently. I'm not even mentioning the spikes..
              CALCULATED_VOLTAGE25 -= NO_DUST_VOLTAGE25;
              Serial.print("WaveShare: measured voltage is high enough: ");
              Serial.print(CALCULATED_VOLTAGE25);
              Serial.print("\n");
              DUST_DENSITY25 = CALCULATED_VOLTAGE25 * CONVERSION_RATIO25;
              
              SENSOR_SUM25 = SENSOR_SUM25 + DUST_DENSITY25;
              GATHERED_READINGS25++;
              Serial.print(GATHERED_READINGS25);
              Serial.print(" gathered readings. ------------\n");
            }
            else
            {
              Serial.print("Waveshare: too little dust detected. \n");
              // Low readings have a way too big influence on the average value. I am not adding them to the average, which is cheating a little bit. But the other way around it would have way more detrimental influence.
              DUST_DENSITY25 = 0;
            }
            CURRENTLY_MEASURING25 = false;
          }  
        }
      
        if (CURRENT_MILLIS - PREVIOUS_MEASUREMENT_MILLIS25 >= INTERNAL_MEASUREMENT_INTERVAL25) {
          if(CURRENTLY_MEASURING25 == false && CURRENTLY_SENSING25 == true){
            // Time for a new internal measurement
            PREVIOUS_MEASUREMENT_MILLIS25 = CURRENT_MILLIS;
            CURRENTLY_MEASURING25 = true;
            LED_ON_MICROTIME25 = micros();
            digitalWrite(ILED, HIGH);
      
          }
        }
        
        if(GATHERED_READINGS25 >= NUM_READS25){
          if(CURRENTLY_SENSING25 == true){
            Serial.print("Gathered enough readings, time to send an average and then sleep. \n");
            float sendMe = SENSOR_SUM25 / GATHERED_READINGS25;
            send(DUST_MSG25.set(sendMe,2)); // Send the 2,5 micrometer data to the MySensors gateway. It makes no scientific sense to send decimals really, it gives afalse sense of accuracy.
            Serial.print("=== WaveShare: the SENT average was ");
            Serial.print(sendMe);
            Serial.print(" micrograms of 2,5 micrometer dust per cubic meter ===\n");
            Serial.print("Waveshare: zzzzZZZZzzzzZZZZzzzz\n");
            CURRENTLY_SENSING25 = false; // The work is done, time to sleep.
            CURRENTLY_MEASURING25 = false; // No need to make another measurement, time to sleep.
            digitalWrite(ILED, LOW); // Turn off LED, just to be sure. Time to sleep.
          }
        }
        
        if(CURRENT_MILLIS - PREVIOUS_SEND_MILLIS25 >= SEND_FREQUENCY25){
          if(CURRENTLY_SENSING25 == true){
            // Uh oh! We're at the end of the run, and still don't have enough good measurements! Is the air that clean?
            float sendMe = 0;
            if(GATHERED_READINGS25 <= (NUM_READS25 / 2)){
              send(DUST_MSG25.set(sendMe,2)); // Very few measurements succeeded, so it's better to send a 0 value to indicate this.
              }
              else
              {
               Serial.print("Sending what we have..\n");
               float sendMe = SENSOR_SUM25 / GATHERED_READINGS25;
               send(DUST_MSG25.set(sendMe,2)); // Send the 2,5 micrometer data to the MySensors gateway. It makes no scientific sense to send decimals really, it gives a false sense of accuracy.
              }
            CURRENTLY_MEASURING25 = false; // No need to make another measurement in this run, time's up.
          }
          Serial.print("Time to wake up and start fresh. \n");
          PREVIOUS_SEND_MILLIS25 = CURRENT_MILLIS; // Save the current time, to later calculate when we the sensor should wake up again.
          GATHERED_READINGS25 = 0; // Reset measurements counter.
          SENSOR_SUM25 = 0; // Reset the variable that stores the sum of the internally gathered measurements.
          CURRENTLY_SENSING25 = true; // Here we go again.
        }
      }
      
      
      
      
      
      posted in Development
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      @nca78 I have the exact same issue. This is a known problem with the Mozilla Gateway.

      But you're also right that this should be a temperature sensor. Good one! I will change it.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: nRF5 action!

      This looks like an Arduino-nano/pro-mini style device with an NRF51:

      https://www.aliexpress.com/item/Nrf51822-LIS3DH-Bluetooth-Module-CJMCU-8223-Bluetooth-acceleration-module/32821873481.html

      posted in My Project
      alowhum
      alowhum
    • RE: Auto resend on NACK

      Here's some ACK experiment code, might be useful. I've left all the messy stuff in, might be interesting.

      The important thing is the retry counter. When a message is sent this is set to 3. If there is no acknowledgement, the message will be sent again, and the counter goes to 2. When it reaches 0 it stops trying to resend.

      If an ACK message is received, it also sets the counter to 0 - resending is not required anymore.

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       *
       * DESCRIPTION
       * Example sketch showing how to control physical relays.
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       * 
       * 
       * 
       * Only sends a quick pulse via a reed relay. Useful to hack other devices with push 
       * buttons. In my case, a cheap IKEA dishwasher that didn't have a timer.
       */
      
      // security
      //#define MY_SIGNING_SIMPLE_PASSWD   "changeme"
      //#define MY_ENCRYPTION_SIMPLE_PASSWD "changeme"
      
      //#define MY_RF24_DATARATE RF24_250KBPS // Slower datarate offers more range. Only the + version of the radio supports 250kbps
      //#define MY_RF24_DATARATE RF24_1MBPS               
      //#define MY_RF24_DATARATE RF24_2MBPS
      
      //#define CE_PIN   10
      //#define CSN_PIN 9
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      // Enable and select radio type attached
      //#define MY_RADIO_RFM69
      #define MY_RADIO_NRF24
      
      //#define MY_RF24_PA_LEVEL RF24_PA_MIN
      #define MY_RF24_PA_LEVEL RF24_PA_LOW
      
      
      // Enable repeater functionality for this node
      //#define MY_REPEATER_FEATURE
      
      #include <MySensors.h>
      
      // MySensors children
      #define DEVICE_STATUS_ID 0                          // The first 'child' of this device is a text field that contains status updates.
      #define RELAY_1_CHILD_ID 1 // MySensors child ID
      #define DONE_CHILD_ID 2 // MySensors child ID
      
      #define RELAY_1_PIN  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // Total number of attached relays
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      #define PULSELENGTH 500 // How long the pulse should last (how long the button should be pressed).
      
      #define LOOPDURATION 600000
      #define ON_TOO_LONG 9 // If it's been on for X * 10 minutes, then it should send a message.
      #define RADIO_DELAY 150 // Keeps the bad Chinese radio happy / supplied with stable power.
      
      byte loopCounter = 0;
      boolean state = 0;
      byte retryCounter = 3;
      
      MyMessage charmsg(DEVICE_STATUS_ID, V_TEXT);        // Sets up the message format that we'll be sending to the MySensors gateway later. The first part is the ID of the specific sensor module on this node. The second part tells the gateway what kind of data to expect.
      MyMessage relaymsg(RELAY_1_CHILD_ID, V_STATUS);
      MyMessage donemsg(DONE_CHILD_ID, V_TRIPPED);
      
      
      
      void before()
      {
      	//for (int pin=0; pin < NUMBER_OF_RELAYS; pin++) {
      		// Then set relay pins in output mode
      	//	pinMode(pin + RELAY_1_PIN, OUTPUT);
      		// Set relay to last known state (using eeprom storage)
      	//	digitalWrite(pin, LOW);
      	//}
          pinMode(RELAY_1_PIN, OUTPUT);
          // Set relay to last known state (using eeprom storage)
          digitalWrite(RELAY_1_PIN, LOW);
       
      }
      
      
      void presentation()
      {
      	// Send the sketch version information to the gateway and Controller
      	sendSketchInfo(F("Dishwasher"), F("1.1")); wait(RADIO_DELAY);
        present(DEVICE_STATUS_ID, S_INFO, F("Status")); wait(RADIO_DELAY); 
        present(RELAY_1_CHILD_ID, S_BINARY, F("Start")); wait(RADIO_DELAY);
        present(DONE_CHILD_ID, S_MOTION, F("Done?")); wait(RADIO_DELAY);
      
        //send(relaymsg.setSensor(RELAY_1_CHILD_ID).set( RELAY_OFF )); wait(200);
      	//for (int i=0; i<NUMBER_OF_RELAYS; i++) {
      		// Register all sensors to gw (they will be created as child devices)
      		//present(sensor, S_BINARY, F("Start")); wait(100);
          //send(relaymsg.setSensor(RELAY_1).set( RELAY_OFF )); wait(100);
      	//}
      }
      
      
      void setup()
      {
        wait(1000);
        Serial.begin(115200);
        Serial.println(F("Hello world, I am a dish washer."));
      
        if(isTransportReady()){
          Serial.println(F("Connected to gateway"));
      
        send(charmsg.setSensor(DEVICE_STATUS_ID).set( F("Dishwasher turned on"))); wait(RADIO_DELAY);  
        send(relaymsg.set(state?false:true), true); wait(RADIO_DELAY); // Send new state and request ack back
        send(donemsg.setSensor(DONE_CHILD_ID).set(0)); wait(RADIO_DELAY);
          
        }else{
          Serial.println(F("Not connected to gateway"));
        }  
      }
      
      
      void loop()
      {
      
        static unsigned long lastLoopTime = 0;            // Holds the last time the main loop ran.
        if (millis() - lastLoopTime > LOOPDURATION) {
          lastLoopTime = millis();
          sendHeartbeat();
      
          // Having fun with status messages
          if( loopCounter < 251 ){
            loopCounter++;
          }
          if( loopCounter == ON_TOO_LONG ){
              send(charmsg.setSensor(DEVICE_STATUS_ID).set( F("Probably done"))); wait(RADIO_DELAY);  
              send(donemsg.setSensor(DONE_CHILD_ID).set(1)); wait(RADIO_DELAY);
          }
          if( loopCounter == ON_TOO_LONG * 2){
              send(charmsg.setSensor(DEVICE_STATUS_ID).set( F("Turn me off please"))); wait(RADIO_DELAY);  
          }
          if( loopCounter == ON_TOO_LONG * 3){
              send(charmsg.setSensor(DEVICE_STATUS_ID).set( F("PLEEAASE turn me off!"))); wait(RADIO_DELAY);
          }
          
          if( loopCounter == 250){
              send(charmsg.setSensor(DEVICE_STATUS_ID).set( F("OMG I am still on??"))); wait(RADIO_DELAY);  
          }
        }
      
        //if( retryCounter > 0 ){
        //  retryCounter--;
        //  send(relaymsg.set(0), true); wait(RADIO_DELAY);  // Send new state and request ack back
        //}
      
      }
      
      /*
      void messageRepeat(MyMessage &message, bool ack = true) {
        int repeat = 1;
        int repeats = 10;
        int repeatdelay = 0;
        boolean sendOK = false;
      
        SerialPrint("Sending message of child ");
        SerialPrintln(message.sensor);
      
        while ((sendOK == false) and (repeat < repeats)) {
          if (send(message, ack)) {
            sendOK = true;
            SerialPrint("Send OK");
          } else {
            sendOK = false;
            SerialPrint("Send ERROR ");
            SerialPrint(repeat);
            repeatdelay += RADIO_DELAY;
          }
      
          if (ack == true) {
            SerialPrintln(" With ack ");
          } else {
            SerialPrintln(" Without ack ");
          }
      
          repeat++;
          wait(repeatdelay);
        }
      }
      */
      
      
      
      void receive(const MyMessage &message)
      {
      	// We only expect one type of message from controller. But we better check anyway.
      
        Serial.print("Incoming message for child: ");
        Serial.println(message.sensor);
      
        if (message.isAck() && message.sensor == RELAY_1_CHILD_ID) { // We got the ACK!
          Serial.println("- Received ACK for relay");
          retryCounter = 0;
        }
        else{
          // Change relay state
          Serial.println("-Gateway wants to change relay position");
        	if (message.type==V_STATUS) {
        		
            Serial.print ("-Received V_status:");
            Serial.println(message.getBool());
            
            if( message.sensor == RELAY_1_CHILD_ID ){
              boolean desiredState = message.getBool()?RELAY_ON:RELAY_OFF;
                if(desiredState == RELAY_ON){
                //digitalWrite(message.sensor-1+RELAY_1_PIN, RELAY_ON);
                //wait(PULSELENGTH);
                //digitalWrite(message.sensor-1+RELAY_1_PIN, RELAY_OFF);
                Serial.print ("-Switching relay on...");
                digitalWrite(RELAY_1_PIN, RELAY_ON);
                wait(PULSELENGTH);
                Serial.println ("Switching relay off.");
                digitalWrite(RELAY_1_PIN, RELAY_OFF);
                retryCounter = 3;
                }
            }
        		//digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
        		// Store state in eeprom
        		// saveState(message.sensor, message.getBool());
        		// Write some debug info
        	}
        }
      }
      
      posted in Troubleshooting
      alowhum
      alowhum
    • RE: New non-blocking temperature sensor code

      Yes, exactly. @hek mentioned replacing that one with the BME280. The only thought I had there was: people looking for a temperature sensor may not find it there if it's just labeled as a humidity sensor. If we can call it "temperature & humidity & barometric pressure sensor", then I'm all for replacing that one with the BME code.

      And having both of them point to each other as a possible alternative.

      posted in Development
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      @Nca78 Version 0.0.4 has been accepted, and has the change you proposed. Thanks for thinking along!

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: nRF5 action!

      This company has the cheapest arduino-ish board I've found.

      It consists of a dev board..
      https://www.aliexpress.com/item/NRF51822-2-4G-Wireless-Module-Wireless-Communication-Module-Bluetooth-module-zigbee-module-DMX512/32726191346.html

      ...and the little module you place in it:
      https://www.aliexpress.com/item/NRF51822-2-4G-Wireless-Module-Wireless-Communication-Module-Bluetooth-module-zigbee-module-DMX512/32726191346.html

      Total cost: about 13 euros.

      posted in My Project
      alowhum
      alowhum
    • RE: Auto resend on NACK

      @electrik Is this a correct understanding?

      • Hardware ACK is just that is reaches the next node in the network, right? It could be a repeater saying "I got something from you". It doesn't 100% guarantee that it reached the controller correctly.
      • Software ACK is the controller sending back the exact same message you sent, but this time with the ACK bit set to true? It goes up and down your entire network. It's the best way to be sure that the message reached the controller, since you could theoretically even check if the message details are still the same as when you sent it.

      Both will happen when you set ACK to true in your send() function?

      So:
      if (send(msgFgeHum.set(fgehum),true)) is just checking the hardware ACK, meaning it got sent away ok.

      And then for software ACK you should use the receive function to check for a returning "echo" message:

      void receive(const MyMessage &message)
      {
      	// We only expect one type of message from controller. But we better check anyway.
      
        Serial.print("Incoming message for child: ");
        Serial.println(message.sensor);
      
        if (message.isAck() && message.sensor == RELAY_1_CHILD_ID) { // We got the ACK!
          Serial.println("- Received ACK for relay");
          retryCounter = 0;
        }
      

      Is this a correct summary?

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: MySensors 2.2 Release

      @ian-bishop I also notices there hasn't been much change in a week. Has is become stable?

      posted in Development
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      @nca78 Great, let me know how that goes.

      I also did a test here, and you're right. If a node cannot re-present itself when the gateway restarts, then it will stay 'disconnected'.

      I've changed how persistence works. It now always creates a persistence file. When you enable persistence, it will re-create all devices when the add-on is initialized. That would be more in line with what you expect from a feature like this anyway.

      I'll do a few more tests and then try to get it approved.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: nRF5 action!

      I just turned the BBC Micro:bit board into a MySensors repeater. No problem, went totally smooth.

      The cheapest Micro-bit I've found is $18 on Aliexpress.

      Lady Ada has a great PDF tutorial, full of little code snippets, to help you get started with all the onboard sensors it comes with.

      posted in My Project
      alowhum
      alowhum
    • RE: Auto resend on NACK

      @mfalkvidd Then how is hardware ACK enabled? I that what you enable in the presentation?

      present(TEXT_CHILD_ID, S_INFO, F("Status"),true);

      I always thought that enabling it in presentation() just means you didn't have to do it manually anymore, that it would be done for all messages of that child.

      Or it hardware ACK always on? And it's just a matter of whether you use the return of the send function or not?

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Secure gateway with sms receiver: stability?

      Thanks for the insight.

      @mfalkvidd: currently the power for all of this stuff is coming from the 5v pin on a nano. If the 800L takes 2000ma I'm amazed the nano still works 😄

      I think the version I have has an internal condensator to boost its power.

      @gohan: I have concidered using more powerful hardware like the STM32, but I try to use chips that are "just good enough".

      posted in Development
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      Version 0.0.5 has been accepted by Mozilla.

      Improvements:

      • More V_types supported, getting close to full support now.
      • Better, more conservative implementation of 'capabilties' from the Mozilla IoT schema.
      • If enabled, persistence is used to immediately re-create all MySensors devives upon reboot. Before, persistence was only used to avoid handing out duplicate node ID's. That has now become standard.
      • Smarter way of dealing with node removal. It now also removes persistence data.
      • Re-discovery process is faster now (asks one node ID per second to present itself). This is on top of the process that is already built into the PyMySensors library that this add-on is based on.

      Perhaps it's getting time to add this to the controllers overview, and fill in all the support details? Please contact me about how to do that. // done

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Candle - signal Hub - A universal 433Mhz signal detector and cloner

      The touch screen code is now also available.

      posted in My Project
      alowhum
      alowhum
    • RE: Auto resend on NACK

      Thanks.

      While we're on the subject: is there any built-in retry functionality for the hardware and/or software ACK? I believe if you set the ACK bit in the send function, then the hardware ACK will try to re-send the message a few times? I seem to remember seeing the ft value increase by one each time after a NACK.
      2070 TSF:MSG:SEND,27-27-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      I suspect this hardware-retry only works if you set the ACK to true?

      And another one:

      Does the isTransportReady() function check..
      A. If the radio works
      B. If there is a connection to a neighbour (repeater or gateway)
      C. If a handshake had been made with the controller

        if(isTransportReady()){
          Serial.println(F("Connected to gateway!"));
        }
        else {
          Serial.println(F("! NO CONNECTION"));
        }
      
      posted in Troubleshooting
      alowhum
      alowhum
    • RE: [security] Migrating from library version 2.1 to 2.2

      @anticimex Awesome!

      So I had a look at the new code, and is this a fair summary?:

      • Simple encryption and simple signing are now two separate functions you can call at the top of your script by adding a line with a password: MY_ENCRYPTION_SIMPLE_PASSWD and MY_SIGNING_SIMPLE_PASSWD.
      • You can also just put "MY_SECURITY_SIMPLE_PASSWD" at the top of your script, and that will do both in one go. This used to be called the MY_SIGNING_SIMPLE_PASSWD option, which also did both.
      MY_SIGNING_SIMPLE_PASSWD is now
      called MY_SECURITY_SIMPLE_PASSWD.
      MY_SIGNING_SIMPLE_PASSWD only affects signing,
      and a new flag, MY_ENCRYPTION_SIMPLE_PASSWD
      only affects encryption.
      MY_SECURITY_SIMPLE_PASSWD enable both these flags.
      

      This is simply wonderful.

      • More choice and flexibility for the end user.
      • Get some simple security on your existing Arduino hardware.

      Thank you so much for this.

      posted in Development
      alowhum
      alowhum
    • Controller page for Mozilla WebThings Gateway

      Here's some text for a page on the website for the Mozilla WebThings Gateway:

      The Mozilla WebThings Gateway is an open source smart home controller that focuses on easy of use and which is built around the proposed WebThings standard. It's an official Mozilla project being built by a team in Silicon Valley.

      It's main development platform is the Raspberry Pi, but also works on other platforms like MacOS. The software should also run on (beefy) OpenWRT routers.

      To enable MySensors support you will have to add the MySensors add-on, which can be installed with a few mouse clicks.

      Features:

      • Simple, easy to use interface. There is a strong focus on usability, and everything can be done via the web interface. Your mother can use this.
      • A drag-and-drop rule system.
      • Focus on privacy - data stays on your system.
      • Visualize your data in graph form. Data can be saved for up to a week.
      • Supports voice control, and supports local instances for improved privacy.
      • A well-designed plugin system which supports multiple programming languages.
      • An open source project by a respected organization.

      Support:

      • Zigbee, Z-wave, bluetooth, network devices, etc.

      Homepage: https://iot.mozilla.org/gateway/
      Github: https://github.com/mozilla-iot/gateway
      Getting started guide: https://iot.mozilla.org/docs/gateway-getting-started-guide.html

      Images from Mozilla:
      6_1558971878700_things_ui_screenshot.png 5_1558971878700_connect_wifi.png 4_1558971878700_choose_subdomain.png 3_1558971878700_image32.png 2_1558971878700_image20.png 1_1558971878700_image7.png 0_1558971878700_image4.png

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: MySensors-powered arcade game screen with wireless gamepad controller

      WOW!!! What a cool project!

      posted in My Project
      alowhum
      alowhum
    • RE: Auto resend on NACK

      @mfalkvidd Thank you so much for the explanation! I feel I'm getting a grasp on things.

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: [security] Migrating from library version 2.1 to 2.2

      @anticimex Heh, then I will invite him/her over for tea congratulate them. And then apply some verbal security 😛

      Can Arduino nano's be updated OTA?

      posted in Development
      alowhum
      alowhum
    • RE: Controller page for Mozilla WebThings Gateway

      @hek Will do. Thanks for adding it!

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Candle - signal Hub - A universal 433Mhz signal detector and cloner

      I haven't tested it without a screen myself. I'll look into it for you and see if I can make the code work optimally without it. I'll get back to you with the updated code.

      posted in My Project
      alowhum
      alowhum
    • RE: Soil Moisture Sensor / analog value

      What have you set as:

      #define SLEEPTIME 100                               // In seconds, how often should a measurement be made and sent to the server? The maximum delay between measurements is once every 254 seconds, but if you change "byte" to "int" further down in the code you could create more time between each loop.
      #define LOOPDURATION 5000                           // The main loop runs every x milliseconds. This main loop starts the modem, and from then on periodically requests the password.
      
      

      5000 * 1000 = 5.000.000 milliseconds between measurements = 8.33 minutes

      Change the loopduration (how long a tick of the internal clock takes) to 1000, and then the SLEEPTIME variable is in normal seconds again.

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: nRF5 OTA updates

      Awesome! Glad to hear you're exploring it!

      posted in Development
      alowhum
      alowhum
    • RE: MySensors add-on crashed ?

      @Nca78 Great, that will narrow things down. I've created a new version (0.0.6) that exposes the debug options. You will be able to enable 'debugging' and see all the same details I do while developing. Then we can find in more detail what it going on. It should arrive on your system automatically when Mozilla accepts it.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: RF433 MHZ connected to Serial Gateway

      I tried to create a gateway with this functionality too, but stopped because it took too much memory, and indeed requires an uninterrupted high speeds burst of signals once in a while.

      I have now been working on a node that can recognise and replay signals. It's universal: it can copy and then recognise and replay any signal. Well, any signal from 4 to 16 bytes. Which is all of them as far as I can tell. No need to mess with timings, it figures that out as well. It compresses the signals an stores them in EEPROM. On average 25 replayable signals can be stored in 512 bytes of storage this way. If you only want to re-detect the signal it's about 50.

      If you wait a few days I'll have some working code I can share.

      posted in Home Assistant
      alowhum
      alowhum
    • RE: Soil Moisture Sensor / analog value

      @k5austria said in Soil Moisture Sensor / analog value:

      May I operate my cheap Aliexpress radio module (nRF24L01+PA+LNA) with MY_RF24_PA_LEVEL RF24_PA_MAX ? Power supply is enough

      In my experience this will fail.

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Trying to bitbang i2c oled screen, using SSD1306Ascii library

      This looks interesting: a completely serial screen for $4:
      https://www.aliexpress.com/item/1-77-1-8-128-160-HMI-Intelligent-Smart-USART-UART-Serial-TFT-LCD-Module-Display/32908921322.html

      posted in Development
      alowhum
      alowhum
    • RE: MySensors add-on crashed ?

      It happens when you restart the add-on / gateway. I'm trying to figure it out here:
      https://github.com/mozilla-iot/gateway-addon-python/issues/48

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: HomeAssitant MySensors plugin Roadmap

      I've also used them both. Now I'm a very happy Webthings Gateway user. Try it!

      [edit by nca78] fixed link, should be without www.

      posted in Home Assistant
      alowhum
      alowhum
    • RE: !MCO:PRO:RC=1 in debug logs

      Yes, that was it. I love it when I answer my own questions 🙂

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Irrigation Controller ... how to achieve controll from smartphone?

      In really rough steps:

      • Get a raspberry Pi (e.g. the Zero WH)
        • install Raspbian (Lite) on it (burn to an SD card)
        • Install Domoticz onto that (see explanation of 'easy way' on the Domoticiz website)
        • Install the MySensors Raspberry Pi gateway (instructions on this site for installing software and connecting the radio to the Pi's pins)
        • In Domoticz, enable MySensors.
      • Create the sensor (connect hardware incuding the radio module, upload arduino code)
        • When powered on, it should appear in Domoticz (under 'devices').
      • Install the Domoticz app. for mobile control.

      That control will be limited to where you have wifi connection. If you want to control it from outside your home, then you may have to take some more steps.

      posted in Development
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      Version 0.0.7 has been created, and should hopefully be accepted soon.

      It fixes the issue that the user's preference for which capability should be shown centrally was reset every time the add-on restarted.

      Internally, the add-on always uses persistence. Whether devices are shown as 'connected' is now an option. You can either immediately show all MySensors nodes as 'connected' upon a restart, or wait until nodes have sent a signal.

      // It has been accepted

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: 💬 Dust Level Sensor

      STAY CLEAR OF THIS ONE FOR NOW

      • The code does not work. It is not complete! The fourth wire, the LED, is not even mentioned..
      • General consensus is that the suggested sensor is not that good. Other, newer sensors (Shinyei PPD42NS, SamYoung DSM501) are better, and don't need an extra fan to blow air into them, that's even built in.
      • Even if you really really want this one: the linked device is way too expensive. You can buy it much cheaper now. It's also a weird version (produced by a company called Waveshare).

      https://forum.mysensors.org/topic/3348/dust-sensor

      The code for the other sensors is already in the library, you can find it under examples (although I have not tested that code yet).

      posted in Announcements
      alowhum
      alowhum
    • RE: NRF24L01+ and NRF24L01+PA-LNA problems - testing in progress

      What @wiredfrank said. Don't use these unshielded PA device in the first place.

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Irrigation Controller ... how to achieve controll from smartphone?

      The Raspberry Pi was just meant as the server that runs the controller software. You would only need one ($15). In home automation you'll find everybody uses it for that.

      But since you already have a server, you won't need it.

      Openhab 2 is totally fine as a controller. Good choice.

      The gateway is the 'manager' in between your controller software and the MySensors network. It can be an arduino that the controller talks to via serial. Or, if you use a Raspberry Pi, it can be a second piece of software on your server. In this case you connect the radio module directly to your Raspberry Pi's GPIO pins. This saves you an Arduino, and makes your controller hardware smaller.

      Wifi is what a lot of smart home devices communicate with. The Nest thermostat, etc. Personally, I think that's a bad idea, since most of these 'smart' devices have poor security. So you don't want the smart devices to be on your home network (or at least not without some security barrier).

      That's why using MySensors is a good idea. Very hack-proof.

      Your other questions: if you start at the front page of the MySensors website and click through the explanations then you will learn a lot. The website is relatively good at explaining things for beginners.

      posted in Development
      alowhum
      alowhum
    • RE: MySensors: trying to add Things in WebThings Gateway

      @rmalbers Great work, that narrows things down a lot.

      It seems the add-on was crashing. Based on your reporting I dove into the issue and I think I may have found a bug in how it loaded settings.

      I'm uploading version 0.0.8 now. It should take a day or two before the Mozilla teams accepts the new version.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: 💬 Dust Level Sensor

      I've posted a working script and other details here:
      https://forum.mysensors.org/topic/6391/the-dust-sensor-is-now-finally-working

      posted in Announcements
      alowhum
      alowhum
    • RE: 💬 NodeManager

      Just wanted to say that NodeManager is awesome. I can't believe I only now really had a better look at what it is. I always thought it was some kind of software you had to install, and that it was used by professionals to manage complicated sensor nets.

      For the last few months I've been thinking "wouldn't it be useful if there was some kind of beginner friendly web interface where you could select which devices you want, and then it creates the code for you". This is so close to that. Thank you for this incredible work!

      posted in OpenHardware.io
      alowhum
      alowhum